diff --git a/toolkit/mozapps/extensions/internal/XPIDatabase.jsm b/toolkit/mozapps/extensions/internal/XPIDatabase.jsm index 5dfd01bead64..043ff5a60a51 100644 --- a/toolkit/mozapps/extensions/internal/XPIDatabase.jsm +++ b/toolkit/mozapps/extensions/internal/XPIDatabase.jsm @@ -2847,12 +2847,6 @@ this.XPIDatabaseReconcile = { ); } else if (unsigned && !isNewInstall) { logger.warn("Not uninstalling existing unsigned add-on"); - } else if (aLocation.name == KEY_APP_BUILTINS) { - // If a builtin has been removed from the build, we need to remove it from our - // data sets. We cannot use location.isBuiltin since the system addon locations - // mix it up. - XPIDatabase.removeAddonMetadata(aAddonState); - aLocation.removeAddon(aId); } else { aLocation.installer.uninstallAddon(aId); } @@ -2865,8 +2859,7 @@ this.XPIDatabaseReconcile = { // Assume that add-ons in the system add-ons install location aren't // foreign and should default to enabled. - aNewAddon.foreignInstall = - isDetectedInstall && !aLocation.isSystem && !aLocation.isBuiltin; + aNewAddon.foreignInstall = isDetectedInstall && !aLocation.isSystem; // appDisabled depends on whether the add-on is a foreignInstall so update aNewAddon.appDisabled = !XPIDatabase.isUsableAddon(aNewAddon); diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index b7d1ff6ac83c..0bedc135abe6 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -967,12 +967,6 @@ var BuiltInLocation = new (class _BuiltInLocation extends XPIStateLocation { get enumerable() { return false; } - - // Builtin addons are never linked, return false - // here for correct behavior elsewhere. - isLinkedAddon(/* aId */) { - return false; - } })(); /** @@ -1435,9 +1429,6 @@ var XPIStates = { */ scanForChanges(ignoreSideloads = true) { let oldState = this.initialStateData || this.loadExtensionState(); - // We're called twice, do not restore the second time as new data - // may have been inserted since the first call. - let shouldRestoreLocationData = !this.initialStateData; this.initialStateData = oldState; let changed = false; @@ -1446,7 +1437,7 @@ var XPIStates = { for (let loc of XPIStates.locations()) { oldLocations.delete(loc.name); - if (shouldRestoreLocationData && oldState[loc.name]) { + if (oldState[loc.name]) { loc.restore(oldState[loc.name]); } changed = changed || loc.changed; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_aom_startup.js b/toolkit/mozapps/extensions/test/xpcshell/test_aom_startup.js deleted file mode 100644 index 92a4ab1c031a..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/test_aom_startup.js +++ /dev/null @@ -1,187 +0,0 @@ -"use strict"; - -const { JSONFile } = ChromeUtils.import("resource://gre/modules/JSONFile.jsm"); - -const aomStartup = Cc["@mozilla.org/addons/addon-manager-startup;1"].getService( - Ci.amIAddonManagerStartup -); - -const gProfDir = do_get_profile(); - -Services.prefs.setIntPref( - "extensions.enabledScopes", - AddonManager.SCOPE_PROFILE | AddonManager.SCOPE_APPLICATION -); -createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42.0", "42.0"); - -const DUMMY_ID = "@dummy"; -const DUMMY_ADDONS = { - addons: { - "@dummy": { - lastModifiedTime: 1337, - rootURI: "resource:///modules/themes/dummy/", - version: "1", - }, - }, -}; - -const TEST_ADDON_ID = "@test-theme"; -const TEST_THEME = { - lastModifiedTime: 1337, - rootURI: "resource:///modules/themes/test/", - version: "1", -}; - -const TEST_ADDONS = { - addons: { - "@test-theme": TEST_THEME, - }, -}; - -// Utility to write out various addonStartup.json files. -async function writeAOMStartupData(data) { - let jsonFile = new JSONFile({ - path: OS.Path.join(gProfDir.path, "addonStartup.json.lz4"), - compression: "lz4", - }); - jsonFile.data = data; - await jsonFile._save(); - return aomStartup.readStartupData(); -} - -// This tests that any buitin removed from the build will -// get removed from the state data. -add_task(async function test_startup_missing_builtin() { - let startupData = await writeAOMStartupData({ - "app-builtin": DUMMY_ADDONS, - }); - Assert.ok( - !!startupData["app-builtin"].addons[DUMMY_ID], - "non-existant addon is in startup data" - ); - - await AddonTestUtils.promiseStartupManager(); - await AddonTestUtils.promiseShutdownManager(); - - // This data is flushed on shutdown, so we check it after shutdown. - startupData = aomStartup.readStartupData(); - Assert.equal( - startupData["app-builtin"].addons[DUMMY_ID], - undefined, - "non-existant addon is removed from startup data" - ); -}); - -// This test verifies that a builtin installed prior to the -// second scan is not overwritten by old state data during -// the scan. -add_task(async function test_startup_default_theme_moved() { - let startupData = await writeAOMStartupData({ - "app-profile": DUMMY_ADDONS, - "app-builtin": TEST_ADDONS, - }); - Assert.ok( - !!startupData["app-profile"].addons[DUMMY_ID], - "non-existant addon is in startup data" - ); - Assert.ok( - !!startupData["app-builtin"].addons[TEST_ADDON_ID], - "test addon is in startup data" - ); - - let themeDef = { - manifest: { - applications: { gecko: { id: TEST_ADDON_ID } }, - version: "1.1", - theme: {}, - }, - }; - - await setupBuiltinExtension(themeDef, "second-loc"); - await AddonTestUtils.promiseStartupManager("44"); - await AddonManager.maybeInstallBuiltinAddon( - TEST_ADDON_ID, - "1.1", - "resource://second-loc/" - ); - await AddonManagerPrivate.getNewSideloads(); - - let addon = await AddonManager.getAddonByID(TEST_ADDON_ID); - Assert.ok(!addon.foreignInstall, "addon was not marked as a foreign install"); - Assert.equal(addon.version, "1.1", "addon version is correct"); - - await AddonTestUtils.promiseShutdownManager(); - - // This data is flushed on shutdown, so we check it after shutdown. - startupData = aomStartup.readStartupData(); - Assert.equal( - startupData["app-builtin"].addons[TEST_ADDON_ID].version, - "1.1", - "startup data is correct in cache" - ); - Assert.equal( - startupData["app-builtin"].addons[DUMMY_ID], - undefined, - "non-existant addon is removed from startup data" - ); -}); - -// This test verifies that a builtin addon being updated -// is not marked as a foreignInstall. -add_task(async function test_startup_builtin_not_foreign() { - let startupData = await writeAOMStartupData({ - "app-profile": DUMMY_ADDONS, - "app-builtin": { - addons: { - "@test-theme": { - ...TEST_THEME, - rootURI: "resource://second-loc/", - }, - }, - }, - }); - Assert.ok( - !!startupData["app-profile"].addons[DUMMY_ID], - "non-existant addon is in startup data" - ); - Assert.ok( - !!startupData["app-builtin"].addons[TEST_ADDON_ID], - "test addon is in startup data" - ); - - let themeDef = { - manifest: { - applications: { gecko: { id: TEST_ADDON_ID } }, - version: "1.1", - theme: {}, - }, - }; - - await setupBuiltinExtension(themeDef, "second-loc"); - await AddonTestUtils.promiseStartupManager("43"); - await AddonManager.maybeInstallBuiltinAddon( - TEST_ADDON_ID, - "1.1", - "resource://second-loc/" - ); - await AddonManagerPrivate.getNewSideloads(); - - let addon = await AddonManager.getAddonByID(TEST_ADDON_ID); - Assert.ok(!addon.foreignInstall, "addon was not marked as a foreign install"); - Assert.equal(addon.version, "1.1", "addon version is correct"); - - await AddonTestUtils.promiseShutdownManager(); - - // This data is flushed on shutdown, so we check it after shutdown. - startupData = aomStartup.readStartupData(); - Assert.equal( - startupData["app-builtin"].addons[TEST_ADDON_ID].version, - "1.1", - "startup data is correct in cache" - ); - Assert.equal( - startupData["app-builtin"].addons[DUMMY_ID], - undefined, - "non-existant addon is removed from startup data" - ); -}); diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini index b2e40fa20599..7a1b87156533 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini @@ -7,7 +7,6 @@ dupe-manifest = support-files = data/** -[test_aom_startup.js] [test_AbuseReporter.js] [test_AddonRepository.js] [test_AddonRepository_cache.js]