diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 6bb232cb29a6..c96cb448b2e1 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -162,7 +162,6 @@ pref("extensions.update.background.url", "https://versioncheck-bg.addons.mozilla pref("extensions.update.interval", 86400); // Check for updates to Extensions and // Themes every day // Non-symmetric (not shared by extensions) extension-specific [update] preferences -pref("extensions.dss.enabled", false); // Dynamic Skin Switching pref("extensions.dss.switchPending", false); // Non-dynamic switch pending after next // restart. diff --git a/browser/base/content/test/general/browser_bug592338.js b/browser/base/content/test/general/browser_bug592338.js index 80177abdc791..6a264d350b62 100644 --- a/browser/base/content/test/general/browser_bug592338.js +++ b/browser/base/content/test/general/browser_bug592338.js @@ -70,48 +70,6 @@ function test_install_lwtheme() { } ); }); -}, - -function test_lwtheme_switch_theme() { - is(LightweightThemeManager.currentTheme, null, "Should be no lightweight theme selected"); - - AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) { - aAddon.userDisabled = false; - ok(aAddon.isActive, "Theme should have immediately enabled"); - Services.prefs.setBoolPref("extensions.dss.enabled", false); - - var pm = Services.perms; - pm.add(makeURI("https://example.com/"), "install", pm.ALLOW_ACTION); - - gBrowser.selectedTab = gBrowser.addTab("https://example.com/browser/browser/base/content/test/general/bug592338.html"); - gBrowser.selectedBrowser.addEventListener("pageshow", function() { - if (gBrowser.contentDocument.location.href == "about:blank") - return; - - gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee); - - executeSoon(function() { - wait_for_notification(function(aPanel) { - is(LightweightThemeManager.currentTheme, null, "Should not have installed the test lwtheme"); - ok(aAddon.isActive, "Test theme should still be active"); - - let notification = aPanel.childNodes[0]; - is(notification.button.label, "Restart Now", "Should have seen the right button"); - - ok(aAddon.userDisabled, "Should be waiting to disable the test theme"); - aAddon.userDisabled = false; - Services.prefs.setBoolPref("extensions.dss.enabled", true); - - gBrowser.removeTab(gBrowser.selectedTab); - - Services.perms.remove(makeURI("http://example.com"), "install"); - - runNextTest(); - }); - BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser); - }); - }); - }); } ]; @@ -124,7 +82,6 @@ function runNextTest() { aAddon.uninstall(); Services.prefs.setBoolPref("extensions.logging.enabled", false); - Services.prefs.setBoolPref("extensions.dss.enabled", false); finish(); }); @@ -147,11 +104,6 @@ function test() { AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) { isnot(aAddon, null, "Should have installed the test theme."); - // In order to switch themes while the test is running we turn on dynamic - // theme switching. This means the test isn't exactly correct but should - // do some good - Services.prefs.setBoolPref("extensions.dss.enabled", true); - runNextTest(); }); } diff --git a/toolkit/mozapps/extensions/LightweightThemeManager.jsm b/toolkit/mozapps/extensions/LightweightThemeManager.jsm index e3e856616c2e..b61754fe0e26 100644 --- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm +++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm @@ -17,7 +17,6 @@ Components.utils.import("resource://gre/modules/Services.jsm"); const ID_SUFFIX = "@personas.mozilla.org"; const PREF_LWTHEME_TO_SELECT = "extensions.lwThemeToSelect"; const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin"; -const PREF_EM_DSS_ENABLED = "extensions.dss.enabled"; const ADDON_TYPE = "theme"; const ADDON_TYPE_WEBEXT = "webextension-theme"; @@ -520,15 +519,8 @@ AddonWrapper.prototype = { get operationsRequiringRestart() { // If a non-default theme is in use then a restart will be required to // enable lightweight themes unless dynamic theme switching is enabled - if (Services.prefs.prefHasUserValue(PREF_GENERAL_SKINS_SELECTEDSKIN)) { - try { - if (Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED)) - return AddonManager.OP_NEEDS_RESTART_NONE; - } catch (e) { - } + if (Services.prefs.prefHasUserValue(PREF_GENERAL_SKINS_SELECTEDSKIN)) return AddonManager.OP_NEEDS_RESTART_ENABLE; - } - return AddonManager.OP_NEEDS_RESTART_NONE; }, diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index aedd6c0293a4..7482eb1cc1a5 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -103,9 +103,8 @@ const PREF_INSTALL_CACHE = "extensions.installCache"; const PREF_XPI_STATE = "extensions.xpiState"; const PREF_BOOTSTRAP_ADDONS = "extensions.bootstrappedAddons"; const PREF_PENDING_OPERATIONS = "extensions.pendingOperations"; -const PREF_EM_DSS_ENABLED = "extensions.dss.enabled"; -const PREF_DSS_SWITCHPENDING = "extensions.dss.switchPending"; -const PREF_DSS_SKIN_TO_SELECT = "extensions.lastSelectedSkin"; +const PREF_SKIN_SWITCHPENDING = "extensions.dss.switchPending"; +const PREF_SKIN_TO_SELECT = "extensions.lastSelectedSkin"; const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin"; const PREF_EM_UPDATE_URL = "extensions.update.url"; const PREF_EM_UPDATE_BACKGROUND_URL = "extensions.update.background.url"; @@ -3013,21 +3012,21 @@ this.XPIProvider = { * Applies any pending theme change to the preferences. */ applyThemeChange() { - if (!Preferences.get(PREF_DSS_SWITCHPENDING, false)) + if (!Preferences.get(PREF_SKIN_SWITCHPENDING, false)) return; // Tell the Chrome Registry which Skin to select try { - this.selectedSkin = Preferences.get(PREF_DSS_SKIN_TO_SELECT); + this.selectedSkin = Preferences.get(PREF_SKIN_TO_SELECT); Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, this.selectedSkin); - Services.prefs.clearUserPref(PREF_DSS_SKIN_TO_SELECT); + Services.prefs.clearUserPref(PREF_SKIN_TO_SELECT); logger.debug("Changed skin to " + this.selectedSkin); this.currentSkin = this.selectedSkin; } catch (e) { logger.error("Error applying theme change", e); } - Services.prefs.clearUserPref(PREF_DSS_SWITCHPENDING); + Services.prefs.clearUserPref(PREF_SKIN_SWITCHPENDING); }, /** @@ -4331,14 +4330,14 @@ this.XPIProvider = { } if (aPendingRestart) { - Services.prefs.setBoolPref(PREF_DSS_SWITCHPENDING, true); - Services.prefs.setCharPref(PREF_DSS_SKIN_TO_SELECT, newSkin); + Services.prefs.setBoolPref(PREF_SKIN_SWITCHPENDING, true); + Services.prefs.setCharPref(PREF_SKIN_TO_SELECT, newSkin); } else if (newSkin == this.currentSkin) { try { - Services.prefs.clearUserPref(PREF_DSS_SWITCHPENDING); + Services.prefs.clearUserPref(PREF_SKIN_SWITCHPENDING); } catch (e) { } try { - Services.prefs.clearUserPref(PREF_DSS_SKIN_TO_SELECT); + Services.prefs.clearUserPref(PREF_SKIN_TO_SELECT); } catch (e) { } } else { Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, newSkin); @@ -4418,8 +4417,8 @@ this.XPIProvider = { Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, addon.internalName); this.currentSkin = this.selectedSkin = addon.internalName; - Preferences.reset(PREF_DSS_SKIN_TO_SELECT); - Preferences.reset(PREF_DSS_SWITCHPENDING); + Preferences.reset(PREF_SKIN_TO_SELECT); + Preferences.reset(PREF_SKIN_SWITCHPENDING); } else { logger.warn("Attempting to activate an already active default theme"); } @@ -4570,10 +4569,6 @@ this.XPIProvider = { let theme = XPIDatabase.getVisibleAddonForInternalName(this.currentSkin); return !theme || this.disableRequiresRestart(theme); } - // If dynamic theme switching is enabled then switching themes does not - // require a restart - if (Preferences.get(PREF_EM_DSS_ENABLED)) - return false; // If the theme is already the theme in use then no restart is necessary. // This covers the case where the default theme is in use but a @@ -4610,11 +4605,6 @@ this.XPIProvider = { return false; if (aAddon.type == "theme") { - // If dynamic theme switching is enabled then switching themes does not - // require a restart - if (Preferences.get(PREF_EM_DSS_ENABLED)) - return false; - // Non-default themes always require a restart to disable since it will // be switching from one theme to another or to the default theme and a // lightweight theme. diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js index dad49e349716..b8d7875981ab 100644 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -55,7 +55,6 @@ const LAST_SQLITE_DB_SCHEMA = 14; const PREF_DB_SCHEMA = "extensions.databaseSchema"; const PREF_PENDING_OPERATIONS = "extensions.pendingOperations"; const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons"; -const PREF_EM_DSS_ENABLED = "extensions.dss.enabled"; const PREF_EM_AUTO_DISABLED_SCOPES = "extensions.autoDisableScopes"; const PREF_E10S_BLOCKED_BY_ADDONS = "extensions.e10sBlockedByAddons"; const PREF_E10S_HAS_NONEXEMPT_ADDON = "extensions.e10s.rollout.hasAddon"; @@ -1429,30 +1428,17 @@ this.XPIDatabase = { // when a lightweight theme is applied for example) text += "\r\n[ThemeDirs]\r\n"; - let dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED, false); - - let themes = []; - if (dssEnabled) { - themes = _filterDB(this.addonDB, aAddon => aAddon.type == "theme"); - } else { - let activeTheme = _findAddon( - this.addonDB, - aAddon => (aAddon.type == "theme") && - (aAddon.internalName == XPIProvider.selectedSkin)); - if (activeTheme) { - themes.push(activeTheme); - } - } - - if (themes.length > 0) { - count = 0; - for (let row of themes) { - text += "Extension" + (count++) + "=" + row.descriptor + "\r\n"; - enabledAddons.push(encodeURIComponent(row.id) + ":" + - encodeURIComponent(row.version)); - } - fullCount += count; + let activeTheme = _findAddon( + this.addonDB, + aAddon => (aAddon.type == "theme") && + (aAddon.internalName == XPIProvider.selectedSkin)); + count = 0; + if (activeTheme) { + text += "Extension" + (count++) + "=" + activeTheme.descriptor + "\r\n"; + enabledAddons.push(encodeURIComponent(activeTheme.id) + ":" + + encodeURIComponent(activeTheme.version)); } + fullCount += count; text += "\r\n[MultiprocessIncompatibleExtensions]\r\n"; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dss.js b/toolkit/mozapps/extensions/test/xpcshell/test_dss.js deleted file mode 100644 index 2b9e9a046897..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/test_dss.js +++ /dev/null @@ -1,817 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -Components.utils.import("resource://gre/modules/NetUtil.jsm"); - -// using a dynamic port in the addon metadata -Components.utils.import("resource://testing-common/httpd.js"); -var gServer = new HttpServer(); -gServer.start(-1); -gPort = gServer.identity.primaryPort; - -// This verifies that themes behave as expected - -const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin"; -const PREF_EXTENSIONS_DSS_ENABLED = "extensions.dss.enabled"; - -Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm"); - -const profileDir = gProfD.clone(); -profileDir.append("extensions"); - -// Observer to ensure a "lightweight-theme-styling-update" notification is sent -// when expected -var gLWThemeChanged = false; -var LightweightThemeObserver = { - observe(aSubject, aTopic, aData) { - if (aTopic != "lightweight-theme-styling-update") - return; - - gLWThemeChanged = true; - } -}; - -AM_Cc["@mozilla.org/observer-service;1"] - .getService(Components.interfaces.nsIObserverService) - .addObserver(LightweightThemeObserver, "lightweight-theme-styling-update", false); - - -function run_test() { - do_test_pending(); - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); - - Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, "theme1/1.0"); - Services.prefs.setBoolPref(PREF_EXTENSIONS_DSS_ENABLED, true); - writeInstallRDFForExtension({ - id: "theme1@tests.mozilla.org", - version: "1.0", - name: "Test 1", - type: 4, - internalName: "theme1/1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "2" - }] - }, profileDir); - - writeInstallRDFForExtension({ - id: "theme2@tests.mozilla.org", - version: "1.0", - name: "Test 1", - internalName: "theme2/1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "2" - }] - }, profileDir); - - // We need a default theme for some of these things to work but we have hidden - // the one in the application directory. - writeInstallRDFForExtension({ - id: "default@tests.mozilla.org", - version: "1.0", - name: "Default", - internalName: "classic/1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "2" - }] - }, profileDir); - - startupManager(); - // Make sure we only register once despite multiple calls - AddonManager.addInstallListener(InstallListener); - AddonManager.addAddonListener(AddonListener); - AddonManager.addInstallListener(InstallListener); - AddonManager.addAddonListener(AddonListener); - AddonManager.addInstallListener(InstallListener); - - AddonManager.getAddonsByIDs(["theme1@tests.mozilla.org", - "theme2@tests.mozilla.org"], function([t1, t2]) { - do_check_neq(t1, null); - do_check_false(t1.userDisabled); - do_check_false(t1.appDisabled); - do_check_true(t1.isActive); - do_check_eq(t1.screenshots, null); - do_check_true(isThemeInAddonsList(profileDir, t1.id)); - do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE)); - do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE)); - - do_check_neq(t2, null); - do_check_true(t2.userDisabled); - do_check_false(t2.appDisabled); - do_check_false(t2.isActive); - do_check_eq(t2.screenshots, null); - do_check_true(isThemeInAddonsList(profileDir, t2.id)); - do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE)); - do_check_true(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE)); - - do_execute_soon(run_test_1); - }); -} - -function end_test() { - do_execute_soon(do_test_finished); -} - -// Checks enabling one theme disables the others -function run_test_1() { - prepare_test({ - "theme1@tests.mozilla.org": [ - ["onDisabling", false], - "onDisabled" - ], - "theme2@tests.mozilla.org": [ - ["onEnabling", false], - "onEnabled" - ] - }); - AddonManager.getAddonsByIDs(["theme1@tests.mozilla.org", - "theme2@tests.mozilla.org"], function([t1, t2]) { - t2.userDisabled = false; - - ensure_test_completed(); - do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE)); - do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE)); - - do_check_true(t1.userDisabled); - do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE)); - do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE)); - - do_execute_soon(check_test_1); - }); -} - -function check_test_1() { - restartManager(); - do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "theme2/1.0"); - - AddonManager.getAddonsByIDs(["theme1@tests.mozilla.org", - "theme2@tests.mozilla.org"], function([t1, t2]) { - do_check_neq(t1, null); - do_check_true(t1.userDisabled); - do_check_false(t1.appDisabled); - do_check_false(t1.isActive); - do_check_true(isThemeInAddonsList(profileDir, t1.id)); - do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE)); - do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE)); - - do_check_neq(t2, null); - do_check_false(t2.userDisabled); - do_check_false(t2.appDisabled); - do_check_true(t2.isActive); - do_check_true(isThemeInAddonsList(profileDir, t2.id)); - do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE)); - do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE)); - do_check_false(gLWThemeChanged); - - do_execute_soon(run_test_2); - }); -} - -// Removing the active theme should fall back to the default (not ideal in this -// case since we don't have the default theme installed) -function run_test_2() { - var dest = profileDir.clone(); - dest.append(do_get_expected_addon_name("theme2@tests.mozilla.org")); - dest.remove(true); - - restartManager(); - do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); - - AddonManager.getAddonsByIDs(["theme1@tests.mozilla.org", - "theme2@tests.mozilla.org"], function([t1, t2]) { - do_check_neq(t1, null); - do_check_true(t1.userDisabled); - do_check_false(t1.appDisabled); - do_check_false(t1.isActive); - do_check_true(isThemeInAddonsList(profileDir, t1.id)); - do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE)); - do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE)); - - do_check_eq(t2, null); - do_check_false(isThemeInAddonsList(profileDir, "theme2@tests.mozilla.org")); - do_check_false(gLWThemeChanged); - - do_execute_soon(run_test_3); - }); -} - -// Installing a lightweight theme should happen instantly and disable the default theme -function run_test_3() { - writeInstallRDFForExtension({ - id: "theme2@tests.mozilla.org", - version: "1.0", - name: "Test 1", - internalName: "theme2/1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "2" - }] - }, profileDir); - restartManager(); - - prepare_test({ - "1@personas.mozilla.org": [ - ["onInstalling", false], - "onInstalled", - ["onEnabling", false], - "onEnabled" - ], - "default@tests.mozilla.org": [ - ["onDisabling", false], - "onDisabled", - ] - }, [ - "onExternalInstall" - ]); - - LightweightThemeManager.currentTheme = { - id: "1", - version: "1", - name: "Test LW Theme", - description: "A test theme", - author: "Mozilla", - homepageURL: "http://localhost:" + gPort + "/data/index.html", - headerURL: "http://localhost:" + gPort + "/data/header.png", - footerURL: "http://localhost:" + gPort + "/data/footer.png", - previewURL: "http://localhost:" + gPort + "/data/preview.png", - iconURL: "http://localhost:" + gPort + "/data/icon.png" - }; - - ensure_test_completed(); - - AddonManager.getAddonByID("1@personas.mozilla.org", function(p1) { - do_check_neq(null, p1); - do_check_eq(p1.name, "Test LW Theme"); - do_check_eq(p1.version, "1"); - do_check_eq(p1.type, "theme"); - do_check_eq(p1.description, "A test theme"); - do_check_eq(p1.creator, "Mozilla"); - do_check_eq(p1.homepageURL, "http://localhost:" + gPort + "/data/index.html"); - do_check_eq(p1.iconURL, "http://localhost:" + gPort + "/data/icon.png"); - do_check_eq(p1.screenshots.length, 1); - do_check_eq(p1.screenshots[0], "http://localhost:" + gPort + "/data/preview.png"); - do_check_false(p1.appDisabled); - do_check_false(p1.userDisabled); - do_check_true(p1.isCompatible); - do_check_true(p1.providesUpdatesSecurely); - do_check_eq(p1.blocklistState, 0); - do_check_true(p1.isActive); - do_check_eq(p1.pendingOperations, 0); - do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_DISABLE); - do_check_eq(p1.scope, AddonManager.SCOPE_PROFILE); - do_check_true("isCompatibleWith" in p1); - do_check_true("findUpdates" in p1); - - AddonManager.getAddonsByTypes(["theme"], function(addons) { - let seen = false; - addons.forEach(function(a) { - if (a.id == "1@personas.mozilla.org") { - seen = true; - } else { - dump("Checking theme " + a.id + "\n"); - do_check_false(a.isActive); - do_check_true(a.userDisabled); - } - }); - do_check_true(seen); - - do_check_true(gLWThemeChanged); - gLWThemeChanged = false; - - do_execute_soon(run_test_4); - }); - }); -} - -// Installing a second lightweight theme should disable the first with no restart -function run_test_4() { - prepare_test({ - "1@personas.mozilla.org": [ - ["onDisabling", false], - "onDisabled", - ], - "2@personas.mozilla.org": [ - ["onInstalling", false], - "onInstalled", - ["onEnabling", false], - "onEnabled" - ] - }, [ - "onExternalInstall" - ]); - - LightweightThemeManager.currentTheme = { - id: "2", - version: "1", - name: "Test LW Theme", - description: "A second test theme", - author: "Mozilla", - homepageURL: "http://localhost:" + gPort + "/data/index.html", - headerURL: "http://localhost:" + gPort + "/data/header.png", - footerURL: "http://localhost:" + gPort + "/data/footer.png", - previewURL: "http://localhost:" + gPort + "/data/preview.png", - iconURL: "http://localhost:" + gPort + "/data/icon.png" - }; - - ensure_test_completed(); - - AddonManager.getAddonsByIDs(["1@personas.mozilla.org", - "2@personas.mozilla.org"], function([p1, p2]) { - do_check_neq(null, p2); - do_check_false(p2.appDisabled); - do_check_false(p2.userDisabled); - do_check_true(p2.isActive); - do_check_eq(p2.pendingOperations, 0); - do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_DISABLE); - - do_check_neq(null, p1); - do_check_false(p1.appDisabled); - do_check_true(p1.userDisabled); - do_check_false(p1.isActive); - do_check_eq(p1.pendingOperations, 0); - do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_ENABLE); - - AddonManager.getAddonsByTypes(["theme"], function(addons) { - let seen = false; - addons.forEach(function(a) { - if (a.id == "2@personas.mozilla.org") { - seen = true; - } else { - dump("Checking theme " + a.id + "\n"); - do_check_false(a.isActive); - do_check_true(a.userDisabled); - } - }); - do_check_true(seen); - - do_check_true(gLWThemeChanged); - gLWThemeChanged = false; - - do_execute_soon(run_test_5); - }); - }); -} - -// Switching to a custom theme should disable the lightweight theme and require -// a restart. Cancelling that should also be possible. -function run_test_5() { - prepare_test({ - "2@personas.mozilla.org": [ - ["onDisabling", false], - "onDisabled" - ], - "theme2@tests.mozilla.org": [ - ["onEnabling", false], - "onEnabled" - ] - }); - - AddonManager.getAddonsByIDs(["2@personas.mozilla.org", - "theme2@tests.mozilla.org"], function([p2, t2]) { - t2.userDisabled = false; - - ensure_test_completed(); - - prepare_test({ - "2@personas.mozilla.org": [ - "onEnabling" - ], - "theme2@tests.mozilla.org": [ - "onDisabling" - ] - }); - - p2.userDisabled = false; - - ensure_test_completed(); - - prepare_test({ - "2@personas.mozilla.org": [ - "onOperationCancelled" - ], - "theme2@tests.mozilla.org": [ - "onOperationCancelled" - ] - }); - - t2.userDisabled = false; - - ensure_test_completed(); - - do_check_true(t2.isActive); - do_check_false(t2.userDisabled); - do_check_false(hasFlag(AddonManager.PENDING_ENABLE, t2.pendingOperations)); - do_check_false(p2.isActive); - do_check_true(p2.userDisabled); - do_check_false(hasFlag(AddonManager.PENDING_DISABLE, p2.pendingOperations)); - do_check_true(hasFlag(AddonManager.PERM_CAN_ENABLE, p2.permissions)); - do_check_true(gLWThemeChanged); - - do_execute_soon(check_test_5); - }); -} - -function check_test_5() { - restartManager(); - - AddonManager.getAddonsByIDs(["2@personas.mozilla.org", - "theme2@tests.mozilla.org"], function([p2, t2]) { - do_check_true(t2.isActive); - do_check_false(t2.userDisabled); - do_check_false(hasFlag(AddonManager.PENDING_ENABLE, t2.pendingOperations)); - do_check_false(p2.isActive); - do_check_true(p2.userDisabled); - do_check_false(hasFlag(AddonManager.PENDING_DISABLE, p2.pendingOperations)); - - do_check_true(gLWThemeChanged); - gLWThemeChanged = false; - - do_execute_soon(run_test_6); - }); -} - -// Switching from a custom theme to a lightweight theme should require a restart -function run_test_6() { - prepare_test({ - "2@personas.mozilla.org": [ - "onEnabling", - ], - "theme2@tests.mozilla.org": [ - "onDisabling" - ] - }); - - AddonManager.getAddonsByIDs(["2@personas.mozilla.org", - "theme2@tests.mozilla.org"], function([p2, t2]) { - p2.userDisabled = false; - - ensure_test_completed(); - - prepare_test({ - "2@personas.mozilla.org": [ - "onOperationCancelled", - ], - "theme2@tests.mozilla.org": [ - "onOperationCancelled" - ] - }); - - t2.userDisabled = false; - - ensure_test_completed(); - - prepare_test({ - "2@personas.mozilla.org": [ - "onEnabling", - ], - "theme2@tests.mozilla.org": [ - "onDisabling" - ] - }); - - p2.userDisabled = false; - - ensure_test_completed(); - - do_check_false(p2.isActive); - do_check_false(p2.userDisabled); - do_check_true(hasFlag(AddonManager.PENDING_ENABLE, p2.pendingOperations)); - do_check_true(t2.isActive); - do_check_true(t2.userDisabled); - do_check_true(hasFlag(AddonManager.PENDING_DISABLE, t2.pendingOperations)); - do_check_false(gLWThemeChanged); - - do_execute_soon(check_test_6); - }); -} - -function check_test_6() { - restartManager(); - - AddonManager.getAddonsByIDs(["2@personas.mozilla.org", - "theme2@tests.mozilla.org"], function([p2, t2]) { - do_check_true(p2.isActive); - do_check_false(p2.userDisabled); - do_check_false(hasFlag(AddonManager.PENDING_ENABLE, p2.pendingOperations)); - do_check_false(t2.isActive); - do_check_true(t2.userDisabled); - do_check_false(hasFlag(AddonManager.PENDING_DISABLE, t2.pendingOperations)); - - do_check_true(gLWThemeChanged); - gLWThemeChanged = false; - - do_execute_soon(run_test_7); - }); -} - -// Uninstalling a lightweight theme should not require a restart -function run_test_7() { - prepare_test({ - "1@personas.mozilla.org": [ - ["onUninstalling", false], - "onUninstalled" - ] - }); - - AddonManager.getAddonByID("1@personas.mozilla.org", function(p1) { - p1.uninstall(); - - ensure_test_completed(); - do_check_eq(LightweightThemeManager.usedThemes.length, 1); - do_check_false(gLWThemeChanged); - - do_execute_soon(run_test_8); - }); -} - -// Uninstalling a lightweight theme in use should not require a restart and it -// should reactivate the default theme -// Also, uninstalling a lightweight theme in use should send a -// "lightweight-theme-styling-update" notification through the observer service -function run_test_8() { - prepare_test({ - "2@personas.mozilla.org": [ - ["onUninstalling", false], - "onUninstalled" - ], - "default@tests.mozilla.org": [ - ["onEnabling", false], - "onEnabled" - ] - }); - - AddonManager.getAddonByID("2@personas.mozilla.org", function(p2) { - p2.uninstall(); - - ensure_test_completed(); - do_check_eq(LightweightThemeManager.usedThemes.length, 0); - - do_check_true(gLWThemeChanged); - gLWThemeChanged = false; - - do_execute_soon(run_test_9); - }); -} - -// Uninstalling a theme not in use should not require a restart -function run_test_9() { - AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) { - prepare_test({ - "theme1@tests.mozilla.org": [ - ["onUninstalling", false], - "onUninstalled" - ] - }); - - t1.uninstall(); - - ensure_test_completed(); - - AddonManager.getAddonByID("theme1@tests.mozilla.org", function(newt1) { - do_check_eq(newt1, null); - do_check_false(gLWThemeChanged); - - do_execute_soon(run_test_10); - }); - }); -} - -// Uninstalling a custom theme in use should require a restart -function run_test_10() { - AddonManager.getAddonByID("theme2@tests.mozilla.org", callback_soon(function(oldt2) { - prepare_test({ - "theme2@tests.mozilla.org": [ - ["onEnabling", false], - "onEnabled" - ], - "default@tests.mozilla.org": [ - ["onDisabling", false], - "onDisabled" - ] - }); - - oldt2.userDisabled = false; - - ensure_test_completed(); - - restartManager(); - - AddonManager.getAddonsByIDs(["default@tests.mozilla.org", - "theme2@tests.mozilla.org"], - callback_soon(function([d, t2]) { - do_check_true(t2.isActive); - do_check_false(t2.userDisabled); - do_check_false(t2.appDisabled); - do_check_false(d.isActive); - do_check_true(d.userDisabled); - do_check_false(d.appDisabled); - - prepare_test({ - "theme2@tests.mozilla.org": [ - ["onUninstalling", false], - "onUninstalled" - ], - "default@tests.mozilla.org": [ - ["onEnabling", false], - "onEnabled" - ] - }); - - t2.uninstall(); - - ensure_test_completed(); - do_check_false(gLWThemeChanged); - - restartManager(); - - do_execute_soon(run_test_11); - })); - })); -} - -// Installing a custom theme not in use should not require a restart -function run_test_11() { - prepare_test({ }, [ - "onNewInstall" - ]); - - AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) { - ensure_test_completed(); - - do_check_neq(install, null); - do_check_eq(install.type, "theme"); - do_check_eq(install.version, "1.0"); - do_check_eq(install.name, "Test Theme 1"); - do_check_eq(install.state, AddonManager.STATE_DOWNLOADED); - - prepare_test({ - "theme1@tests.mozilla.org": [ - ["onInstalling", false], - "onInstalled" - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], callback_soon(check_test_11)); - install.install(); - }); -} - -function check_test_11() { - restartManager(); - AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) { - do_check_neq(t1, null); - var previewSpec = do_get_addon_root_uri(profileDir, "theme1@tests.mozilla.org") + "preview.png"; - do_check_eq(t1.screenshots.length, 1); - do_check_eq(t1.screenshots[0], previewSpec); - do_check_false(gLWThemeChanged); - - do_execute_soon(run_test_12); - }); -} - -// Updating a custom theme not in use should not require a restart -function run_test_12() { - prepare_test({ }, [ - "onNewInstall" - ]); - - AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) { - ensure_test_completed(); - - do_check_neq(install, null); - do_check_eq(install.type, "theme"); - do_check_eq(install.version, "1.0"); - do_check_eq(install.name, "Test Theme 1"); - do_check_eq(install.state, AddonManager.STATE_DOWNLOADED); - - prepare_test({ - "theme1@tests.mozilla.org": [ - ["onInstalling", false], - "onInstalled" - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], check_test_12); - install.install(); - }); -} - -function check_test_12() { - AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) { - do_check_neq(t1, null); - do_check_false(gLWThemeChanged); - - do_execute_soon(run_test_13); - }); -} - -// Updating a custom theme in use should require a restart -function run_test_13() { - AddonManager.getAddonByID("theme1@tests.mozilla.org", callback_soon(function(t1) { - prepare_test({ - "theme1@tests.mozilla.org": [ - ["onEnabling", false], - "onEnabled" - ], - "default@tests.mozilla.org": [ - ["onDisabling", false], - "onDisabled" - ] - }); - - t1.userDisabled = false; - ensure_test_completed(); - restartManager(); - - prepare_test({ }, [ - "onNewInstall" - ]); - - AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) { - ensure_test_completed(); - - do_check_neq(install, null); - do_check_eq(install.type, "theme"); - do_check_eq(install.version, "1.0"); - do_check_eq(install.name, "Test Theme 1"); - do_check_eq(install.state, AddonManager.STATE_DOWNLOADED); - - prepare_test({ - "theme1@tests.mozilla.org": [ - "onInstalling", - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], callback_soon(check_test_13)); - install.install(); - }); - })); -} - -function check_test_13() { - restartManager(); - - AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) { - do_check_neq(t1, null); - do_check_true(t1.isActive); - do_check_false(gLWThemeChanged); - t1.uninstall(); - - do_execute_soon(run_test_14); - }); -} - -// Switching from a lightweight theme to the default theme should not require -// a restart -function run_test_14() { - restartManager(); - LightweightThemeManager.currentTheme = { - id: "1", - version: "1", - name: "Test LW Theme", - description: "A test theme", - author: "Mozilla", - homepageURL: "http://localhost:" + gPort + "/data/index.html", - headerURL: "http://localhost:" + gPort + "/data/header.png", - footerURL: "http://localhost:" + gPort + "/data/footer.png", - previewURL: "http://localhost:" + gPort + "/data/preview.png", - iconURL: "http://localhost:" + gPort + "/data/icon.png" - }; - - AddonManager.getAddonByID("default@tests.mozilla.org", function(d) { - do_check_true(d.userDisabled); - do_check_false(d.isActive); - - prepare_test({ - "1@personas.mozilla.org": [ - ["onDisabling", false], - "onDisabled" - ], - "default@tests.mozilla.org": [ - ["onEnabling", false], - "onEnabled" - ] - }); - - d.userDisabled = false; - ensure_test_completed(); - - do_check_false(d.userDisabled); - do_check_true(d.isActive); - - do_check_true(gLWThemeChanged); - gLWThemeChanged = false; - - end_test(); - }); -} diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js index 8f12ecdb22cd..4190519a7ff7 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js @@ -173,7 +173,7 @@ function* setDisabledStateAndCheck(which, disabled = false) { ensure_test_completed(); } -add_task(function* test_dss_themes() { +add_task(function* test_complete_themes() { // Enable the complete theme. yield* setDisabledStateAndCheck(THEME_IDS[0]); diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini index 2dc39d41b94b..b40035b60138 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini @@ -183,9 +183,6 @@ tags = blocklist [test_langpack.js] [test_disable.js] [test_distribution.js] -[test_dss.js] -# Bug 676992: test consistently fails on Android -fail-if = os == "android" [test_duplicateplugins.js] # Bug 676992: test consistently hangs on Android skip-if = os == "android"