summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-page/parsing
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-page/parsing
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-page/parsing')
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/margin-rules-001.html51
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/nested-rules-001.html66
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/page-computed.html15
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/page-invalid.html13
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/page-orientation-computed.tentative.html12
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/page-orientation-invalid.tentative.html15
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/page-valid.html11
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/size-001.html63
-rw-r--r--testing/web-platform/tests/css/css-page/parsing/size-invalid.html25
9 files changed, 271 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-page/parsing/margin-rules-001.html b/testing/web-platform/tests/css/css-page/parsing/margin-rules-001.html
new file mode 100644
index 0000000000..c4270fe606
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/margin-rules-001.html
@@ -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>
diff --git a/testing/web-platform/tests/css/css-page/parsing/nested-rules-001.html b/testing/web-platform/tests/css/css-page/parsing/nested-rules-001.html
new file mode 100644
index 0000000000..23c8eb0894
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/nested-rules-001.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<link rel="help" href="https://drafts.csswg.org/css-page-3/#syntax-page-selector">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+@page p0{
+ @page a{ size: letter; }
+}
+@page p1{
+ @namespace svg url(http://www.w3.org/2000/svg);
+}
+@page p2{
+ @font-face{}
+}
+@page p3{
+ @font-feature-values font one{}
+}
+@page p4{
+ @font-palette-values --alternate{}
+}
+@page p5{
+ @counter-style x{}
+}
+@page p6{
+ @keyframes y{}
+}
+@page p7{
+ @property z{
+ syntax: "<color>";
+ inherits: false;
+ initial-value: #c0ffee;
+ }
+}
+@page p8{
+ @import url("style.css") screen;
+}
+</style>
+
+<script>
+'use strict';
+test(t => {
+ assert_equals(document.styleSheets.length, 1);
+ let styleSheet = document.styleSheets[0];
+ const ruleTypes = [
+ "page",
+ "namespace",
+ "font-face",
+ "font-feature-values",
+ "font-palette-values",
+ "counter-style",
+ "keyframes",
+ "property",
+ "import"
+ ];
+ assert_equals(styleSheet.rules.length, ruleTypes.length);
+ for(let i = 0; i < styleSheet.rules.length; i++){
+ // Just test that this is the right rule first.
+ assert_equals(styleSheet.rules[i].selectorText, "p" + i,
+ "@page p" + i + " was not parsed at all");
+ // Test that the nested rule was not valid.
+ assert_equals(styleSheet.rules[i].cssText, "@page p" + i + " { }",
+ "@" + ruleTypes[i] + " rules should not be allowed in @page rules");
+ }
+}, "nested-rules-001");
+</script>
diff --git a/testing/web-platform/tests/css/css-page/parsing/page-computed.html b/testing/web-platform/tests/css/css-page/parsing/page-computed.html
new file mode 100644
index 0000000000..0accba0574
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/page-computed.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
+<link rel="help" href="https://www.w3.org/TR/css-page-3/#using-named-pages">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/computed-testcommon.js"></script>
+<div id="target"></div>
+<script>
+ test_computed_value("page", "auto");
+ test_computed_value("page", "AUTO", "auto");
+ test_computed_value("page", "blablabla");
+ test_computed_value("page", "BLABLABLA");
+ test_computed_value("page", "table");
+ test_computed_value("page", "TABLE");
+</script>
diff --git a/testing/web-platform/tests/css/css-page/parsing/page-invalid.html b/testing/web-platform/tests/css/css-page/parsing/page-invalid.html
new file mode 100644
index 0000000000..2c373a7d7f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/page-invalid.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
+<link rel="help" href="https://www.w3.org/TR/css-page-3/#using-named-pages">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+<script>
+ test_invalid_value("page", "not valid");
+ test_invalid_value("page", "not,valid");
+ test_invalid_value("page", "123px");
+ test_invalid_value("page", "calc(10%+1px)");
+ test_invalid_value("page", "default");
+</script>
diff --git a/testing/web-platform/tests/css/css-page/parsing/page-orientation-computed.tentative.html b/testing/web-platform/tests/css/css-page/parsing/page-orientation-computed.tentative.html
new file mode 100644
index 0000000000..c9dd155f8c
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/page-orientation-computed.tentative.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-page-3/#page-orientation-prop">
+<div id="elm" style="page-orientation:rotate-right;"></div>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ test(()=> {
+ assert_equals(getComputedStyle(elm).pageOrientation, "");
+ }, "page-orientation is not a property (only a descriptor)");
+</script>
+
diff --git a/testing/web-platform/tests/css/css-page/parsing/page-orientation-invalid.tentative.html b/testing/web-platform/tests/css/css-page/parsing/page-orientation-invalid.tentative.html
new file mode 100644
index 0000000000..e89b1f0917
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/page-orientation-invalid.tentative.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-page-3/#page-orientation-prop">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+<script>
+ // page-orientation is not a property. test_invalid_value() tries to specify
+ // it on an element, and this should fail, even when using a valid
+ // value. page-orientation is only valid as a descriptor inside an @page rule.
+ test_invalid_value("page-orientation", "hotpink");
+ test_invalid_value("page-orientation", "upright");
+ test_invalid_value("page-orientation", "rotate-left");
+ test_invalid_value("page-orientation", "rotate-right");
+</script>
diff --git a/testing/web-platform/tests/css/css-page/parsing/page-valid.html b/testing/web-platform/tests/css/css-page/parsing/page-valid.html
new file mode 100644
index 0000000000..a4c31f5766
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/page-valid.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
+<link rel="help" href="https://www.w3.org/TR/css-page-3/#using-named-pages">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+<script>
+ test_valid_value("page", "auto");
+ test_valid_value("page", "table");
+ test_valid_value("page", "xyzabc");
+</script>
diff --git a/testing/web-platform/tests/css/css-page/parsing/size-001.html b/testing/web-platform/tests/css/css-page/parsing/size-001.html
new file mode 100644
index 0000000000..885a7b8530
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/size-001.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<link rel="help" href="https://drafts.csswg.org/css-page-3/#page-size-prop">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+@page{
+ size: 640px 480px;
+}
+@page{
+ size: 8.5in 11in;
+}
+@page{
+ size: A4;
+}
+@page{
+ size: 3in 10in;
+}
+@page{
+ size: jis-B5;
+}
+@page{
+ size: auto;
+}
+@page{
+ size: landscape;
+}
+@page{
+ size: letter portrait;
+}
+@page{
+ size: legal landscape;
+}
+</style>
+
+<script>
+'use strict';
+
+const expectedSizes = [
+ "640px 480px",
+ "8.5in 11in",
+ "a4",
+ "3in 10in",
+ "jis-b5",
+ "auto",
+ "landscape",
+ "letter",
+ "legal landscape"
+];
+const sizePrefix = "size: ";
+
+test(t => {
+ assert_equals(document.styleSheets.length, 1);
+ let styleSheet = document.styleSheets[0];
+ assert_equals(styleSheet.rules.length, expectedSizes.length);
+ for(let i = 0; i < expectedSizes.length; i++){
+ let cssText = styleSheet.cssRules[i].style.cssText;
+ assert_true(cssText.startsWith(sizePrefix));
+ cssText = cssText.slice(sizePrefix.length);
+ assert_equals(cssText, expectedSizes[i] + ";", "for rule " + i);
+ }
+}, "size-001");
+</script>
diff --git a/testing/web-platform/tests/css/css-page/parsing/size-invalid.html b/testing/web-platform/tests/css/css-page/parsing/size-invalid.html
new file mode 100644
index 0000000000..6e7c4a222d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-page/parsing/size-invalid.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m">
+<link rel="help" href="https://drafts.csswg.org/css-page-3/#page-orientation-prop">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+<script>
+ // size is not a property, but a descriptor. test_invalid_value() tries to specify
+ // it on an element, and this should fail, even when using a valid
+ // value. size is only valid as a descriptor inside an @page rule.
+ test_invalid_value("size", "initial");
+ test_invalid_value("size", "inherit");
+ test_invalid_value("size", "revert");
+ test_invalid_value("size", "revert-layer");
+ test_invalid_value("size", "unset");
+ test_invalid_value("size", "640px 480px");
+ test_invalid_value("size", "8.5in 11in");
+ test_invalid_value("size", "a4");
+ test_invalid_value("size", "3in 10in");
+ test_invalid_value("size", "jis-b5");
+ test_invalid_value("size", "auto");
+ test_invalid_value("size", "landscape");
+ test_invalid_value("size", "letter");
+ test_invalid_value("size", "legal landscape");
+</script>