Backed out 4 changesets (bug 1540387) for xpcshell failures at toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js on a CLOSED TREE

Backed out changeset 0f940b496e58 (bug 1540387)
Backed out changeset f8e11c0bb2a4 (bug 1540387)
Backed out changeset e3ca91d64e82 (bug 1540387)
Backed out changeset ee2913c76f4a (bug 1540387)
This commit is contained in:
Coroiu Cristina 2019-04-11 02:57:19 +03:00
parent 619127a72d
commit 4a56b6ca02
16 changed files with 130 additions and 37 deletions

View File

@ -0,0 +1,70 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
ChromeUtils.defineModuleGetter(
this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
/**
* Enables compacttheme.css when needed.
*/
var CompactTheme = {
get styleSheet() {
delete this.styleSheet;
for (let styleSheet of document.styleSheets) {
if (styleSheet.href == "chrome://browser/skin/compacttheme.css") {
this.styleSheet = styleSheet;
break;
}
}
return this.styleSheet;
},
get isStyleSheetEnabled() {
return this.styleSheet && !this.styleSheet.disabled;
},
isCompactTheme(theme) {
return theme && (theme.id == "firefox-compact-dark@mozilla.org" ||
theme.id == "firefox-compact-light@mozilla.org");
},
get isThemeCurrentlyApplied() {
return this.isCompactTheme(LightweightThemeManager.currentThemeWithFallback);
},
init() {
Services.obs.addObserver(this, "lightweight-theme-styling-update");
if (this.isThemeCurrentlyApplied) {
this._toggleStyleSheet(true);
}
},
observe(subject, topic, data) {
if (topic == "lightweight-theme-styling-update") {
if (this.isCompactTheme(subject.wrappedJSObject.theme)) {
// We are using the theme ID on this object instead of always referencing
// LightweightThemeManager.currentTheme in case this is a preview
this._toggleStyleSheet(true);
} else {
this._toggleStyleSheet(false);
}
}
},
_toggleStyleSheet(enabled) {
let wasEnabled = this.isStyleSheetEnabled;
if (enabled) {
this.styleSheet.disabled = false;
} else if (!enabled && wasEnabled) {
this.styleSheet.disabled = true;
}
},
uninit() {
Services.obs.removeObserver(this, "lightweight-theme-styling-update");
this.styleSheet = null;
},
};

View File

@ -1376,6 +1376,7 @@ var gBrowserInit = {
TabsInTitlebar.init();
new LightweightThemeConsumer(document);
CompactTheme.init();
if (AppConstants.platform == "win") {
if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
@ -2003,6 +2004,8 @@ var gBrowserInit = {
ToolbarIconColor.uninit();
CompactTheme.uninit();
// In certain scenarios it's possible for unload to be fired before onload,
// (e.g. if the window is being closed after browser.js loads but before the
// load completes). In that case, there's nothing to do here.

View File

@ -29,6 +29,7 @@
<?xml-stylesheet href="chrome://browser/skin/searchbar.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/places/tree-icons.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/places/editBookmark.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/compacttheme.css" type="text/css" alternate="yes" title="Light/Dark"?>
# All DTD information is stored in a separate file so that it can be shared by
# hiddenWindow.xul.
@ -83,6 +84,7 @@
<script type="application/javascript">
Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", this);
Services.scriptloader.loadSubScript("chrome://browser/content/browser-captivePortal.js", this);
Services.scriptloader.loadSubScript("chrome://browser/content/browser-compacttheme.js", this);
Services.scriptloader.loadSubScript("chrome://browser/content/browser-contentblocking.js", this);
#ifdef MOZ_DATA_REPORTING
Services.scriptloader.loadSubScript("chrome://browser/content/browser-data-submission-info-bar.js", this);

View File

@ -121,6 +121,9 @@ with Files("browser-addons.js"):
with Files("*menu*"):
BUG_COMPONENT = ("Firefox", "Menus")
with Files("browser-compacttheme.js"):
BUG_COMPONENT = ("Firefox", "Themes")
with Files("browser-customization.js"):
BUG_COMPONENT = ("Firefox", "Toolbars and Customization")

View File

@ -246,6 +246,8 @@ subsuite = clipboard
[browser_clipboard_pastefile.js]
skip-if = true # Disabled due to the clipboard not supporting real file types yet (bug 1288773)
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_compacttheme.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_contentAreaClick.js]
skip-if = e10s # Clicks in content don't go through contentAreaClick with e10s.
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.

View File

@ -0,0 +1,47 @@
/*
* Testing changes for compact themes.
* A special stylesheet should be added to the browser.xul document
* when the firefox-compact-light and firefox-compact-dark lightweight
* themes are applied.
*/
const DEFAULT_THEME = "default-theme@mozilla.org";
const COMPACT_LIGHT_ID = "firefox-compact-light@mozilla.org";
const COMPACT_DARK_ID = "firefox-compact-dark@mozilla.org";
const {AddonManager} = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
async function selectTheme(id) {
let theme = await AddonManager.getAddonByID(id || DEFAULT_THEME);
await theme.enable();
}
registerCleanupFunction(() => {
// Set preferences back to their original values
return selectTheme(null);
});
function tick() {
return new Promise(SimpleTest.executeSoon);
}
add_task(async function startTests() {
info("Setting the current theme to null");
await selectTheme(null);
await tick();
ok(!CompactTheme.isStyleSheetEnabled, "There is no compact style sheet when no lw theme is applied.");
info("Applying the dark compact theme.");
await selectTheme(COMPACT_DARK_ID);
await tick();
ok(CompactTheme.isStyleSheetEnabled, "The compact stylesheet has been added when the compact lightweight theme is applied");
info("Applying the light compact theme.");
await selectTheme(COMPACT_LIGHT_ID);
await tick();
ok(CompactTheme.isStyleSheetEnabled, "The compact stylesheet has been added when the compact lightweight theme is applied");
info("Unapplying all themes.");
await selectTheme(null);
await tick();
ok(!CompactTheme.isStyleSheetEnabled, "There is no compact style sheet when no lw theme is applied.");
});

View File

@ -38,6 +38,7 @@ browser.jar:
content/browser/browser-ctrlTab.js (content/browser-ctrlTab.js)
content/browser/browser-customization.js (content/browser-customization.js)
content/browser/browser-data-submission-info-bar.js (content/browser-data-submission-info-bar.js)
content/browser/browser-compacttheme.js (content/browser-compacttheme.js)
content/browser/browser-contentblocking.js (content/browser-contentblocking.js)
#ifndef MOZILLA_OFFICIAL
content/browser/browser-development-helpers.js (content/browser-development-helpers.js)

View File

@ -1,2 +0,0 @@
/* Dark theme */
@import url("chrome://browser/skin/compacttheme.css");

View File

@ -35,9 +35,5 @@
"sidebar_text": "rgb(249, 249, 250)",
"sidebar_border": "rgba(255, 255, 255, 0.1)"
}
},
"theme_experiment": {
"stylesheet": "experiment.css"
}
}

