зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1344926 - add a regression test to make sure themes are persisted across windows using the Theming API. r=mossop
MozReview-Commit-ID: BU7knUPaz1w --HG-- extra : rebase_source : dcbf16a49544c0feeeb11fb78ef10b3cab36a849
This commit is contained in:
Родитель
66407b6bab
Коммит
1d646c760e
|
@ -8,6 +8,7 @@ module.exports = { // eslint-disable-line no-undef
|
|||
},
|
||||
|
||||
"globals": {
|
||||
"BrowserTestUtils": true,
|
||||
"ExtensionTestUtils": false,
|
||||
"XPCOMUtils": true,
|
||||
},
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
head.js
|
||||
|
||||
[browser_ext_themes_chromeparity.js]
|
||||
[browser_ext_themes_dynamic_updates.js]
|
||||
[browser_ext_themes_lwtsupport.js]
|
||||
[browser_ext_themes_persistence.js]
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
const BACKGROUND = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
||||
const ACCENT_COLOR = "#a14040";
|
||||
const TEXT_COLOR = "#fac96e";
|
||||
|
||||
function hexToRGB(hex) {
|
||||
hex = parseInt((hex.indexOf("#") > -1 ? hex.substring(1) : hex), 16);
|
||||
return [hex >> 16, (hex & 0x00FF00) >> 8, (hex & 0x0000FF)];
|
||||
}
|
||||
|
||||
add_task(function* setup() {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.webextensions.themes.enabled", true]],
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
|
||||
// This test checks whether applied WebExtension themes are persisted and applied
|
||||
// on newly opened windows.
|
||||
|
||||
add_task(function* setup() {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.webextensions.themes.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* test_multiple_windows() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"theme": {
|
||||
"images": {
|
||||
"headerURL": BACKGROUND,
|
||||
},
|
||||
"colors": {
|
||||
"accentcolor": ACCENT_COLOR,
|
||||
"textcolor": TEXT_COLOR,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
|
||||
let docEl = window.document.documentElement;
|
||||
let style = window.getComputedStyle(docEl);
|
||||
|
||||
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||
Assert.equal(docEl.getAttribute("lwthemetextcolor"), "bright",
|
||||
"LWT text color attribute should be set");
|
||||
Assert.equal(style.backgroundImage, 'url("' + BACKGROUND.replace(/"/g, '\\"') + '")',
|
||||
"Expected background image");
|
||||
|
||||
// Now we'll open a new window to see if the theme is also applied there.
|
||||
let window2 = yield BrowserTestUtils.openNewBrowserWindow();
|
||||
docEl = window2.document.documentElement;
|
||||
style = window2.getComputedStyle(docEl);
|
||||
|
||||
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||
Assert.equal(docEl.getAttribute("lwthemetextcolor"), "bright",
|
||||
"LWT text color attribute should be set");
|
||||
Assert.equal(style.backgroundImage, 'url("' + BACKGROUND.replace(/"/g, '\\"') + '")',
|
||||
"Expected background image");
|
||||
|
||||
yield BrowserTestUtils.closeWindow(window2);
|
||||
yield extension.unload();
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
/* exported BACKGROUND, ACCENT_COLOR, TEXT_COLOR, hexToRGB */
|
||||
|
||||
"use strict";
|
||||
|
||||
const BACKGROUND = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
||||
const ACCENT_COLOR = "#a14040";
|
||||
const TEXT_COLOR = "#fac96e";
|
||||
|
||||
function hexToRGB(hex) {
|
||||
hex = parseInt((hex.indexOf("#") > -1 ? hex.substring(1) : hex), 16);
|
||||
return [hex >> 16, (hex & 0x00FF00) >> 8, (hex & 0x0000FF)];
|
||||
}
|
Загрузка…
Ссылка в новой задаче