Bug 1442559 part 1 - Make it clearer what whitelist item filters the error. r=Gijs
authorXidorn Quan <me@upsuper.org>
Sat, 03 Mar 2018 11:54:24 +1100
changeset 406509 4d6a3eb93a00dce5d9eea854acef6aaa9475e2f0
parent 406502 53f082b32ba9eb0b9febdc97373c89b9ac500bd3
child 406510 756d5b77b54002d1b058e4d6e297b8fef689f97a
push id33567
push userebalazs@mozilla.com
push dateMon, 05 Mar 2018 09:40:48 +0000
treeherdermozilla-central@e365d166458b [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 1 - Make it clearer what whitelist item filters the error. r=Gijs MozReview-Commit-ID: 2VFgHRdvd5m
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
@@ -150,16 +150,22 @@ let allowedImageReferences = [
    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;
+  });
+}
+
 /**
  * Check if an error should be ignored due to matching one of the whitelist
  * objects defined in whitelist
  *
  * @param aErrorObject the error to check
  * @return true if the error should be ignored, false otherwise.
  */
 function ignoredError(aErrorObject) {
@@ -169,16 +175,19 @@ function ignoredError(aErrorObject) {
       if (whitelistItem.hasOwnProperty(prop) &&
           !whitelistItem[prop].test(aErrorObject[prop] || "")) {
         matches = false;
         break;
       }
     }
     if (matches) {
       whitelistItem.used = true;
+      let {sourceName, errorMessage} = aErrorObject;
+      info(`Ignored error "${errorMessage}" on ${sourceName} ` +
+           "because of whitelist item " + dumpWhitelistItem(whitelistItem));
       return true;
     }
   }
   return false;
 }
 
 var gChromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
                  .getService(Ci.nsIChromeRegistry);
@@ -243,17 +252,16 @@ function messageIsCSSError(msg) {
       msg.sourceName.endsWith(kPathSuffix)) {
     let sourceName = msg.sourceName.slice(0, -kPathSuffix.length);
     let msgInfo = { sourceName, errorMessage: msg.errorMessage };
     // Check if this error is whitelisted in whitelist
     if (!ignoredError(msgInfo)) {
       ok(false, `Got error message for ${sourceName}: ${msg.errorMessage}`);
       return true;
     }
-    info(`Ignored error for ${sourceName} because of filter.`);
   }
   return false;
 }
 
 let imageURIsToReferencesMap = new Map();
 let customPropsToReferencesMap = new Map();
 
 function processCSSRules(sheet) {
@@ -453,20 +461,17 @@ add_task(async function checkAllTheCSS()
   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. " +
-                (item.propName ? " propName: " + item.propName : "") +
-                (item.sourceName ? " sourceName: " + item.sourceName : "") +
-                (item.errorMessage ? " errorMessage: " + item.errorMessage : ""));
+      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. " +