Bug 969961 - Turn CSS Variables pref on in tests that rely on it. r=philor
authorCameron McCormack <cam@mcc.id.au>
Mon, 10 Feb 2014 11:56:35 +1100
changeset 167806 890d5e759a4b7c6af8c7022361760bcf322cec01
parent 167805 81e6988807deba68a62abacbe032da2d86e416cd
child 167807 4b255bcb080ccfd3bf2c0cf2b8fdef9888bc8ed9
push id26186
push usercbook@mozilla.com
push dateMon, 10 Feb 2014 11:48:02 +0000
treeherdermozilla-central@063a9e3da435 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilor
bugs969961
milestone30.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 969961 - Turn CSS Variables pref on in tests that rely on it. r=philor
layout/style/test/chrome/test_author_specified_style.html
layout/style/test/test_value_storage.html
layout/style/test/test_variable_serialization_computed.html
layout/style/test/test_variable_serialization_specified.html
layout/style/test/test_variables.html
--- a/layout/style/test/chrome/test_author_specified_style.html
+++ b/layout/style/test/chrome/test_author_specified_style.html
@@ -21,24 +21,32 @@ var values = [
 
 var properties = [
   // property to test with  // fixed prefix to ignore from getAuthoredPropertyValue()
   "color",                  "",
   "background-color",       "",
   "background",             "none repeat scroll 0% 0% "
 ];
 
-var span = document.createElement("span");
-for (var j = 0; j < properties.length; j += 2) {
-  var propertyName = properties[j];
-  var expectedPrefix = properties[j + 1];
-  for (var i = 0; i < values.length; i += 2) {
-    var value = values[i];
-    var expected = values[i + 1];
-    span.setAttribute("style", propertyName + ": " + value);
-    is(span.style.getAuthoredPropertyValue(propertyName), expectedPrefix + expected, "specified " + value);
+function runTest() {
+  var span = document.createElement("span");
+  for (var j = 0; j < properties.length; j += 2) {
+    var propertyName = properties[j];
+    var expectedPrefix = properties[j + 1];
+    for (var i = 0; i < values.length; i += 2) {
+      var value = values[i];
+      var expected = values[i + 1];
+      span.setAttribute("style", propertyName + ": " + value);
+      is(span.style.getAuthoredPropertyValue(propertyName), expectedPrefix + expected, "specified " + value);
+    }
   }
+
+  // also test a custom property
+  span.setAttribute("style", "var-color: rgb(10%,25%,99%)");
+  is(span.style.getAuthoredPropertyValue("var-color"), " rgb(10%,25%,99%)", "specified var-color");
+
+  SimpleTest.finish();
 }
 
-// also test a custom property
-span.setAttribute("style", "var-color: rgb(10%,25%,99%)");
-is(span.style.getAuthoredPropertyValue("var-color"), " rgb(10%,25%,99%)", "specified var-color");
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({ set: [["layout.css.variables.enabled", true]] },
+                          runTest);
 </script>
--- a/layout/style/test/test_value_storage.html
+++ b/layout/style/test/test_value_storage.html
@@ -100,16 +100,17 @@ var gElement = document.getElementById("
 var gDeclaration = gElement.style;
 var gComputedStyle = window.getComputedStyle(gElement, "");
 
 var gPrereqDeclaration =
   document.getElementById("prereqsheet").sheet.cssRules[0].style;
 
 function test_property(property)
 {
+  ok(SpecialPowers.getBoolPref("layout.css.variables.enabled"), "pref not set #2");
   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]);
@@ -281,30 +282,36 @@ function test_property(property)
   if ("prerequisites" in info) {
     for (var prereq in info.prerequisites) {
       gPrereqDeclaration.removeProperty(prereq);
     }
   }
 
 }
 
-// To avoid triggering the slow script dialog, we have to test one
-// property at a time.
+function runTest() {
+  // To avoid triggering the slow script dialog, we have to test one
+  // property at a time.
+  ok(SpecialPowers.getBoolPref("layout.css.variables.enabled"), "pref not set #1");
+  var props = [];
+  for (var prop in gCSSProperties)
+    props.push(prop);
+  props = props.reverse();
+  function do_one() {
+    if (props.length == 0) {
+      SimpleTest.finish();
+      return;
+    }
+    test_property(props.pop());
+    SimpleTest.executeSoon(do_one);
+  }
+  SimpleTest.executeSoon(do_one);
+}
+
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestLongerTimeout(2);
-var props = [];
-for (var prop in gCSSProperties)
-  props.push(prop);
-props = props.reverse();
-function do_one() {
-  if (props.length == 0) {
-    SimpleTest.finish();
-    return;
-  }
-  test_property(props.pop());
-  SimpleTest.executeSoon(do_one);
-}
-SimpleTest.executeSoon(do_one);
 
+SpecialPowers.pushPrefEnv({ set: [["layout.css.variables.enabled", true]] },
+                          runTest);
 </script>
 </pre>
 </body>
 </html>
--- a/layout/style/test/test_variable_serialization_computed.html
+++ b/layout/style/test/test_variable_serialization_computed.html
@@ -1,15 +1,15 @@
 <!DOCTYPE html>
 <title>Test serialization of computed CSS variable values</title>
 <script src="/MochiKit/MochiKit.js"></script>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css" type="text/css">
 
-<div style="var-z:an-inherited-value">
+<div>
   <span></span>
 </div>
 
 <script>
 // Each entry is an entire declaration followed by the property to check and
 // its expected computed value.
 var values = [
   ["", "var-z", "an-inherited-value"],
@@ -47,19 +47,30 @@ var values = [
   ["var-a: url(http://example.org/", "var-a", " url(http://example.org/)"],
   ["var-a: url(http://example.org/\\", "var-a", " url(http://example.org/\\\ufffd)"],
   ["var-a: url('http://example.org/", "var-a", " url('http://example.org/')"],
   ["var-a: url('http://example.org/\\", "var-a", " url('http://example.org/')"],
   ["var-a: url(\"http://example.org/", "var-a", " url(\"http://example.org/\")"],
   ["var-a: url(\"http://example.org/\\", "var-a", " url(\"http://example.org/\")"]
 ];
 
-var span = document.querySelector("span");
+function runTest() {
+  var div = document.querySelector("div");
+  var span = document.querySelector("span");
+
+  div.setAttribute("style", "var-z:an-inherited-value");
 
-values.forEach(function(entry, i) {
-  var declaration = entry[0];
-  var property = entry[1];
-  var expected = entry[2];
-  span.setAttribute("style", declaration);
-  var cs = getComputedStyle(span, "");
-  is(cs.getPropertyValue(property), expected, "subtest #" + i);
-});
+  values.forEach(function(entry, i) {
+    var declaration = entry[0];
+    var property = entry[1];
+    var expected = entry[2];
+    span.setAttribute("style", declaration);
+    var cs = getComputedStyle(span, "");
+    is(cs.getPropertyValue(property), expected, "subtest #" + i);
+  });
+
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({ set: [["layout.css.variables.enabled", true]] },
+                          runTest);
 </script>
--- a/layout/style/test/test_variable_serialization_specified.html
+++ b/layout/style/test/test_variable_serialization_specified.html
@@ -93,16 +93,24 @@ function test_specified_value_serializat
      "value with identical serialization set on non-custom shorthand property via parsing");
 
   // Clean up.
   decl.removeProperty("var-test");
   decl.removeProperty("color");
   decl.removeProperty("margin");
 }
 
-values_with_unchanged_specified_value_serialization.forEach(function(value) {
-  test_specified_value_serialization(value, value);
-});
+function runTest() {
+  values_with_unchanged_specified_value_serialization.forEach(function(value) {
+    test_specified_value_serialization(value, value);
+  });
 
-values_with_changed_specified_value_serialization.forEach(function(pair) {
-  test_specified_value_serialization(pair[0], pair[1]);
-});
+  values_with_changed_specified_value_serialization.forEach(function(pair) {
+    test_specified_value_serialization(pair[0], pair[1]);
+  });
+
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({ set: [["layout.css.variables.enabled", true]] },
+                          runTest);
 </script>
--- a/layout/style/test/test_variables.html
+++ b/layout/style/test/test_variables.html
@@ -1,43 +1,53 @@
 <!DOCTYPE type>
 <title>Assorted CSS variable tests</title>
 <script src="/MochiKit/MochiKit.js"></script>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css" type="text/css">
 
 <style id="test1">
-p { var-a:123!important; }
 </style>
 
 <style id="test2">
-p { var-a: a !important; }
 </style>
 
 <style id="test3">
-p { border-left-style: inset; padding: 1px; var-decoration: line-through; }
 </style>
 
 <script>
 var tests = [
   function() {
     // https://bugzilla.mozilla.org/show_bug.cgi?id=773296#c121
-    var declaration = document.getElementById("test1").sheet.cssRules[0].style;
+    var test1 = document.getElementById("test1");
+    test1.textContent = "p { var-a:123!important; }";
+    var declaration = test1.sheet.cssRules[0].style;
     declaration.cssText;
     declaration.setProperty("color", "black");
     is(declaration.getPropertyValue("var-a"), "123");
   },
 
   function() {
     // https://bugzilla.mozilla.org/show_bug.cgi?id=773296#c121
-    var declaration = document.getElementById("test2").sheet.cssRules[0].style;
+    var test2 = document.getElementById("test2");
+    test2.textContent = "p { var-a: a !important; }";
+    var declaration = test2.sheet.cssRules[0].style;
     is(declaration.getPropertyPriority("var-a"), "important");
   },
 
   function() {
     // https://bugzilla.mozilla.org/show_bug.cgi?id=955913
-    var declaration = document.getElementById("test3").sheet.cssRules[0].style;
+    var test3 = document.getElementById("test3");
+    test3.textContent = "p { border-left-style: inset; padding: 1px; var-decoration: line-through; }";
+    var declaration = test3.sheet.cssRules[0].style;
     is(declaration[declaration.length - 1], "var-decoration");
   },
 ];
 
-tests.forEach(function(fn) { fn(); });
+function runTest() {
+  tests.forEach(function(fn) { fn(); });
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({ set: [["layout.css.variables.enabled", true ]] },
+                          runTest);
 </script>