Bug 1476322 - Make browser_parsable_css.js parse more types of rules. r=jaws draft
authorTim Nguyen <ntim.bugs@gmail.com>
Tue, 17 Jul 2018 16:53:03 +0100
changeset 819350 00fd2dd98397375d596677f8025012e8ad3d48bc
parent 819340 8e70c52ba4bcfd069893582ae30c7a24eae141ad
push id116525
push userbmo:ntim.bugs@gmail.com
push dateTue, 17 Jul 2018 17:54:42 +0000
reviewersjaws
bugs1476322
milestone63.0a1
Bug 1476322 - Make browser_parsable_css.js parse more types of rules. r=jaws MozReview-Commit-ID: HZmMUEJsROz
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
@@ -115,26 +115,22 @@ let propNameWhitelist = [
    isFromDevTools: false},
   {propName: "--positionDurationBox-width-long",
    isFromDevTools: false},
   // Used on Linux
   {propName: "--in-content-box-background-odd",
    platforms: ["win", "macosx"],
    isFromDevTools: false},
 
-  // These properties *are* actually referenced. Need to find why
-  // their reference isn't getting counted.
+  // These variables are used in a shorthand, but the CSS parser deletes the values
+  // when expanding the shorthands. See https://github.com/w3c/csswg-drafts/issues/2515
   {propName: "--bezier-diagonal-color",
    isFromDevTools: true},
   {propName: "--bezier-grid-color",
    isFromDevTools: true},
-
-  // Bug 1476322 - Doesn't parse CSSKeyframeRules
-  {propName: "--tracking-protection-shield-color",
-   isFromDevTools: false},
 ];
 
 // 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) {
@@ -251,25 +247,25 @@ function messageIsCSSError(msg) {
   return false;
 }
 
 let imageURIsToReferencesMap = new Map();
 let customPropsToReferencesMap = new Map();
 
 function processCSSRules(sheet) {
   for (let rule of sheet.cssRules) {
-    if (rule instanceof CSSMediaRule) {
+    if (rule instanceof CSSConditionRule || rule instanceof CSSKeyframesRule) {
       processCSSRules(rule);
       continue;
     }
-    if (!(rule instanceof CSSStyleRule))
+    if (!(rule instanceof CSSStyleRule) && !(rule instanceof CSSKeyframeRule))
       continue;
 
     // Extract urls from the css text.
-    // Note: CSSStyleRule.cssText always has double quotes around URLs even
+    // Note: CSSRule.cssText always has double quotes around URLs even
     //       when the original CSS file didn't.
     let urls = rule.cssText.match(/url\("[^"]*"\)/g);
     // Extract props by searching all "--" preceeded by "var(" or a non-word
     // character.
     let props = rule.cssText.match(/(var\(|\W)(--[\w\-]+)/g);
     if (!urls && !props)
       continue;