Bug 1442559 part 2 - Use a separate whitelist for prop names. r=Gijs
☠☠ backed out by 53f082b32ba9 ☠ ☠
authorXidorn Quan <me@upsuper.org>
Sat, 03 Mar 2018 11:55:42 +1100
changeset 461518 6371120b7c1cd2701152c86a5840257e9df5b9fb
parent 461517 b2bf42743febfe4d3d29753b9ff8f72aaca5b237
child 461519 d540c55c96c5e4fdab1434032628fa876152b8e1
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1442559
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1442559 part 2 - Use a separate whitelist for prop names. r=Gijs MozReview-Commit-ID: LT50Q5xFydH
browser/base/content/test/static/browser_parsable_css.js
--- 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(whitelist) {
+    for (let item of whitelist) {
+      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();