mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Backed out changeset 58acbc167331 (bug 1550090) for causing various bc perma failures CLOSED TREE
This commit is contained in:
parent
b854f853c0
commit
4afbff4959
@ -45,11 +45,20 @@ class Theme {
|
||||
if (startupData && startupData.lwtData) {
|
||||
Object.assign(this, startupData);
|
||||
} else {
|
||||
// TODO(ntim): clean this in bug 1550090
|
||||
this.lwtStyles = {};
|
||||
this.lwtDarkStyles = {};
|
||||
this.lwtDarkStyles = null;
|
||||
if (darkDetails) {
|
||||
this.lwtDarkStyles = {};
|
||||
}
|
||||
|
||||
if (experiment) {
|
||||
if (extension.experimentsAllowed) {
|
||||
this.lwtStyles.experimental = {
|
||||
colors: {},
|
||||
images: {},
|
||||
properties: {},
|
||||
};
|
||||
const {baseURI} = this.extension;
|
||||
if (experiment.stylesheet) {
|
||||
experiment.stylesheet = baseURI.resolve(experiment.stylesheet);
|
||||
@ -82,8 +91,6 @@ class Theme {
|
||||
this.lwtData = {
|
||||
theme: this.lwtStyles,
|
||||
darkTheme: this.lwtDarkStyles,
|
||||
id: this.extension.id,
|
||||
version: this.extension.version,
|
||||
};
|
||||
|
||||
if (this.experiment) {
|
||||
@ -119,14 +126,6 @@ class Theme {
|
||||
* @param {Object} styles Styles object in which to store the colors.
|
||||
*/
|
||||
loadDetails(details, styles) {
|
||||
if (this.experiment) {
|
||||
styles.experimental = {
|
||||
colors: {},
|
||||
images: {},
|
||||
properties: {},
|
||||
};
|
||||
}
|
||||
|
||||
if (details.colors) {
|
||||
this.loadColors(details.colors, styles);
|
||||
}
|
||||
@ -138,6 +137,8 @@ class Theme {
|
||||
if (details.properties) {
|
||||
this.loadProperties(details.properties, styles);
|
||||
}
|
||||
|
||||
this.loadMetadata(this.extension, styles);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -336,10 +337,21 @@ class Theme {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for loading extension metadata required by downstream
|
||||
* consumers.
|
||||
*
|
||||
* @param {Object} extension Extension object.
|
||||
* @param {Object} styles Styles object in which to store the colors.
|
||||
*/
|
||||
loadMetadata(extension, styles) {
|
||||
styles.id = extension.id;
|
||||
styles.version = extension.version;
|
||||
}
|
||||
|
||||
static unload(windowId) {
|
||||
let lwtData = {
|
||||
theme: {},
|
||||
darkTheme: {},
|
||||
theme: null,
|
||||
};
|
||||
|
||||
if (windowId) {
|
||||
|
@ -189,9 +189,12 @@ LightweightThemeConsumer.prototype = {
|
||||
this._lastData = themeData;
|
||||
|
||||
let theme = themeData.theme;
|
||||
if (Object.keys(themeData.darkTheme).length && this.darkMode) {
|
||||
if (themeData.darkTheme && this.darkMode) {
|
||||
theme = themeData.darkTheme;
|
||||
}
|
||||
if (!theme) {
|
||||
theme = { id: DEFAULT_THEME_ID };
|
||||
}
|
||||
|
||||
let active = this._active = Object.keys(theme).length;
|
||||
|
||||
@ -203,6 +206,8 @@ LightweightThemeConsumer.prototype = {
|
||||
root.removeAttribute("lwtheme-image");
|
||||
}
|
||||
|
||||
this._setExperiment(active, themeData.experiment, theme.experimental);
|
||||
|
||||
if (theme.headerImage) {
|
||||
this._doc.mozSetImageElement("lwt-header-image", theme.headerImage);
|
||||
root.style.setProperty("--lwt-header-image", "-moz-element(#lwt-header-image)");
|
||||
@ -213,15 +218,14 @@ LightweightThemeConsumer.prototype = {
|
||||
|
||||
_setImage(root, active, "--lwt-additional-images", theme.additionalBackgrounds);
|
||||
_setProperties(root, active, theme);
|
||||
this._setExperiment(active, themeData.experiment, theme.experimental);
|
||||
|
||||
if (active) {
|
||||
if (theme.id != DEFAULT_THEME_ID || this.darkMode) {
|
||||
root.setAttribute("lwtheme", "true");
|
||||
} else {
|
||||
root.removeAttribute("lwtheme");
|
||||
root.removeAttribute("lwthemetextcolor");
|
||||
}
|
||||
if (themeData.id == DEFAULT_THEME_ID && this.darkMode) {
|
||||
if (theme.id == DEFAULT_THEME_ID && this.darkMode) {
|
||||
root.setAttribute("lwt-default-theme-in-dark-mode", "true");
|
||||
} else {
|
||||
root.removeAttribute("lwt-default-theme-in-dark-mode");
|
||||
|
@ -49,10 +49,10 @@ add_task(async function test_theme_install() {
|
||||
let parsed = JSON.parse(updates[0]);
|
||||
ok(parsed.theme.headerURL.endsWith("/testImage.png"),
|
||||
"Theme update has the expected headerURL");
|
||||
is(parsed.id, "theme@tests.mozilla.org", "Theme update includes the theme ID");
|
||||
is(parsed.version, "1.0", "Theme update includes the theme's version");
|
||||
is(parsed.theme.id, "theme@tests.mozilla.org", "Theme update includes the theme ID");
|
||||
is(parsed.theme.version, "1.0", "Theme update includes the theme's version");
|
||||
|
||||
let addon = await AddonManager.getAddonByID(parsed.id);
|
||||
let addon = await AddonManager.getAddonByID(parsed.theme.id);
|
||||
await addon.uninstall();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user