Bug 1267890 part 2 - Add test for -moz-bool-pref(). r?emilio draft
authorXidorn Quan <me@upsuper.org>
Fri, 08 Dec 2017 00:36:30 -0600
changeset 709730 7420fe1babf529eac00e5c3b2a40ca2459e6273d
parent 709729 3ff0c3e0e12673b0fbae87592c39cae04c37932a
child 743500 783f8fdcdd756a374a144b01220549fa10c07a71
push id92735
push userxquan@mozilla.com
push dateFri, 08 Dec 2017 17:27:30 +0000
reviewersemilio
bugs1267890
milestone59.0a1
Bug 1267890 part 2 - Add test for -moz-bool-pref(). r?emilio MozReview-Commit-ID: AFTVgwbi9M
layout/reftests/css-parsing/green-ref.html
layout/reftests/css-parsing/moz-bool-pref.css
layout/reftests/css-parsing/reftest.list
layout/reftests/css-parsing/supports-moz-bool-pref-1.html
layout/reftests/css-parsing/supports-moz-bool-pref-2.html
layout/reftests/css-parsing/supports-moz-bool-pref-3.html
layout/reftests/css-parsing/supports-moz-bool-pref-ref.html
layout/reftests/css-parsing/supports-moz-bool-pref.html
layout/tools/reftest/jar.mn
layout/tools/reftest/reftest-preferences.js
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/green-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background: green"></div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/moz-bool-pref.css
@@ -0,0 +1,22 @@
+#test {
+  width: 100px;
+  height: 100px;
+}
+
+.enabled {
+  background: red;
+}
+
+.disabled {
+  background: green;
+}
+
+@supports -moz-bool-pref("testing.supports.moz-bool-pref") {
+  .enabled {
+    background: green;
+  }
+
+  .disabled {
+    background: red;
+  }
+}
--- a/layout/reftests/css-parsing/reftest.list
+++ b/layout/reftests/css-parsing/reftest.list
@@ -1,9 +1,12 @@
 == at-rule-013.html at-rule-013-ref.html
 == invalid-url-handling.xhtml invalid-url-handling-ref.xhtml
 == pseudo-elements-1.html pseudo-elements-1-ref.html
 == invalid-attr-1.html invalid-attr-1-ref.html
 == at-rule-error-handling-import-1.html at-rule-error-handling-ref.html
 == at-rule-error-handling-media-1.html at-rule-error-handling-ref.html
 == invalid-font-face-descriptor-1.html invalid-font-face-descriptor-1-ref.html
 == two-dash-identifiers.html two-dash-identifiers-ref.html
-== supports-moz-bool-pref.html supports-moz-bool-pref-ref.html
+
+test-pref(testing.supports.moz-bool-pref,true) == supports-moz-bool-pref-1.html green-ref.html
+test-pref(testing.supports.moz-bool-pref,false) == supports-moz-bool-pref-2.html green-ref.html
+test-pref(testing.supports.moz-bool-pref,true) == supports-moz-bool-pref-3.html green-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/supports-moz-bool-pref-1.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<!-- The query part here is necessary because chrome stylesheets are
+     cached after first parse, so the -moz-bool-pref() wouldn't be
+     re-evaluated if we use the same url as the other test. -->
+<link rel="stylesheet" href="chrome://reftest/content/moz-bool-pref.css?1">
+<!-- testing.supports.moz-bool-pref = true -->
+<div id="test" class="enabled"></div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/supports-moz-bool-pref-2.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<!-- The query part here is necessary because chrome stylesheets are
+     cached after first parse, so the -moz-bool-pref() wouldn't be
+     re-evaluated if we use the same url as the other test. -->
+<link rel="stylesheet" href="chrome://reftest/content/moz-bool-pref.css?2">
+<!-- testing.supports.moz-bool-pref = false -->
+<div id="test" class="disabled"></div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/supports-moz-bool-pref-3.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<link rel="stylesheet" href="moz-bool-pref.css">
+<!-- not valid outside chrome / ua stylesheets -->
+<div id="test" class="disabled"></div>
deleted file mode 100644
--- a/layout/reftests/css-parsing/supports-moz-bool-pref-ref.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<!-- Any copyright is dedicated to the Public Domain.
-   - http://creativecommons.org/publicdomain/zero/1.0/ -->
-
-<html>
-  <body>
-    <p>This text should not have background color.</p>
-  </body>
-</html>
-
deleted file mode 100644
--- a/layout/reftests/css-parsing/supports-moz-bool-pref.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<!-- Any copyright is dedicated to the Public Domain.
-   - http://creativecommons.org/publicdomain/zero/1.0/ -->
-
-<html>
-  <style>
-  /* This is not a user agent style sheet, so the style will be ignored.
-     "testing.supports.moz-bool-pref" is set to true in
-     layout/tools/reftest/reftest-preferences.js. */
-  @supports -moz-bool-pref("testing.supports.moz-bool-pref") {
-    p {
-      background-color: red;
-    }
-  }
-  </style>
-  <body>
-    <p>This text should not have background color.</p>
-  </body>
-</html>
-
--- a/layout/tools/reftest/jar.mn
+++ b/layout/tools/reftest/jar.mn
@@ -1,12 +1,13 @@
 reftest.jar:
 % content reftest %content/ contentaccessible=yes
   content/globals.jsm (globals.jsm)
   content/reftest-content.js (reftest-content.js)
   content/AsyncSpellCheckTestHelper.jsm (../../../editor/AsyncSpellCheckTestHelper.jsm)
   content/httpd.jsm (../../../netwerk/test/httpserver/httpd.js)
   content/StructuredLog.jsm (../../../testing/modules/StructuredLog.jsm)
   content/input.css (../../../editor/reftests/xul/input.css)
+  content/moz-bool-pref.css (../../../layout/reftests/css-parsing/moz-bool-pref.css)
   content/progress.css (../../../layout/reftests/forms/progress/style.css)
 *  content/manifest.jsm (manifest.jsm)
 *  content/reftest.jsm (reftest.jsm)
   content/reftest.xul (reftest.xul)
--- a/layout/tools/reftest/reftest-preferences.js
+++ b/layout/tools/reftest/reftest-preferences.js
@@ -125,17 +125,17 @@ user_pref("xpinstall.signatures.required
 user_pref("startup.homepage_welcome_url", "");
 user_pref("startup.homepage_welcome_url.additional", "");
 user_pref("startup.homepage_override_url", "");
 
 user_pref("media.gmp-manager.url.override", "http://localhost/dummy-gmp-manager.xml");
 user_pref("media.gmp-manager.updateEnabled", false);
 
 // A fake bool pref for "@supports -moz-bool-pref" sanify test.
-user_pref("testing.supports.moz-bool-pref", true);
+user_pref("testing.supports.moz-bool-pref", false);
 
 // Reftests load a lot of URLs very quickly. This puts avoidable and
 // unnecessary I/O pressure on the Places DB (measured to be in the
 // gigabytes).
 user_pref("places.history.enabled", false);
 
 // For Firefox 52 only, ESR will support non-Flash plugins while release will
 // not, so we keep testing the non-Flash pathways