diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-page/page-rule-declarations-004.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-page/page-rule-declarations-004.html')
-rw-r--r-- | testing/web-platform/tests/css/css-page/page-rule-declarations-004.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-page/page-rule-declarations-004.html b/testing/web-platform/tests/css/css-page/page-rule-declarations-004.html new file mode 100644 index 0000000000..94d0f8291d --- /dev/null +++ b/testing/web-platform/tests/css/css-page/page-rule-declarations-004.html @@ -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> |