☠☠ backed out by a9f6c1e46e8c ☠ ☠ | |
author | Mike de Boer <mdeboer@mozilla.com> |
Tue, 14 Mar 2017 15:51:22 +0100 | |
changeset 347533 | 48c4281a7308b1a8f7f52b04acc2c3dfd2cc96f4 |
parent 347532 | e998d849b34ef3d324d0ffecc8dae0cfa0c0922f |
child 347534 | a9f6c1e46e8ce200fdb08b6d30b41d1c541b6181 |
push id | 31499 |
push user | kwierso@gmail.com |
push date | Tue, 14 Mar 2017 23:41:39 +0000 |
treeherder | mozilla-central@cef93bf5a0a1 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mossop |
bugs | 1343821 |
milestone | 55.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -157,17 +157,16 @@ pref("app.update.service.enabled", true) // .. etc .. // pref("extensions.update.enabled", true); pref("extensions.update.url", "https://versioncheck.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=%APP_OS%&appABI=%APP_ABI%&locale=%APP_LOCALE%¤tAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%"); pref("extensions.update.background.url", "https://versioncheck-bg.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=%APP_OS%&appABI=%APP_ABI%&locale=%APP_LOCALE%¤tAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%"); 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. pref("extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.name", "chrome://browser/locale/browser.properties"); pref("extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description", "chrome://browser/locale/browser.properties"); pref("extensions.webextensions.themes.icons.buttons", "back,forward,reload,stop,bookmark_star,bookmark_menu,downloads,home,app_menu,cut,copy,paste,new_window,new_private_window,save_page,print,history,full_screen,find,options,addons,developer,synced_tabs,open_file,sidebars,share_page,subscribe,text_encoding,email_link,forget,pocket");
--- a/browser/base/content/test/general/browser_bug592338.js +++ b/browser/base/content/test/general/browser_bug592338.js @@ -72,64 +72,54 @@ 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); + ok(!aAddon.isActive, "Theme shouldn't have immediately enabled"); 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() { + is(LightweightThemeManager.currentTheme, null, "Should not have installed the test lwtheme"); + ok(!aAddon.isActive, "Test theme should still not be active"); + ok(!aAddon.userDisabled, "Test theme should not be disabled yet"); - 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"); + aAddon.userDisabled = true; - 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); - gBrowser.removeTab(gBrowser.selectedTab); + Services.perms.remove(makeURI("http://example.com"), "install"); - Services.perms.remove(makeURI("http://example.com"), "install"); - - runNextTest(); - }); - BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser); + runNextTest(); }); - }); + BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser); + }, { once: true }); }); } ]; function runNextTest() { AddonManager.getAllInstalls(function(aInstalls) { is(aInstalls.length, 0, "Should be no active installs"); if (TESTS.length == 0) { AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) { aAddon.uninstall(); Services.prefs.setBoolPref("extensions.logging.enabled", false); - Services.prefs.setBoolPref("extensions.dss.enabled", false); finish(); }); return; } info("Running " + TESTS[0].name); TESTS.shift()(); @@ -142,21 +132,16 @@ function test() { Services.prefs.setBoolPref("extensions.logging.enabled", true); AddonManager.getInstallForURL(TESTROOT + "theme.xpi", function(aInstall) { aInstall.addListener({ onInstallEnded() { 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(); }); } }); aInstall.install(); }, "application/x-xpinstall"); }
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm +++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm @@ -12,17 +12,16 @@ const Ci = Components.interfaces; Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/AddonManager.jsm"); /* globals AddonManagerPrivate*/ 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"; const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties"; const STRING_TYPE_NAME = "type.%ID%.name"; const DEFAULT_MAX_USED_THEMES_COUNT = 30; @@ -496,25 +495,18 @@ AddonWrapper.prototype = { if (this.isActive == this.userDisabled) pending |= this.isActive ? AddonManager.PENDING_DISABLE : AddonManager.PENDING_ENABLE; return pending; }, 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; }, get size() { // The size changes depending on whether the theme is in use or not, this is // probably not worth exposing. return null; },
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -98,19 +98,18 @@ Cu.importGlobalProperties(["URL"]); const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile", "initWithPath"); const PREF_DB_SCHEMA = "extensions.databaseSchema"; 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"; const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons"; const PREF_EM_EXTENSION_FORMAT = "extensions."; const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes"; const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI"; const PREF_XPI_ENABLED = "xpinstall.enabled"; @@ -3008,31 +3007,31 @@ this.XPIProvider = { Services.obs.notifyObservers(null, "xpi-provider-shutdown", null); return undefined; }, /** * 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); }, /** * If the application has been upgraded and there are add-ons outside the * application directory then we may need to synchronize compatibility * information but only if the mismatch UI isn't disabled. * * @returns False if no update check is needed, otherwise an array of add-on @@ -4326,24 +4325,24 @@ this.XPIProvider = { } else if (isChangedAddon) { newSkin = theme.internalName; } else if (theme.userDisabled == false && !theme.pendingUninstall) { previousTheme = theme; } } 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); this.currentSkin = newSkin; } this.selectedSkin = newSkin; // Flush the preferences to disk so they don't get out of sync with the @@ -4413,18 +4412,18 @@ this.XPIProvider = { this.updateAddonDisabledState(addon, false); } else if (!this.extensionsActive) { // During startup we may end up trying to enable the default theme when // the database thinks it is already enabled (see f.e. bug 638847). In // this case just force the theme preferences to be correct 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"); } } else { logger.warn("Unable to activate the default theme"); } }, @@ -4565,20 +4564,16 @@ this.XPIProvider = { if (isTheme(aAddon.type)) { if (isWebExtension(aAddon.type)) { // Enabling a WebExtension type theme requires a restart ONLY when the // theme-to-be-disabled requires a restart. 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 // lightweight theme is considered active. return aAddon.internalName != this.currentSkin; } if (this.e10sBlocksEnabling(aAddon)) @@ -4605,21 +4600,16 @@ this.XPIProvider = { if (Services.appinfo.inSafeMode) return false; // Anything that isn't active is already disabled if (!aAddon.active) 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. if (aAddon.internalName != this.defaultSkin) return true; // The default theme requires a restart to disable if we are in the // process of switching to a different theme. Note that this makes the
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -50,17 +50,16 @@ const FILE_JSON_DB = const FILE_OLD_DATABASE = "extensions.rdf"; const FILE_XPI_ADDONS_LIST = "extensions.ini"; // The last version of DB_SCHEMA implemented in SQLITE 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"; const KEY_APP_PROFILE = "app-profile"; const KEY_APP_SYSTEM_ADDONS = "app-system-addons"; const KEY_APP_SYSTEM_DEFAULTS = "app-system-defaults"; const KEY_APP_GLOBAL = "app-global"; @@ -1424,39 +1423,24 @@ this.XPIDatabase = { encodeURIComponent(row.version)); } fullCount += count; // The selected skin may come from an inactive theme (the default theme // 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 dssEnabled = Services.prefs.getBoolPref(let activeTheme = _findAddon( + this.addonDB, + aAddon => (aAddon.type == "theme") && + (aAddon.internalName == XPIProvider.selectedSkin)); + if (activeTheme) { + text += "Extension" + (fullCount++) + "=" + activeTheme.descriptor + "\r\n"; + enabledAddons.push(encodeURIComponent(activeTheme.id) + ":" + + encodeURIComponent(activeTheme.version)); } text += "\r\n[MultiprocessIncompatibleExtensions]\r\n"; count = 0; for (let row of activeAddons) { if (!row.multiprocessCompatible) { text += "Extension" + (count++) + "=" + row.id + "\r\n";
deleted file mode 100644 --- 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(); - }); -}
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js @@ -168,17 +168,17 @@ function* setDisabledStateAndCheck(which "There should be no pending operations left"); if (!isDisabled) gActiveTheme = theme.id; } ensure_test_completed(); } -add_task(function* test_dss_themes() { +add_task(function* test_complete_themes() { // Enable the complete theme. yield* setDisabledStateAndCheck(THEME_IDS[0]); // Disabling the complete theme should revert to the default theme. yield* setDisabledStateAndCheck(THEME_IDS[0], true); // Enable it again. yield* setDisabledStateAndCheck(THEME_IDS[0]);
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini @@ -178,19 +178,16 @@ tags = blocklist [test_corrupt_strictcompat.js] [test_corruptfile.js] [test_dataDirectory.js] [test_default_providers_pref.js] [test_dictionary.js] [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" [test_error.js] [test_experiment.js] [test_filepointer.js] # Bug 676992: test consistently hangs on Android skip-if = os == "android"