fune/toolkit/components/extensions/test/browser/browser_ext_themes_toolbars.js
Luca Greco 4030a1c685 Bug 1472740 - Remove support for deprecated lwt aliases from WebExtensions theme API. r=ntim,robwu
Removing the lwt aliases from the theme API schema is not going to be enough, because the images and colors properties are very permissive on the unknown properties (likely to prevent a property supported on chrome but not on firefox to prevent the theme from being installed), and so removing the lwt aliases from the schema would not raise any error (the theme API implementation would just be silently ignoring the deprecated lwt aliases).

For the above reason the following patch use the following approach:

- kept the deprecated lwt aliases in the schema, but changes the deprecation warning message to mention that the property is now completely ignored by Firefox, and which property should be used instead

- removed the deprecation warning from the toolbar_text theme colors property, as we decided that we are not going to deprecate it anymore

- changed the theme API implementation to ignore the deprecated lwt alias property

- repurposed browser_ext_themes_lwtsupport.js test file to verify that the lwt aliases are ignored as expected

A separate addons-linter pull request is going to be created, to ensure that the addons-linter will raise linting errors (instead of linting warning) when these deprecated lwt aliases are being used in a theme (to prevent that newly submitted theme versions including the aliases will go unnoticed).

Depends on D37890

Differential Revision: https://phabricator.services.mozilla.com/D37891

--HG--
extra : moz-landing-system : lando
2019-07-19 11:30:48 +00:00

105 lines
3 KiB
JavaScript

"use strict";
// This test checks whether applied WebExtension themes that attempt to change
// the background color of toolbars are applied properly.
add_task(async function test_support_toolbar_property() {
const TOOLBAR_COLOR = "#ff00ff";
const TOOLBAR_TEXT_COLOR = "#9400ff";
let extension = ExtensionTestUtils.loadExtension({
manifest: {
theme: {
colors: {
frame: ACCENT_COLOR,
tab_background_text: TEXT_COLOR,
toolbar: TOOLBAR_COLOR,
toolbar_text: TOOLBAR_TEXT_COLOR,
},
},
},
});
let toolbox = document.querySelector("#navigator-toolbox");
let toolbars = [
...toolbox.querySelectorAll("toolbar:not(#TabsToolbar)"),
].filter(toolbar => {
let bounds = toolbar.getBoundingClientRect();
return bounds.width > 0 && bounds.height > 0;
});
let transitionPromise = waitForTransition(toolbars[0], "background-color");
await extension.startup();
await transitionPromise;
info(`Checking toolbar colors for ${toolbars.length} toolbars.`);
for (let toolbar of toolbars) {
info(`Testing ${toolbar.id}`);
Assert.equal(
window.getComputedStyle(toolbar).backgroundColor,
hexToCSS(TOOLBAR_COLOR),
"Toolbar background color should be set."
);
Assert.equal(
window.getComputedStyle(toolbar).color,
hexToCSS(TOOLBAR_TEXT_COLOR),
"Toolbar text color should be set."
);
}
info("Checking selected tab colors");
let selectedTab = document.querySelector(".tabbrowser-tab[selected]");
Assert.equal(
window.getComputedStyle(selectedTab).color,
hexToCSS(TOOLBAR_TEXT_COLOR),
"Selected tab text color should be set."
);
await extension.unload();
});
add_task(async function test_bookmark_text_property() {
const TOOLBAR_COLOR = [255, 0, 255];
const TOOLBAR_TEXT_COLOR = [48, 0, 255];
let extension = ExtensionTestUtils.loadExtension({
manifest: {
theme: {
colors: {
frame: ACCENT_COLOR,
tab_background_text: TEXT_COLOR,
toolbar: TOOLBAR_COLOR,
bookmark_text: TOOLBAR_TEXT_COLOR,
},
},
},
});
await extension.startup();
let toolbox = document.querySelector("#navigator-toolbox");
let toolbars = [
...toolbox.querySelectorAll("toolbar:not(#TabsToolbar)"),
].filter(toolbar => {
let bounds = toolbar.getBoundingClientRect();
return bounds.width > 0 && bounds.height > 0;
});
info(`Checking toolbar colors for ${toolbars.length} toolbars.`);
for (let toolbar of toolbars) {
info(`Testing ${toolbar.id}`);
Assert.equal(
window.getComputedStyle(toolbar).color,
rgbToCSS(TOOLBAR_TEXT_COLOR),
"bookmark_text should be an alias for toolbar_text"
);
}
info("Checking selected tab colors");
let selectedTab = document.querySelector(".tabbrowser-tab[selected]");
Assert.equal(
window.getComputedStyle(selectedTab).color,
rgbToCSS(TOOLBAR_TEXT_COLOR),
"Selected tab text color should be set."
);
await extension.unload();
});