mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-30 21:28:59 +00:00
Tests: Import CSSMarginRule tests
This commit is contained in:
parent
2903defcfc
commit
101f6b1d7e
Notes:
github-actions[bot]
2025-05-16 10:02:48 +00:00
Author: https://github.com/AtkinsSJ
Commit: 101f6b1d7e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4746
4 changed files with 178 additions and 0 deletions
|
@ -0,0 +1,39 @@
|
||||||
|
Harness status: OK
|
||||||
|
|
||||||
|
Found 33 tests
|
||||||
|
|
||||||
|
17 Pass
|
||||||
|
16 Fail
|
||||||
|
Pass margin-rules-001
|
||||||
|
Pass @top-left-corner{ } should be an invalid rule
|
||||||
|
Pass @top-left{ } should be an invalid rule
|
||||||
|
Pass @top-center{ } should be an invalid rule
|
||||||
|
Pass @top-right{ } should be an invalid rule
|
||||||
|
Pass @top-right-corner{ } should be an invalid rule
|
||||||
|
Pass @bottom-left-corner{ } should be an invalid rule
|
||||||
|
Pass @bottom-left{ } should be an invalid rule
|
||||||
|
Pass @bottom-center{ } should be an invalid rule
|
||||||
|
Pass @bottom-right{ } should be an invalid rule
|
||||||
|
Pass @bottom-right-corner{ } should be an invalid rule
|
||||||
|
Pass @left-top{ } should be an invalid rule
|
||||||
|
Pass @left-middle{ } should be an invalid rule
|
||||||
|
Pass @left-bottom{ } should be an invalid rule
|
||||||
|
Pass @right-top{ } should be an invalid rule
|
||||||
|
Pass @right-middle{ } should be an invalid rule
|
||||||
|
Pass @right-bottom{ } should be an invalid rule
|
||||||
|
Fail @page { @top-left-corner { } } should be a valid rule
|
||||||
|
Fail @page { @top-left { } } should be a valid rule
|
||||||
|
Fail @page { @top-center { } } should be a valid rule
|
||||||
|
Fail @page { @top-right { } } should be a valid rule
|
||||||
|
Fail @page { @top-right-corner { } } should be a valid rule
|
||||||
|
Fail @page { @bottom-left-corner { } } should be a valid rule
|
||||||
|
Fail @page { @bottom-left { } } should be a valid rule
|
||||||
|
Fail @page { @bottom-center { } } should be a valid rule
|
||||||
|
Fail @page { @bottom-right { } } should be a valid rule
|
||||||
|
Fail @page { @bottom-right-corner { } } should be a valid rule
|
||||||
|
Fail @page { @left-top { } } should be a valid rule
|
||||||
|
Fail @page { @left-middle { } } should be a valid rule
|
||||||
|
Fail @page { @left-bottom { } } should be a valid rule
|
||||||
|
Fail @page { @right-top { } } should be a valid rule
|
||||||
|
Fail @page { @right-middle { } } should be a valid rule
|
||||||
|
Fail @page { @right-bottom { } } should be a valid rule
|
|
@ -0,0 +1,9 @@
|
||||||
|
Harness status: OK
|
||||||
|
|
||||||
|
Found 4 tests
|
||||||
|
|
||||||
|
4 Fail
|
||||||
|
Fail margin rule without any preceding @page properties
|
||||||
|
Fail margin rule followed by @page properties
|
||||||
|
Fail margin rule preceded by @page properties
|
||||||
|
Fail margin rules with @page properties between
|
|
@ -0,0 +1,51 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel="author" title="Mozilla" href="https://mozilla.org">
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-page-3/#margin-at-rules">
|
||||||
|
<script src="../../../resources/testharness.js"></script>
|
||||||
|
<script src="../../../resources/testharnessreport.js"></script>
|
||||||
|
<script src="../../../css/support/parsing-testcommon.js"></script>
|
||||||
|
<style>
|
||||||
|
#test{ }
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
test(t => {
|
||||||
|
const ruleTypes = [
|
||||||
|
"@top-left-corner",
|
||||||
|
"@top-left",
|
||||||
|
"@top-center",
|
||||||
|
"@top-right",
|
||||||
|
"@top-right-corner",
|
||||||
|
"@bottom-left-corner",
|
||||||
|
"@bottom-left",
|
||||||
|
"@bottom-center",
|
||||||
|
"@bottom-right",
|
||||||
|
"@bottom-right-corner",
|
||||||
|
"@left-top",
|
||||||
|
"@left-middle",
|
||||||
|
"@left-bottom",
|
||||||
|
"@right-top",
|
||||||
|
"@right-middle",
|
||||||
|
"@right-bottom"
|
||||||
|
];
|
||||||
|
// Test that margin-rules are not valid at a top-level.
|
||||||
|
for(let t in ruleTypes){
|
||||||
|
test_invalid_rule(ruleTypes[t] + "{ }");
|
||||||
|
}
|
||||||
|
// Test that margin-rules are not valid in style rules.
|
||||||
|
assert_equals(document.styleSheets.length, 1);
|
||||||
|
let styleSheet = document.styleSheets[0];
|
||||||
|
assert_equals(styleSheet.rules.length, 1);
|
||||||
|
let rule = styleSheet.rules[0];
|
||||||
|
for(let t in ruleTypes){
|
||||||
|
assert_throws_dom(
|
||||||
|
DOMException.SYNTAX_ERR,
|
||||||
|
() => rule.insertRule(ruleTypes[t] + "{ }"),
|
||||||
|
"Should not be able to add " + ruleTypes[t] + " to a style rule");
|
||||||
|
}
|
||||||
|
// Test that margin-rules are valid inside page-rules.
|
||||||
|
for(let t in ruleTypes){
|
||||||
|
test_valid_rule("@page { " + ruleTypes[t] + " { } }");
|
||||||
|
}
|
||||||
|
}, "margin-rules-001");
|
||||||
|
</script>
|
|
@ -0,0 +1,79 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-page-3/#margin-at-rules">
|
||||||
|
<meta name="assert" content="Test parsing of margin rule with/without preceding/following @page properties">
|
||||||
|
<style id="nothing">
|
||||||
|
@page {
|
||||||
|
@top-center {
|
||||||
|
content: "PASS";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style id="propertiesAfter">
|
||||||
|
@page {
|
||||||
|
@top-center {
|
||||||
|
content: "PASS";
|
||||||
|
}
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style id="propertiesBefore">
|
||||||
|
@page {
|
||||||
|
padding-left: 10px;
|
||||||
|
@top-center {
|
||||||
|
content: "PASS";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style id="propertiesBetween">
|
||||||
|
@page {
|
||||||
|
padding-left: 666px;
|
||||||
|
@top-left {
|
||||||
|
content: "left";
|
||||||
|
}
|
||||||
|
padding-left: 10px;
|
||||||
|
@top-right {
|
||||||
|
content: "right";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="../../../resources/testharness.js"></script>
|
||||||
|
<script src="../../../resources/testharnessreport.js"></script>
|
||||||
|
<script>
|
||||||
|
test(()=>{
|
||||||
|
assert_equals(nothing.sheet.rules.length, 1);
|
||||||
|
let pagerule = nothing.sheet.rules[0];
|
||||||
|
assert_equals(pagerule.cssRules.length, 1);
|
||||||
|
let marginrule = pagerule.cssRules[0];
|
||||||
|
assert_equals(marginrule.style.content, "\"PASS\"");
|
||||||
|
}, "margin rule without any preceding @page properties");
|
||||||
|
|
||||||
|
test(()=>{
|
||||||
|
assert_equals(propertiesAfter.sheet.rules.length, 1);
|
||||||
|
let pagerule = propertiesAfter.sheet.rules[0];
|
||||||
|
assert_equals(pagerule.cssRules.length, 1);
|
||||||
|
let marginrule = pagerule.cssRules[0];
|
||||||
|
assert_equals(marginrule.style.content, "\"PASS\"");
|
||||||
|
assert_equals(pagerule.style.paddingLeft, "10px");
|
||||||
|
}, "margin rule followed by @page properties");
|
||||||
|
|
||||||
|
test(()=>{
|
||||||
|
assert_equals(propertiesAfter.sheet.rules.length, 1);
|
||||||
|
let pagerule = propertiesAfter.sheet.rules[0];
|
||||||
|
assert_equals(pagerule.cssRules.length, 1);
|
||||||
|
let marginrule = pagerule.cssRules[0];
|
||||||
|
assert_equals(marginrule.style.content, "\"PASS\"");
|
||||||
|
assert_equals(pagerule.style.paddingLeft, "10px");
|
||||||
|
}, "margin rule preceded by @page properties");
|
||||||
|
|
||||||
|
test(()=>{
|
||||||
|
assert_equals(propertiesBetween.sheet.rules.length, 1);
|
||||||
|
let pagerule = propertiesBetween.sheet.rules[0];
|
||||||
|
assert_equals(pagerule.cssRules.length, 2);
|
||||||
|
let marginrule = pagerule.cssRules[0];
|
||||||
|
assert_equals(marginrule.style.content, "\"left\"");
|
||||||
|
marginrule = pagerule.cssRules[1];
|
||||||
|
assert_equals(marginrule.style.content, "\"right\"");
|
||||||
|
assert_equals(pagerule.style.paddingLeft, "10px");
|
||||||
|
}, "margin rules with @page properties between");
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue