diff options
Diffstat (limited to 'testing/web-platform/tests/css/css-shapes/parsing')
11 files changed, 361 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-computed.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-computed.html new file mode 100644 index 0000000000..81bc0ccb84 --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-computed.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: getComputedStyle().shapeImageThreshold</title> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-image-threshold-property"> +<meta name="assert" content="shape-image-threshold computed value is as specified, clamped to [0,1]."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/computed-testcommon.js"></script> +</head> +<body> +<div id="target"></div> +<script> +test_computed_value("shape-image-threshold", "-7", "0"); +test_computed_value("shape-image-threshold", "0.5"); +test_computed_value("shape-image-threshold", "12.5", "1"); + +// https://github.com/w3c/csswg-drafts/issues/4102 +test_computed_value("shape-image-threshold", "-100%", "0"); +test_computed_value("shape-image-threshold", "50%", "0.5"); +test_computed_value("shape-image-threshold", "300%", "1"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-invalid.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-invalid.html new file mode 100644 index 0000000000..c0cac033fb --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-invalid.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-image-threshold with invalid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-image-threshold-property"> +<meta name="assert" content="shape-image-threshold supports only the grammar '<number>'."> +<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("shape-image-threshold", "auto"); +test_invalid_value("shape-image-threshold", "10px"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-valid.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-valid.html new file mode 100644 index 0000000000..4ed1fb9fba --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-image-threshold-valid.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-image-threshold with valid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-image-threshold-property"> +<meta name="assert" content="shape-image-threshold supports the full grammar '<number>'."> +<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("shape-image-threshold", "12.5"); +test_valid_value("shape-image-threshold", "-7"); + +// https://github.com/w3c/csswg-drafts/issues/4102 +test_valid_value("shape-image-threshold", "-100%", "-1"); +test_valid_value("shape-image-threshold", "50%", "0.5"); +test_valid_value("shape-image-threshold", "300%", "3"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-computed.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-computed.html new file mode 100644 index 0000000000..123145cbc4 --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-computed.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: getComputedStyle().shapeMargin</title> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-margin-property"> +<meta name="assert" content="shape-margin computed value is non-negative <length-percentage>."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/computed-testcommon.js"></script> +</head> +<body> +<style> + #target { + font-size: 40px; + } +</style> +<div id="target"></div> +<script> +test_computed_value("shape-margin", "calc(10px + 0.5em)", "30px"); +test_computed_value("shape-margin", "calc(10px - 0.5em)", "0px"); +test_computed_value("shape-margin", "50%"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-invalid.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-invalid.html new file mode 100644 index 0000000000..2255982ef9 --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-invalid.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-margin with invalid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-margin-property"> +<meta name="assert" content="shape-margin supports only the grammar '<length> | <percentage>'."> +<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("shape-margin", "none"); +test_invalid_value("shape-margin", "10"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-valid.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-valid.html new file mode 100644 index 0000000000..e4a3a89108 --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-margin-valid.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-margin with valid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-margin-property"> +<meta name="assert" content="shape-margin supports the full grammar '<length> | <percentage>'."> +<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("shape-margin", "0", "0px"); +test_valid_value("shape-margin", "10px"); +test_valid_value("shape-margin", "20em"); +test_valid_value("shape-margin", "37.5%"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-computed.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-computed.html new file mode 100644 index 0000000000..19d69ee738 --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-computed.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: getComputedStyle().shapeOutside</title> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-outside-property"> +<meta name="assert" content="shape-outside computed value is as specified."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/computed-testcommon.js"></script> +</head> +<body> +<style> + #target { + font-size: 40px; + } +</style> +<div id="target"></div> +<script> +// TODO: Add inset() tests + +test_computed_value("shape-outside", "circle(at 10% 20%)"); +test_computed_value("shape-outside", "circle(at calc(75% + 0px) calc(75% + 0px))", "circle(at 75% 75%)"); +test_computed_value("shape-outside", "circle(calc(10px + 0.5em) at -50% 50%) border-box", "circle(30px at -50% 50%) border-box"); +test_computed_value("shape-outside", "circle(calc(10px - 0.5em) at 50% -50%) border-box", "circle(0px at 50% -50%) border-box"); + +test_computed_value("shape-outside", "ellipse(60% closest-side at 50% 50%)"); +test_computed_value("shape-outside", "ellipse(calc(10px + 0.5em) calc(10px - 0.5em) at -50% 50%) padding-box", "ellipse(30px 0px at -50% 50%) padding-box"); +test_computed_value("shape-outside", "ellipse(calc(10px - 0.5em) calc(10px + 0.5em) at 50% -50%) border-box", "ellipse(0px 30px at 50% -50%) border-box"); + +test_computed_value("polygon(evenodd, -10px, -20px, -30px, -40px, -50px, -60px) margin-box"); +test_computed_value("polygon(10%, 20%, 30%, 40%, 50%, 60%) content-box"); +test_computed_value("polygon(calc(10px - 0.5em), 20%, 30%, 40%, 50%, calc(10px - 0.5em))", "polygon(-10px, 20%, 30%, 40%, 50%, -10px)"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-invalid-position.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-invalid-position.html new file mode 100644 index 0000000000..e61c7071f9 --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-invalid-position.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-outside with invalid position values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-values-4/#typedef-position"> +<meta name="assert" content="shape-outside positions support only the '<position>' grammar."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +</head> +<body> +<script> +// The following were supported in an earlier version of the spec. +// https://github.com/w3c/csswg-drafts/issues/2140 +test_invalid_value("shape-outside", "circle(at center left 1px)"); +test_invalid_value("shape-outside", "circle(at center top 2px)"); +test_invalid_value("shape-outside", "circle(at right 3% center)"); +test_invalid_value("shape-outside", "circle(at left 4px top)"); +test_invalid_value("shape-outside", "circle(at right 5px top)"); +test_invalid_value("shape-outside", "ellipse(at right top 5px)"); +test_invalid_value("shape-outside", "ellipse(at bottom 6% center)"); +test_invalid_value("shape-outside", "ellipse(at bottom 7% left)"); +test_invalid_value("shape-outside", "ellipse(at bottom right 8%)"); +test_invalid_value("shape-outside", "ellipse(at right 10px top)"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-invalid.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-invalid.html new file mode 100644 index 0000000000..5fe89a605e --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-invalid.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-outside with invalid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-outside-property"> +<meta name="assert" content="shape-outside supports only the grammar 'none | [ <basic-shape> || <shape-box> ] | <image>'."> +<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("shape-outside", "auto"); +test_invalid_value("shape-outside", "ray(0deg)"); + +test_invalid_value("shape-outside", "inset()"); +test_invalid_value("shape-outside", "inset(123)"); +test_invalid_value("shape-outside", "inset(1% 2% 3% 4% 5%)"); +test_invalid_value("shape-outside", "inset(round 0)"); +test_invalid_value("shape-outside", "inset(0px round)"); +test_invalid_value("shape-outside", "inset(0px round 123)"); +test_invalid_value("shape-outside", "inset(0px round 1% 2% 3% 4% 5%)"); +test_invalid_value("shape-outside", "inset(0px round / 1px)"); +test_invalid_value("shape-outside", "inset(10px round -20px)"); +test_invalid_value("shape-outside", "inset(30% round -40%)"); + +test_invalid_value("shape-outside", "circle(123)"); +test_invalid_value("shape-outside", "circle(at)"); +test_invalid_value("shape-outside", "circle(10% 20%)"); +test_invalid_value("shape-outside", "circle(-10px at 20px 30px)"); +test_invalid_value("shape-outside", "circle(-10% at 20% 30%)"); +test_invalid_value("shape-outside", "circle(1% 2% at 0% 100%)"); + +test_invalid_value("shape-outside", "ellipse(farthest-side at)"); +test_invalid_value("shape-outside", "ellipse(1% 2% top right)"); +test_invalid_value("shape-outside", "ellipse(3%)"); +test_invalid_value("shape-outside", "ellipse(3% at 100% 0%)"); +test_invalid_value("shape-outside", "ellipse(closest-side)"); +test_invalid_value("shape-outside", "ellipse(farthest-side at 100% 0%)"); +test_invalid_value("shape-outside", "ellipse(10% -20% at 30% 40%)"); +test_invalid_value("shape-outside", "ellipse(-50px 60px at 70% 80%)"); + +test_invalid_value("shape-outside", "polygon(1%)"); + +test_invalid_value("shape-outside", "border-box circle(7% at 8% 9%) border-box"); + +// <geometry-box> other than <shape-box> +test_invalid_value("shape-outside", "fill-box"); +test_invalid_value("shape-outside", "stroke-box"); +test_invalid_value("shape-outside", "view-box"); + +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-valid-position.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-valid-position.html new file mode 100644 index 0000000000..cd13c25ba3 --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-valid-position.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-outside with valid position values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-values-4/#typedef-position"> +<meta name="assert" content="shape-outside positions support the full '<position>' grammar."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +</head> +<body> +<script> +// First serialization is being returned by Firefox/Edge, second by Blink/WebKit. +test_valid_value("shape-outside", "circle(at 10%)", ["circle(at 10%)", "circle(at 10% 50%)"]); +test_valid_value("shape-outside", "circle(at 20% 30px)"); +test_valid_value("shape-outside", "circle(at 30px center)", ["circle(at 30px center)", "circle(at 30px 50%)"]); +test_valid_value("shape-outside", "circle(at 40px top)", ["circle(at 40px top)", "circle(at 40px 0%)"]); +test_valid_value("shape-outside", "circle(at bottom 10% right 20%)", ["circle(at bottom 10% right 20%)", "circle(at 80% 90%)"]); +test_valid_value("shape-outside", "circle(at bottom right)", ["circle(at bottom right)", "circle(at 100% 100%)"]); +test_valid_value("shape-outside", "circle(at center)", ["circle(at center)", "circle(at 50% 50%)"]); +test_valid_value("shape-outside", "circle(at center 50px)", ["circle(at center 50px)", "circle(at 50% 50px)"]); +test_valid_value("shape-outside", "circle(at center bottom)", ["circle(at center bottom)", "circle(at 50% 100%)"]); +test_valid_value("shape-outside", "circle(at center center)", ["circle(at center center)", "circle(at 50% 50%)"]); +test_valid_value("shape-outside", "circle(at center left)", ["circle(at center left)", "circle(at 0% 50%)"]); +test_valid_value("shape-outside", "circle(at left)", ["circle(at left)", "circle(at 0% 50%)"]); +test_valid_value("shape-outside", "circle(at left bottom)", ["circle(at left bottom)", "circle(at 0% 100%)"]); +test_valid_value("shape-outside", "circle(at left center)", ["circle(at left center)", "circle(at 0% 50%)"]); +test_valid_value("shape-outside", "circle(at right 40%)", ["circle(at right 40%)", "circle(at 100% 40%)"]); +test_valid_value("shape-outside", "circle(at right 30% top 60px)", ["circle(at right 30% top 60px)", "circle(at 70% 60px)"]); +test_valid_value("shape-outside", "circle(at top)", ["circle(at top)", "circle(at 50% 0%)"]); +test_valid_value("shape-outside", "circle(at top center)", ["circle(at top center)", "circle(at 50% 0%)"]); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-valid.html b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-valid.html new file mode 100644 index 0000000000..c48974406b --- /dev/null +++ b/testing/web-platform/tests/css/css-shapes/parsing/shape-outside-valid.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Shapes Module Level 1: parsing shape-outside with valid values</title> +<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-outside-property"> +<meta name="assert" content="shape-outside supports the full grammar 'none | [ <basic-shape> || <shape-box> ] | <image>'."> +<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("shape-outside", "none"); + +// <basic-shape> +test_valid_value("shape-outside", "inset(100%)"); +test_valid_value("shape-outside", "inset(0 1px)", "inset(0px 1px)"); +test_valid_value("shape-outside", "inset(0px 1px 2%)"); +test_valid_value("shape-outside", "inset(0px 1px 2% 3em)"); +test_valid_value("shape-outside", "inset(0px round 100%)"); +test_valid_value("shape-outside", "inset(0px round 0 1px)", "inset(0px round 0px 1px)"); +test_valid_value("shape-outside", "inset(0px round 0px 1px 2%)"); +test_valid_value("shape-outside", "inset(0px round 0px 1px 2% 3em)"); +test_valid_value("shape-outside", "inset(10px round 20% / 0px 1px 2% 3em)"); + +test_valid_value("shape-outside", "circle()", "circle(at 50% 50%)"); +test_valid_value("shape-outside", "circle(1px)", "circle(1px at 50% 50%)"); +test_valid_value("shape-outside", "circle(closest-side)", "circle(at 50% 50%)"); +test_valid_value("shape-outside", "circle(at 10% 20%)"); +test_valid_value("shape-outside", "circle(farthest-side at center top)", "circle(farthest-side at 50% 0%)"); +test_valid_value("shape-outside", "circle(4% at top right)", "circle(4% at 100% 0%)"); + +test_valid_value("shape-outside", "ellipse()", "ellipse(at 50% 50%)"); +test_valid_value("shape-outside", "ellipse(3% 2%)", "ellipse(3% 2% at 50% 50%)"); +test_valid_value("shape-outside", "ellipse(closest-side 1px)", "ellipse(closest-side 1px at 50% 50%)"); +test_valid_value("shape-outside", "ellipse(10% closest-side)", "ellipse(10% closest-side at 50% 50%)"); +test_valid_value("shape-outside", "ellipse(closest-side closest-side at 60% 70%)", "ellipse(at 60% 70%)"); +test_valid_value("shape-outside", "ellipse(at 10% 20%)"); +test_valid_value("shape-outside", "ellipse(farthest-side 4% at bottom left)", "ellipse(farthest-side 4% at 0% 100%)"); + +test_valid_value("shape-outside", "polygon(1% 2%)"); +test_valid_value("shape-outside", "polygon(nonzero, 1px 2px, 3em 4em)", "polygon(1px 2px, 3em 4em)"); +test_valid_value("shape-outside", "polygon(evenodd, 1px 2px, 3em 4em, 5pt 6%)"); + +// <shape-box> +test_valid_value("shape-outside", "border-box"); +test_valid_value("shape-outside", "padding-box"); +test_valid_value("shape-outside", "content-box"); +test_valid_value("shape-outside", "margin-box"); + +// basic-shape> <shape-box> +test_valid_value("shape-outside", "circle(7% at 8% 9%) border-box"); + +// <shape-box> <basic-shape> +test_valid_value("shape-outside", "padding-box inset(10em)", "inset(10em) padding-box"); +test_valid_value("shape-outside", "border-box circle(7% at 8% 9%)", "circle(7% at 8% 9%) border-box"); +test_valid_value("shape-outside", "margin-box ellipse(at 1em 2em)", ["ellipse(at 1em 2em) margin-box", "ellipse(at 1em 2em)"]); +test_valid_value("shape-outside", "content-box polygon(1% 2%)", "polygon(1% 2%) content-box"); + +// <image> +// Spec is silent about url serialization. +// Blink, Edge, Firefox add quotes. WebKit removes quotes. +test_valid_value("shape-outside", "url(https://example.com/)", ["url(https://example.com/)", "url(\"https://example.com/\")"]); +test_valid_value("shape-outside", "url(\"https://example.com/\")", ["url(https://example.com/)", "url(\"https://example.com/\")"]); +test_valid_value("shape-outside", "cross-fade(url(\"https://example.com/\"), green)"); +test_valid_value("shape-outside", "linear-gradient(yellow, blue)"); +</script> +</body> +</html> |