diff options
Diffstat (limited to 'testing/web-platform/tests/css/css-cascade/parsing')
4 files changed, 148 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-cascade/parsing/all-invalid.html b/testing/web-platform/tests/css/css-cascade/parsing/all-invalid.html new file mode 100644 index 0000000000..4a1d045ecc --- /dev/null +++ b/testing/web-platform/tests/css/css-cascade/parsing/all-invalid.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Cascading and Inheritance Level 3: parsing all with invalid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-cascade-3/#propdef-all"> +<meta name="assert" content="all supports only the grammar 'initial | inherit | unset'."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +</head> +<body> +<script> +test_invalid_value("all", "auto"); +test_invalid_value("all", "none"); +test_invalid_value("all", "filter"); +test_invalid_value("all", "unset inherit"); +test_invalid_value("all", "inherit initial"); +test_invalid_value("all", "initial unset"); +test_invalid_value("all", "opacity transform"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-cascade/parsing/all-valid.html b/testing/web-platform/tests/css/css-cascade/parsing/all-valid.html new file mode 100644 index 0000000000..3a9e5922de --- /dev/null +++ b/testing/web-platform/tests/css/css-cascade/parsing/all-valid.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Cascading and Inheritance Level 3: parsing all with valid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-cascade-3/#propdef-all"> +<meta name="assert" content="all supports the full grammar 'initial | inherit | unset'."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +</head> +<body> +<script> +test_valid_value("all", "initial"); +test_valid_value("all", "inherit"); +test_valid_value("all", "unset"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-cascade/parsing/layer-import-parsing.html b/testing/web-platform/tests/css/css-cascade/parsing/layer-import-parsing.html new file mode 100644 index 0000000000..f879ba8897 --- /dev/null +++ b/testing/web-platform/tests/css/css-cascade/parsing/layer-import-parsing.html @@ -0,0 +1,79 @@ +<!doctype html> +<meta charset="utf-8"> +<title>@import rule with layer parsing / serialization</title> +<link rel="author" href="mailto:xiaochengh@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#at-import"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + function setupSheet(rule) { + const style = document.createElement("style"); + document.head.append(style); + const {sheet} = style; + const {cssRules} = sheet; + + assert_equals(cssRules.length, 0, "Sheet should have no rules"); + sheet.insertRule(rule); + assert_equals(cssRules.length, 1, "Sheet should have 1 rule"); + + return {sheet, cssRules}; + } + + function test_valid_layer_import(rule, serialized) { + if (serialized === undefined) + serialized = rule; + + test(function() { + const {sheet, cssRules} = setupSheet(rule); + + const serialization = cssRules[0].cssText; + assert_equals(serialization, serialized, 'serialization should be canonical'); + + const media = cssRules[0].media; + assert_equals(media.length, 0, 'layer() should be valid'); + + sheet.deleteRule(0); + assert_equals(cssRules.length, 0, 'Sheet should have no rule'); + sheet.insertRule(serialization); + assert_equals(cssRules.length, 1, 'Sheet should have 1 rule'); + + assert_equals(cssRules[0].cssText, serialization, 'serialization should round-trip'); + }, rule + ' should be a valid layered import rule'); + } + + function test_invalid_layer_import(rule) { + test(function() { + const {sheet, cssRules} = setupSheet(rule); + + const media = cssRules[0].media; + assert_not_equals(media.length, 0, + 'invalid layer declaration should be parsed as <general-enclosed> media query'); + + sheet.deleteRule(0); + assert_equals(cssRules.length, 0, 'Sheet should have no rule'); + }, rule + ' should still be a valid import rule with an invalid layer declaration'); + } + + test_valid_layer_import('@import url("nonexist.css") layer;'); + test_valid_layer_import('@import url("nonexist.css") layer(A);'); + test_valid_layer_import('@import url("nonexist.css") layer(A.B);'); + + test_valid_layer_import('@import url(nonexist.css) layer;', + '@import url("nonexist.css") layer;'); + test_valid_layer_import('@import url(nonexist.css) layer(A);', + '@import url("nonexist.css") layer(A);'); + test_valid_layer_import('@import url(nonexist.css) layer(A.B);', + '@import url("nonexist.css") layer(A.B);'); + + test_valid_layer_import('@import "nonexist.css" layer;', + '@import url("nonexist.css") layer;'); + test_valid_layer_import('@import "nonexist.css" layer(A);', + '@import url("nonexist.css") layer(A);'); + test_valid_layer_import('@import "nonexist.css" layer(A.B);', + '@import url("nonexist.css") layer(A.B);'); + + test_invalid_layer_import('@import url("nonexist.css") layer();'); + test_invalid_layer_import('@import url("nonexist.css") layer(A B);'); + test_invalid_layer_import('@import url("nonexist.css") layer(A . B);'); + test_invalid_layer_import('@import url("nonexist.css") layer(A, B, C);'); +</script> diff --git a/testing/web-platform/tests/css/css-cascade/parsing/layer.html b/testing/web-platform/tests/css/css-cascade/parsing/layer.html new file mode 100644 index 0000000000..3bfc863ede --- /dev/null +++ b/testing/web-platform/tests/css/css-cascade/parsing/layer.html @@ -0,0 +1,25 @@ +<!doctype html> +<meta charset="utf-8"> +<title>@layer rule parsing / serialization</title> +<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> +<link rel="author" title="Mozilla" href="https://mozilla.org"> +<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layering"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_rule("@layer A;"); + test_valid_rule("@layer A, B, C;"); + test_valid_rule("@layer A.A;"); + test_valid_rule("@layer A, B.C.D, C;"); + + test_invalid_rule("@layer;"); + test_invalid_rule("@layer A . A;"); + + test_valid_rule("@layer {\n}"); + test_valid_rule("@layer A {\n}"); + test_valid_rule("@layer A.B {\n}"); + test_invalid_rule("@layer A . B {\n}"); + + test_invalid_rule("@layer A, B, C {\n}"); +</script> |