View File

@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES.themes['dark'] += [
'experiment.css',
'icon.svg',
'manifest.json',
]

View File

@ -1,2 +0,0 @@
/* Light theme */
@import url("chrome://browser/skin/compacttheme.css");

View File

@ -28,9 +28,5 @@
"toolbar_field": "#fff",
"toolbar_field_border": "#ccc"
}
},
"theme_experiment": {
"stylesheet": "experiment.css"
}
}

View File

@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES.themes['light'] += [
'experiment.css',
'icon.svg',
'manifest.json',
]

View File

@ -6,8 +6,6 @@
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(this, "AddonManagerPrivate",
"resource://gre/modules/AddonManager.jsm");
ChromeUtils.defineModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
@ -55,10 +53,8 @@ class Theme {
this.lwtDarkStyles = null;
if (experiment) {
const canRunExperiment = AddonManagerPrivate.addonIsBuiltin(extension.id) || (
AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS &&
Services.prefs.getBoolPref("extensions.legacy.enabled")
);
const canRunExperiment = AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS &&
Services.prefs.getBoolPref("extensions.legacy.enabled");
if (canRunExperiment) {
this.lwtStyles.experimental = {
colors: {},

View File

@ -2806,11 +2806,6 @@ var AddonManagerPrivate = {
.addonIsActive(addonId);
},
addonIsBuiltin(addonId) {
return AddonManagerInternal._getProviderByName("XPIProvider")
.addonIsBuiltin(addonId);
},
/**
* Gets an array of add-ons which were side-loaded prior to the last
* startup, and are currently disabled.

View File

@ -2036,18 +2036,6 @@ var XPIProvider = {
return state && state.enabled;
},
/**
* Returns true if the add-on with the given ID is built-in.
*
* @param {string} addonId
* The ID of the add-on to check.
* @returns {boolean}
*/
addonIsBuiltin(addonId) {
let state = XPIStates.findAddon(addonId);
return state && state.location.isBuiltin;
},
/**
* Returns an array of the add-on values in `enabledAddons`,
* sorted so that all of an add-on's dependencies appear in the array