Bug 1442559 part 1 - Make it clearer what whitelist item filters the error. r?Gijs draft
authorXidorn Quan <me@upsuper.org>
Sat, 03 Mar 2018 11:54:24 +1100
changeset 763008 b0a701cf4ba1b0164f14b4ee3cbf9ead7252f970
parent 763007 232be45cc7936c50810d4888abb50f7906e8aa6f
child 763009 81c72f023c1ee47857da6df69a4b6791c3aca4f6
push id101304
push userxquan@mozilla.com
push dateSun, 04 Mar 2018 23:54:42 +0000
reviewersGijs
bugs1442559
milestone60.0a1
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. " +