summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_supports_rules.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /layout/style/test/test_supports_rules.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/style/test/test_supports_rules.html')
-rw-r--r--layout/style/test/test_supports_rules.html88
1 files changed, 88 insertions, 0 deletions
diff --git a/layout/style/test/test_supports_rules.html b/layout/style/test/test_supports_rules.html
new file mode 100644
index 000000000..834671375
--- /dev/null
+++ b/layout/style/test/test_supports_rules.html
@@ -0,0 +1,88 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=649740
+-->
+<head>
+ <title>Test for Bug 649740</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <style id="style">
+ </style>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=649740">Mozilla Bug 649740</a>
+<p id="display1"></p>
+<p id="display2"></p>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 649740 **/
+
+function condition(s) {
+ return s.replace(/^@supports\s*/, '').replace(/ \s*{\s*}\s*$/, '');
+}
+
+var styleSheetText =
+ "@supports(color: green){ }\n" +
+ "@supports (color: green) { }\n" +
+ "@supports ((color: green)) { }\n" +
+ "@supports (color: green) and (color: blue) { }\n" +
+ "@supports ( Font: 20px serif ! Important) { }";
+
+function runTest() {
+ var style = document.getElementById("style");
+ style.textContent = styleSheetText;
+
+ var sheet = style.sheet;
+
+ is(condition(sheet.cssRules[0].cssText), "(color: green)");
+ is(condition(sheet.cssRules[1].cssText), "(color: green)");
+ is(condition(sheet.cssRules[2].cssText), "((color: green))");
+ is(condition(sheet.cssRules[3].cssText), "(color: green) and (color: blue)");
+ is(condition(sheet.cssRules[4].cssText), "( Font: 20px serif ! Important)");
+
+ var cs1 = getComputedStyle(document.getElementById("display1"), "");
+ var cs2 = getComputedStyle(document.getElementById("display2"), "");
+ function check_balanced_condition(condition, expected_match) {
+ style.textContent = "#display1, #display2 { text-decoration: overline }\n" +
+ "@supports " + condition + "{\n" +
+ " #display1 { text-decoration: line-through }\n" +
+ "}\n" +
+ "#display2 { text-decoration: underline }\n";
+ is(cs1.textDecoration,
+ expected_match ? "line-through" : "overline",
+ "@supports condition \"" + condition + "\" should " +
+ (expected_match ? "" : "NOT ") + "match");
+ is(cs2.textDecoration, "underline",
+ "@supports condition \"" + condition + "\" should be balanced");
+ }
+
+ check_balanced_condition("not (color: green)", false);
+ check_balanced_condition("not (colour: green)", true);
+ check_balanced_condition("not(color: green)", false);
+ check_balanced_condition("not(colour: green)", false);
+ check_balanced_condition("not/* */(color: green)", false);
+ check_balanced_condition("not/* */(colour: green)", false);
+ check_balanced_condition("not /* */ (color: green)", false);
+ check_balanced_condition("not /* */ (colour: green)", true);
+ check_balanced_condition("(color: green) and (color: blue)", true);
+ check_balanced_condition("(color: green) /* */ /* */ and /* */ /* */ (color: blue)", true);
+ check_balanced_condition("(color: green) and(color: blue)", false);
+ check_balanced_condition("(color: green) and/* */(color: blue)", false);
+ check_balanced_condition("(color: green)and (color: blue)", false);
+ check_balanced_condition("(color: green) or (color: blue)", true);
+ check_balanced_condition("(color: green) /* */ /* */ or /* */ /* */ (color: blue)", true);
+ check_balanced_condition("(color: green) or(color: blue)", false);
+ check_balanced_condition("(color: green) or/* */(color: blue)", false);
+ check_balanced_condition("(color: green)or (color: blue)", false);
+
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+runTest();
+</script>
+</pre>
+</body>
+</html>