mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update web-platform-tests to revision b'b728032f59a396243864b0f8584e7211e3632005'
This commit is contained in:
parent
ace9b32b1c
commit
df68c4e5d1
15632 changed files with 514865 additions and 155000 deletions
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Paged Media: parsing @page selectors</title>
|
||||
<link rel="author" title="Mozilla" href="https://mozilla.org"/>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-page/#page-selectors"/>
|
||||
<meta name="assert" content="Test that @page selectors are parsed correctly.">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<style>
|
||||
@page a, B {
|
||||
size: 1in;
|
||||
}
|
||||
@page A,b,C {
|
||||
size: 2in;
|
||||
}
|
||||
@page auto {
|
||||
size: 3in;
|
||||
}
|
||||
@page something, auto {
|
||||
size: 4in;
|
||||
}
|
||||
@page auto, other_thing {
|
||||
size: 5in;
|
||||
}
|
||||
@page _a, Z {
|
||||
size: 6in;
|
||||
}
|
||||
@page -b, y {
|
||||
size: 7in;
|
||||
}
|
||||
@page _abcd {
|
||||
size: 8in;
|
||||
}
|
||||
@page n,-XYZ {
|
||||
size: 9in;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
let expectedForSelector = {
|
||||
"a, B" : "size: 1in;",
|
||||
"A, b, C" : "size: 2in;",
|
||||
"auto" : "size: 3in;",
|
||||
"something, auto" : "size: 4in;",
|
||||
"auto, other_thing" : "size: 5in;",
|
||||
"_a, Z" : "size: 6in;",
|
||||
"-b, y" : "size: 7in;",
|
||||
"_abcd" : "size: 8in;",
|
||||
"n, -XYZ" : "size: 9in;"
|
||||
};
|
||||
let styleSheets = document.styleSheets;
|
||||
for (let sheet of styleSheets) {
|
||||
let rules = sheet.cssRules;
|
||||
for (let rule of rules) {
|
||||
if (rule.type == CSSRule.PAGE_RULE) {
|
||||
let expected = expectedForSelector[rule.selectorText];
|
||||
test(function(){
|
||||
assert_equals(rule.style.cssText, expected, "unexpected @page contents");
|
||||
}, "contents for selector ['" + rule.selectorText + "']");
|
||||
delete expectedForSelector[rule.selectorText];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validate that we can assign an empty selector
|
||||
test(function() {
|
||||
let rule = styleSheets[0].cssRules[0];
|
||||
assert_equals(rule.type, CSSRule.PAGE_RULE, "expected first rule to be @page");
|
||||
rule.selectorText = "";
|
||||
assert_equals(rule.selectorText, "", "unexpected selector when assigning blank string");
|
||||
}, "expected empty selector when assigning blank string");
|
||||
test(function() {
|
||||
assert_equals(Object.keys(expectedForSelector).length, 0, "missing @page selectors");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Paged Media: parsing invalid @page selectors</title>
|
||||
<link rel="author" title="Mozilla" href="https://mozilla.org"/>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-page/#page-selectors"/>
|
||||
<meta name="assert" content="Test that @page selectors are parsed correctly.">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<style>
|
||||
@page 1 {
|
||||
size: 1in;
|
||||
}
|
||||
@page -3 {
|
||||
size: 2in;
|
||||
}
|
||||
@page --a {
|
||||
size: 3in;
|
||||
}
|
||||
@page 7cm {
|
||||
size: 4in;
|
||||
}
|
||||
@page 0.17 {
|
||||
size: 5in;
|
||||
}
|
||||
@page a, 123 {
|
||||
size: 6in;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
const invalidSelectorTexts = [
|
||||
"1",
|
||||
"-3",
|
||||
"--a",
|
||||
"7cm",
|
||||
"0.17",
|
||||
"a, 123",
|
||||
];
|
||||
|
||||
let styleSheets = document.styleSheets;
|
||||
for (let sheet of styleSheets) {
|
||||
for (let rule of sheet.cssRules) {
|
||||
test(function(){
|
||||
assert_not_equals(rule.type, CSSRule.PAGE_RULE,
|
||||
"no @page rule should have been parsed");
|
||||
}, "rule with invalid selector ['" + rule.selectorText + "']");
|
||||
}
|
||||
}
|
||||
|
||||
let ruleIndex = styleSheets[0].insertRule("@page{}");
|
||||
let rule = styleSheets[0].cssRules[ruleIndex];
|
||||
test(function() {
|
||||
assert_equals(rule.selectorText, "", "Initial selector text should have been empty");
|
||||
assert_equals(rule.type, CSSRule.PAGE_RULE, "unexpected rule type (not @page)");
|
||||
}, "adding a blank @page rule");
|
||||
for (let selectorText of invalidSelectorTexts){
|
||||
test(function() {
|
||||
// Clear the selector first
|
||||
rule.selectorText = "";
|
||||
rule.selectorText = selectorText;
|
||||
assert_equals(rule.selectorText, "",
|
||||
"should not be able to assign an invalid selector");
|
||||
}, "assigning invalid selector text ['" + selectorText + "']");
|
||||
}
|
||||
</script>
|
|
@ -9,4 +9,5 @@
|
|||
test_invalid_value("page", "not,valid");
|
||||
test_invalid_value("page", "123px");
|
||||
test_invalid_value("page", "calc(10%+1px)");
|
||||
test_invalid_value("page", "default");
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue