Bug 904263 - Add tests to assure all properties can be removed. r=dbaron, a=bajaj
authorJohn Daggett <jdaggett@mozilla.com>
Thu, 15 Aug 2013 09:38:01 +0900
changeset 233442 a4851d7c6393cb16fc5752b070f9cefa235e4457
parent 233441 510c52b4ec97ef242fb97b89978a35865fbd38ed
child 233443 ebdb46e872e8d71c0d5a7610f43ee17be3cf05b7
push id208
push userryanvm@gmail.com
push dateMon, 23 Feb 2015 15:44:39 +0000
treeherdermozilla-b2g37_v2_2@09dafeb43234 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, bajaj
bugs904263
milestone25.0a2
Bug 904263 - Add tests to assure all properties can be removed. r=dbaron, a=bajaj
layout/style/test/test_inherit_storage.html
layout/style/test/test_initial_storage.html
layout/style/test/test_value_storage.html
--- a/layout/style/test/test_inherit_storage.html
+++ b/layout/style/test/test_inherit_storage.html
@@ -74,16 +74,33 @@ function test_property(property)
     is(val, "", "value of '" + sproperty + "' after removal of value");
     is(val, gDeclaration[sinfo.domProp],
        "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
   }
   check_final(property);
   if ("subproperties" in info)
     for (var idx in info.subproperties)
       check_final(info.subproperties[idx]);
+
+  // can all properties be removed from the style?
+  function test_remove_all_properties(property, value) {
+    var i, p = [];
+    for (i = 0; i < gDeclaration.length; i++) p.push(gDeclaration[i]);
+    for (i = 0; i < p.length; i++) gDeclaration.removeProperty(p[i]);
+    var errstr = "when setting property " + property + " to " + value;
+    is(gDeclaration.length, 0, "unremovable properties " + errstr);
+    is(gDeclaration.cssText, "", "non-empty serialization after removing all properties " + errstr);
+  }
+
+  // sanity check shorthands to make sure disabled props aren't exposed
+  if (info.type != CSS_TYPE_LONGHAND) {
+    gDeclaration.setProperty(property, "inherit", "");
+    test_remove_all_properties(property, "inherit");
+    gDeclaration.removeProperty(property);
+  }
 }
 
 for (var prop in gCSSProperties)
   test_property(prop);
 
 </script>
 </pre>
 </body>
--- a/layout/style/test/test_initial_storage.html
+++ b/layout/style/test/test_initial_storage.html
@@ -74,16 +74,33 @@ function test_property(property)
     is(val, "", "value of '" + sproperty + "' after removal of value");
     is(val, gDeclaration[sinfo.domProp],
        "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
   }
   check_final(property);
   if ("subproperties" in info)
     for (var idx in info.subproperties)
       check_final(info.subproperties[idx]);
+
+  // can all properties be removed from the style?
+  function test_remove_all_properties(property, value) {
+    var i, p = [];
+    for (i = 0; i < gDeclaration.length; i++) p.push(gDeclaration[i]);
+    for (i = 0; i < p.length; i++) gDeclaration.removeProperty(p[i]);
+    var errstr = "when setting property " + property + " to " + value;
+    is(gDeclaration.length, 0, "unremovable properties " + errstr);
+    is(gDeclaration.cssText, "", "non-empty serialization after removing all properties " + errstr);
+  }
+
+  // sanity check shorthands to make sure disabled props aren't exposed
+  if (info.type != CSS_TYPE_LONGHAND) {
+    gDeclaration.setProperty(property, "initial", "");
+    test_remove_all_properties(property, "initial");
+    gDeclaration.removeProperty(property);
+  }
 }
 
 for (var prop in gCSSProperties)
   test_property(prop);
 
 </script>
 </pre>
 </body>
--- a/layout/style/test/test_value_storage.html
+++ b/layout/style/test/test_value_storage.html
@@ -104,16 +104,26 @@ var gPrereqDeclaration =
   document.getElementById("prereqsheet").sheet.cssRules[0].style;
 
 function test_property(property)
 {
   var info = gCSSProperties[property];
 
   var test_computed = !("backend_only" in info);
 
+  // can all properties be removed from the style?
+  function test_remove_all_properties(property, value) {
+    var i, p = [];
+    for (i = 0; i < gDeclaration.length; i++) p.push(gDeclaration[i]);
+    for (i = 0; i < p.length; i++) gDeclaration.removeProperty(p[i]);
+    var errstr = "when setting property " + property + " to " + value;
+    is(gDeclaration.length, 0, "unremovable properties " + errstr);
+    is(gDeclaration.cssText, "", "non-empty serialization after removing all properties " + errstr);
+  }
+
   function test_value(value) {
     gDeclaration.setProperty(property, value, "");
 
     var idx;
 
     var step1val = gDeclaration.getPropertyValue(property);
     var step1vals = [];
     var step1ser = gDeclaration.cssText;
@@ -217,16 +227,22 @@ function test_property(property)
         if ("backend_only" in gCSSProperties[subprop])
           continue;
         is(gComputedStyle.getPropertyValue(subprop), step1comps[idx],
            "parse+compute+serialize(" + subprop + ") should be idempotent for '" +
            property + ": " + value + "'");
       }
     }
 
+    // sanity check shorthands to make sure disabled props aren't exposed
+    if (info.type != CSS_TYPE_LONGHAND) {
+      gDeclaration.setProperty(property, value, "");
+      test_remove_all_properties(property, value);
+    }
+
     gDeclaration.removeProperty(property);
   }
 
   if ("prerequisites" in info) {
     var prereqs = info.prerequisites;
     for (var prereq in prereqs) {
       gPrereqDeclaration.setProperty(prereq, prereqs[prereq], "");
     }