--- a/browser/base/content/test/static/browser_parsable_css.js
+++ b/browser/base/content/test/static/browser_parsable_css.js
@@ -64,17 +64,38 @@ let whitelist = [
{sourceName: /webide\/skin\/logs\.css$/i,
intermittent: true,
errorMessage: /Property contained reference to invalid variable.*background/i,
isFromDevTools: true},
{sourceName: /devtools\/skin\/animationinspector\.css$/i,
intermittent: true,
errorMessage: /Property contained reference to invalid variable.*color/i,
isFromDevTools: true},
+];
+if (!Services.prefs.getBoolPref("full-screen-api.unprefix.enabled")) {
+ whitelist.push({
+ sourceName: /(?:res|gre-resources)\/(ua|html)\.css$/i,
+ errorMessage: /Unknown pseudo-class .*\bfullscreen\b/i,
+ isFromDevTools: false
+ });
+}
+
+// Platform can be "linux", "macosx" or "win". If omitted, the exception applies to all platforms.
+let allowedImageReferences = [
+ // Bug 1302691
+ {file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png",
+ from: "chrome://devtools/skin/toolbox.css",
+ isFromDevTools: true},
+ {file: "chrome://devtools/skin/images/dock-bottom-maximize@2x.png",
+ from: "chrome://devtools/skin/toolbox.css",
+ isFromDevTools: true},
+];
+
+let propNameWhitelist = [
// These are CSS custom properties that we found a definition of but
// no reference to.
// Bug 1441837
{propName: "--in-content-category-text-active",
isFromDevTools: false},
// Bug 1441844
{propName: "--chrome-nav-bar-separator-color",
isFromDevTools: false},
@@ -126,35 +147,16 @@ let whitelist = [
// These properties *are* actually referenced. Need to find why
// their reference isn't getting counted.
{propName: "--bezier-diagonal-color",
isFromDevTools: true},
{propName: "--bezier-grid-color",
isFromDevTools: true},
];
-if (!Services.prefs.getBoolPref("full-screen-api.unprefix.enabled")) {
- whitelist.push({
- sourceName: /(?:res|gre-resources)\/(ua|html)\.css$/i,
- errorMessage: /Unknown pseudo-class .*\bfullscreen\b/i,
- isFromDevTools: false
- });
-}
-
-// Platform can be "linux", "macosx" or "win". If omitted, the exception applies to all platforms.
-let allowedImageReferences = [
- // Bug 1302691
- {file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png",
- from: "chrome://devtools/skin/toolbox.css",
- isFromDevTools: true},
- {file: "chrome://devtools/skin/images/dock-bottom-maximize@2x.png",
- from: "chrome://devtools/skin/toolbox.css",
- isFromDevTools: true},
-];
-
// Add suffix to stylesheets' URI so that we always load them here and
// have them parsed. Add a random number so that even if we run this
// test multiple times, it would be unlikely to affect each other.
const kPathSuffix = "?always-parse-css-" + Math.random();
function dumpWhitelistItem(item) {
return JSON.stringify(item, (key, value) => {
return value instanceof RegExp ? value.toString() : value;
@@ -433,17 +435,17 @@ add_task(async function checkAllTheCSS()
}
}
}
// Check if all the properties that are defined are referenced.
for (let [prop, refCount] of customPropsToReferencesMap) {
if (!refCount) {
let ignored = false;
- for (let item of whitelist) {
+ for (let item of propNameWhitelist) {
if (item.propName == prop &&
isDevtools == item.isFromDevTools) {
item.used = true;
if (!item.platforms || item.platforms.includes(AppConstants.platform)) {
ignored = true;
}
break;
}
@@ -456,34 +458,28 @@ add_task(async function checkAllTheCSS()
let messages = Services.console.getMessageArray();
// Count errors (the test output will list actual issues for us, as well
// as the ok(false) in messageIsCSSError.
let errors = messages.filter(messageIsCSSError);
is(errors.length, 0, "All the styles (" + allPromises.length + ") loaded without errors.");
// Confirm that all whitelist rules have been used.
- for (let item of whitelist) {
- if (!item.used &&
- (!item.platforms || item.platforms.includes(AppConstants.platform)) &&
- isDevtools == item.isFromDevTools &&
- !item.intermittent) {
- ok(false, "Unused whitelist item. " + dumpWhitelistItem(item));
+ function checkWhitelist(list) {
+ for (let item of list) {
+ if (!item.used && isDevtools == item.isFromDevTools &&
+ (!item.platforms || item.platforms.includes(AppConstants.platform)) &&
+ !item.intermittent) {
+ ok(false, "Unused whitelist item: " + dumpWhitelistItem(item));
+ }
}
}
-
- // Confirm that all file whitelist rules have been used.
- for (let item of allowedImageReferences) {
- if (!item.used && isDevtools == item.isFromDevTools &&
- (!item.platforms || item.platforms.includes(AppConstants.platform))) {
- ok(false, "Unused file whitelist item. " +
- " file: " + item.file +
- " from: " + item.from);
- }
- }
+ checkWhitelist(whitelist);
+ checkWhitelist(allowedImageReferences);
+ checkWhitelist(propNameWhitelist);
// Clean up to avoid leaks:
iframe.remove();
doc.head.innerHTML = "";
doc = null;
iframe = null;
win = null;
hiddenFrame.destroy();