mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
4db87c1296
The wpt will be updated in https://github.com/web-platform-tests/wpt/pull/18866. Besides, there are some other test cases use text-decoration, so we have to update them as well. The rule is: if the test case is not related to old `text-decoration` longhand, we use `text-decoration-line` instead. If the test case is for testing the change of `text-decoration` from longhand to shorthand, we should use the correct serialization. Differential Revision: https://phabricator.services.mozilla.com/D44909 --HG-- extra : moz-landing-system : lando
89 lines
3.5 KiB
HTML
89 lines
3.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=649740
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 649740</title>
|
|
<script 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_inner, expected_match) {
|
|
style.textContent = "#display1, #display2 { text-decoration: overline }\n" +
|
|
"@supports " + condition_inner + "{\n" +
|
|
" #display1 { text-decoration: line-through }\n" +
|
|
"}\n" +
|
|
"#display2 { text-decoration: underline }\n";
|
|
is(cs1.textDecorationLine,
|
|
expected_match ? "line-through" : "overline",
|
|
"@supports condition \"" + condition_inner + "\" should " +
|
|
(expected_match ? "" : "NOT ") + "match");
|
|
is(cs2.textDecorationLine, "underline",
|
|
"@supports condition \"" + condition_inner + "\" 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)", true);
|
|
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)", true);
|
|
check_balanced_condition("(color: green)and (color: blue)", true);
|
|
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)", true);
|
|
check_balanced_condition("(color: green)or (color: blue)", true);
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
runTest();
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|