Bug 1308467 - fix fronts/css-properties.js when remote debugging old firefox;r=tromey draft
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 07 Oct 2016 15:53:30 +0200
changeset 422104 d8bb5765a8ac68978ee55c65c5d474c1358917ae
parent 421721 1d7748535fa370332623ac29e50dd19e1ef6133b
child 533265 c23c099fe9b948515a91c9af0296cc904803737b
push id31697
push userjdescottes@mozilla.com
push dateFri, 07 Oct 2016 14:02:36 +0000
reviewerstromey
bugs1308467
milestone52.0a1
Bug 1308467 - fix fronts/css-properties.js when remote debugging old firefox;r=tromey MozReview-Commit-ID: 365CiBV8uha
devtools/shared/fronts/css-properties.js
--- a/devtools/shared/fronts/css-properties.js
+++ b/devtools/shared/fronts/css-properties.js
@@ -272,38 +272,32 @@ function normalizeCssData(db) {
     // now it returns an object with multiple types of CSS information.
     if (!db.properties) {
       db = { properties: db };
     }
 
     // Fill in any missing DB information from the static database.
     db = Object.assign({}, CSS_PROPERTIES_DB, db);
 
-    // Add "supports" information to the css properties if it's missing.
-    if (!db.properties.color.supports) {
-      for (let name in db.properties) {
-        if (typeof CSS_PROPERTIES_DB.properties[name] === "object") {
-          db.properties[name].supports = CSS_PROPERTIES_DB.properties[name].supports;
-        }
+    for (let name in db.properties) {
+      // Skip the current property if we can't find it in CSS_PROPERTIES_DB.
+      if (typeof CSS_PROPERTIES_DB.properties[name] !== "object") {
+        continue;
       }
-    }
 
-    // Add "values" information to the css properties if it's missing.
-    if (!db.properties.color.values) {
-      for (let name in db.properties) {
-        if (typeof CSS_PROPERTIES_DB.properties[name] === "object") {
-          db.properties[name].values = CSS_PROPERTIES_DB.properties[name].values;
-        }
+      // Add "supports" information to the css properties if it's missing.
+      if (!db.properties.color.supports) {
+        db.properties[name].supports = CSS_PROPERTIES_DB.properties[name].supports;
       }
-    }
-
-    // Add "subproperties" information to the css properties if it's
-    // missing.
-    if (!db.properties.background.subproperties) {
-      for (let name in db.properties) {
+      // Add "values" information to the css properties if it's missing.
+      if (!db.properties.color.values) {
+        db.properties[name].values = CSS_PROPERTIES_DB.properties[name].values;
+      }
+      // Add "subproperties" information to the css properties if it's missing.
+      if (!db.properties.background.subproperties) {
         db.properties[name].subproperties =
           CSS_PROPERTIES_DB.properties[name].subproperties;
       }
     }
   }
 
   reattachCssColorValues(db);
 
@@ -315,17 +309,18 @@ function normalizeCssData(db) {
  * @param {Object} The CSS database.
  */
 function reattachCssColorValues(db) {
   if (db.properties.color.values[0] === "COLOR") {
     const colors = Object.keys(cssColors);
 
     for (let name in db.properties) {
       const property = db.properties[name];
-      if (property.values[0] === "COLOR") {
+      // "values" can be undefined if {name} was not found in CSS_PROPERTIES_DB.
+      if (property.values && property.values[0] === "COLOR") {
         property.values.shift();
         property.values = property.values.concat(colors).sort();
       }
     }
   }
 }
 
 module.exports = {