Bug 815499 - Force @supports pref on for test_supports_rules.html. r=bz

This commit is contained in:
Cameron McCormack 2012-11-27 16:30:29 +11:00
parent d9b25082f5
commit bf788902dd

View File

@ -8,11 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=649740
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style id="style"> <style id="style">
@supports(color: green){ }
@supports (color: green) { }
@supports ((color: green)) { }
@supports (color: green) and (color: blue) { }
@supports ( Font: 20px serif ! Important) { }
</style> </style>
</head> </head>
<body> <body>
@ -30,17 +25,30 @@ function condition(s) {
return s.replace(/^@supports\s*/, '').replace(/ \s*{\s*}\s*$/, ''); return s.replace(/^@supports\s*/, '').replace(/ \s*{\s*}\s*$/, '');
} }
if (!SpecialPowers.getBoolPref("layout.css.supports-rule.enabled")) { var styleSheetText =
todo(false, "skipping test because pref is disabled"); "@supports(color: green){ }\n" +
} else { "@supports (color: green) { }\n" +
var sheet = document.getElementById("style").sheet; "@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[0].cssText), "(color: green)");
is(condition(sheet.cssRules[1].cssText), "(color: green)"); is(condition(sheet.cssRules[1].cssText), "(color: green)");
is(condition(sheet.cssRules[2].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[3].cssText), "(color: green) and (color: blue)");
is(condition(sheet.cssRules[4].cssText), "( Font: 20px serif ! Important)"); is(condition(sheet.cssRules[4].cssText), "( Font: 20px serif ! Important)");
SimpleTest.finish();
} }
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({ "set": [["layout.css.supports-rule.enabled", true]] }, runTest);
</script> </script>
</pre> </pre>
</body> </body>