1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/test/test_css_supports.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,134 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=779917 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 779917</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=779917">Mozilla Bug 779917</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script type="application/javascript"> 1.22 + 1.23 +/** Test for Bug 779917 **/ 1.24 + 1.25 +function runTest() 1.26 +{ 1.27 + var passingConditions = [ 1.28 + "(color: green)", 1.29 + "((color: green))", 1.30 + "(color: green !important)", 1.31 + "(color: rainbow) or (color: green)", 1.32 + "(color: green) or (color: rainbow)", 1.33 + "(color: green) and (color: blue)", 1.34 + "(color: rainbow) or (color: iridescent) or (color: green)", 1.35 + "(color: red) and (color: green) and (color: blue)", 1.36 + "(color:green)", 1.37 + "not (color: rainbow)", 1.38 + "not (not (color: green))", 1.39 + "(unknown:) or (color: green)", 1.40 + "(unknown) or (color: green)", 1.41 + "(font: 16px serif)", 1.42 + "(color:) or (color: green)", 1.43 + "not (@page)", 1.44 + "not ({ something @with [ balanced ] brackets })", 1.45 + "an-extension(of some kind) or (color: green)", 1.46 + "not ()", 1.47 + "( Font: 20px serif ! Important) ", 1.48 + "(color: /* comment */ green)", 1.49 + "(/* comment */ color: green)", 1.50 + "(color: green /* comment */)", 1.51 + "(color: green) /* comment */", 1.52 + "/* comment */ (color: green)", 1.53 + "(color /* comment */: green)", 1.54 + "(color: green) /* unclosed comment", 1.55 + "(color: green", 1.56 + "(((((((color: green", 1.57 + "(font-family: 'Helvetica" 1.58 + ]; 1.59 + 1.60 + var failingConditions = [ 1.61 + "(color: rainbow)", 1.62 + "(color: rainbow) and (color: green)", 1.63 + "(color: blue) and (color: rainbow)", 1.64 + "(color: green) and (color: green) or (color: green)", 1.65 + "(color: green) or (color: green) and (color: green)", 1.66 + "not not (color: green)", 1.67 + "not (color: rainbow) and not (color: iridescent)", 1.68 + "not (color: rainbow) or (color: green)", 1.69 + "(not (color: rainbow) or (color: green))", 1.70 + "(unknown: green)", 1.71 + "not ({ something @with (unbalanced brackets })", 1.72 + "(color: green) or an-extension(that is [unbalanced)", 1.73 + "not(unknown: unknown)", 1.74 + "(color: green) or(color: blue)", 1.75 + "color: green", 1.76 + "(color: green;)", 1.77 + "(font-family: 'Helvetica\n", 1.78 + "(font-family: 'Helvetica\n')", 1.79 + "()", 1.80 + "" 1.81 + ]; 1.82 + 1.83 + var passingDeclarations = [ 1.84 + ["color", "green"], 1.85 + ["color", " green "], 1.86 + ["Color", "Green"], 1.87 + ["color", "green /* comment */"], 1.88 + ["color", "/* comment */ green"], 1.89 + ["color", "green /* unclosed comment"], 1.90 + ["font", "16px serif"], 1.91 + ["font", "16px /* comment */ serif"], 1.92 + ["font", "16px\nserif"], 1.93 + ["color", "\\0067reen"] 1.94 + ]; 1.95 + 1.96 + var failingDeclarations = [ 1.97 + ["color ", "green"], 1.98 + ["color", "rainbow"], 1.99 + ["color", "green green"], 1.100 + ["color", "green !important"], 1.101 + ["\\0063olor", "green"], 1.102 + ["/* comment */color", "green"], 1.103 + ["color/* comment */", "green"], 1.104 + ["font-family", "'Helvetica\n"], 1.105 + ["font-family", "'Helvetica\n'"], 1.106 + ["color", "green;"], 1.107 + ["color", ""], 1.108 + ["unknown", "unknown"], 1.109 + ["", "green"], 1.110 + ["", ""] 1.111 + ]; 1.112 + 1.113 + passingConditions.forEach(function(aCondition) { 1.114 + is(CSS.supports(aCondition), true, "CSS.supports returns true for passing condition \"" + aCondition + "\""); 1.115 + }); 1.116 + 1.117 + failingConditions.forEach(function(aCondition) { 1.118 + is(CSS.supports(aCondition), false, "CSS.supports returns false for failing condition \"" + aCondition + "\""); 1.119 + }); 1.120 + 1.121 + passingDeclarations.forEach(function(aDeclaration) { 1.122 + is(CSS.supports(aDeclaration[0], aDeclaration[1]), true, "CSS.supports returns true for supported declaration \"" + aDeclaration.join(":") + "\""); 1.123 + }); 1.124 + 1.125 + failingDeclarations.forEach(function(aDeclaration) { 1.126 + is(CSS.supports(aDeclaration[0], aDeclaration[1]), false, "CSS.supports returns false for unsupported declaration \"" + aDeclaration.join(":") + "\""); 1.127 + }); 1.128 + 1.129 + SimpleTest.finish(); 1.130 +} 1.131 + 1.132 +SimpleTest.waitForExplicitFinish(); 1.133 +SpecialPowers.pushPrefEnv({ "set": [["layout.css.supports-rule.enabled", true]] }, runTest); 1.134 +</script> 1.135 +</pre> 1.136 +</body> 1.137 +</html>