Truly independent web browser
LibWeb: Import optional clamp bound coverage
Andreas Klingb7dc7e54cbd4
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-color-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-color-computed.txtnew file mode 100644index 00000000000..043dcd840f4--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-color-computed.txt@@ -0,0 +1,21 @@+Harness status: OK++Found 15 tests++6 Pass+9 Fail+Pass Property color value 'rgb(clamp(10, 20, 30) 0 0)'+Fail Property color value 'rgb(clamp(none, 30, 33) 0 0)'+Fail Property color value 'rgb(clamp(none, 33, 30) 0 0)'+Fail Property color value 'rgb(clamp(30, 33, none) 0 0)'+Fail Property color value 'rgb(clamp(33, 30, none) 0 0)'+Fail Property color value 'rgb(clamp(none, 30, none) 0 0)'+Pass Property color value 'rgb(from red clamp(r, 30, 300) g b)'+Pass Property color value 'rgb(from red clamp(30, 300, r) g b)'+Pass Property color value 'rgb(from red clamp(3, r, 300) g b)'+Pass Property color value 'rgb(from red clamp(3, r, r + 30) g b)'+Pass Property color value 'rgb(from red clamp(r - 30, r, 300) g b)'+Fail Property color value 'rgb(from red clamp(3, r, none) g b)'+Fail Property color value 'rgb(from red clamp(r, 30, none) g b)'+Fail Property color value 'rgb(from red clamp(none, r, 300) g b)'+Fail Property color value 'rgb(from red clamp(none, r, r + 30) g b)'\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-integer-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-integer-computed.txtnew file mode 100644index 00000000000..d63802d6f8d--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-integer-computed.txt@@ -0,0 +1,12 @@+Harness status: OK++Found 6 tests++1 Pass+5 Fail+Pass Property z-index value 'clamp(10, 20, 30)'+Fail Property z-index value 'clamp(none, 30, 33)'+Fail Property z-index value 'clamp(none, 33, 30)'+Fail Property z-index value 'clamp(30, 33, none)'+Fail Property z-index value 'clamp(33, 30, none)'+Fail Property z-index value 'clamp(none, 30, none)'\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-length-serialize.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-length-serialize.txtnew file mode 100644index 00000000000..e0bb4992a92--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-length-serialize.txt@@ -0,0 +1,56 @@+Harness status: OK++Found 50 tests++44 Pass+6 Fail+Pass e.style['margin-top'] = "clamp(1px, 2px, 3px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(1px, 2px, 3px))" should set the property value+Pass e.style['margin-top'] = "clamp(1px, 2px, clamp(2px, 3px, 4px))" should set the property value+Pass e.style['margin-top'] = "calc(clamp(1px, 2px, clamp(2px, 3px, 4px)))" should set the property value+Pass e.style['margin-top'] = "clamp(10px, 5px, 30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(10px, 5px, 30px))" should set the property value+Pass e.style['margin-top'] = "clamp(10px, 35px, 30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(10px, 35px, 30px))" should set the property value+Pass e.style['margin-top'] = "clamp(10px, 35px , 30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(10px, 35px , 30px))" should set the property value+Pass e.style['margin-top'] = "clamp(10px, 35px /*foo*/, 30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(10px, 35px /*foo*/, 30px))" should set the property value+Pass e.style['margin-top'] = "clamp(10px /* foo */ , 35px, 30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(10px /* foo */ , 35px, 30px))" should set the property value+Pass e.style['margin-top'] = "clamp(10px , 35px, 30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(10px , 35px, 30px))" should set the property value+Pass e.style['margin-top'] = "clamp(30px, 100px, 20px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(30px, 100px, 20px))" should set the property value+Pass e.style['margin-top'] = "clamp(-30px, -20px, -10px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(-30px, -20px, -10px))" should set the property value+Pass e.style['margin-top'] = "clamp(-30px, -100px, -10px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(-30px, -100px, -10px))" should set the property value+Pass e.style['margin-top'] = "clamp(-30px, 100px, -10px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(-30px, 100px, -10px))" should set the property value+Pass e.style['margin-top'] = "clamp(-10px, 100px, -30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(-10px, 100px, -30px))" should set the property value+Pass e.style['margin-top'] = "clamp(-10px, -100px, -30px)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(-10px, -100px, -30px))" should set the property value+Pass e.style['margin-top'] = "calc(0px + clamp(10px, 20px, 30px))" should set the property value+Pass e.style['margin-top'] = "calc(calc(0px + clamp(10px, 20px, 30px)))" should set the property value+Pass e.style['margin-top'] = "calc(0px - clamp(10px, 20px, 30px))" should set the property value+Pass e.style['margin-top'] = "calc(calc(0px - clamp(10px, 20px, 30px)))" should set the property value+Pass e.style['margin-top'] = "calc(0px + clamp(30px, 100px, 20px))" should set the property value+Pass e.style['margin-top'] = "calc(calc(0px + clamp(30px, 100px, 20px)))" should set the property value+Pass e.style['margin-top'] = "calc(0px - clamp(30px, 100px, 20px))" should set the property value+Pass e.style['margin-top'] = "calc(calc(0px - clamp(30px, 100px, 20px)))" should set the property value+Pass e.style['margin-top'] = "clamp(1px, 1em, 1vh)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(1px, 1em, 1vh))" should set the property value+Pass e.style['margin-top'] = "clamp(-18px, 3vw, -3vw)" should set the property value+Pass e.style['margin-top'] = "calc(clamp(-18px, 3vw, -3vw))" should set the property value+Pass e.style['margin-top'] = "calc(0px + clamp(1px, 1em, 1vh))" should set the property value+Pass e.style['margin-top'] = "calc(calc(0px + clamp(1px, 1em, 1vh)))" should set the property value+Pass e.style['margin-top'] = "calc(0px - clamp(1px, 1em, 1vh))" should set the property value+Pass e.style['margin-top'] = "calc(calc(0px - clamp(1px, 1em, 1vh)))" should set the property value+Fail e.style['margin-top'] = "clamp(none, 33px, 30px)" should set the property value+Fail e.style['margin-top'] = "calc(clamp(none, 33px, 30px))" should set the property value+Fail e.style['margin-top'] = "clamp(33px, 30px, none)" should set the property value+Fail e.style['margin-top'] = "calc(clamp(33px, 30px, none))" should set the property value+Fail e.style['margin-top'] = "clamp(none, 30px, none)" should set the property value+Fail e.style['margin-top'] = "calc(clamp(none, 30px, none))" should set the property value\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-none-whitespace.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-none-whitespace.txtnew file mode 100644index 00000000000..5591530e5dc--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/clamp-none-whitespace.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail clamp() accepts whitespace between a 'none' min argument and the following comma+Fail clamp() accepts whitespace after a trailing 'none' max argument+Fail clamp() accepts whitespace around 'none' for both bounds\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-color-computed.html b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-color-computed.htmlnew file mode 100644index 00000000000..d08ce81330f--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-color-computed.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-values/#funcdef-clamp">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../support/computed-testcommon.js"></script>+<div id="target"></div>+<script>+test_computed_value('color', 'rgb(clamp(10, 20, 30) 0 0)', 'rgb(20, 0, 0)');+test_computed_value('color', 'rgb(clamp(none, 30, 33) 0 0)', 'rgb(30, 0, 0)');+test_computed_value('color', 'rgb(clamp(none, 33, 30) 0 0)', 'rgb(30, 0, 0)');+test_computed_value('color', 'rgb(clamp(30, 33, none) 0 0)', 'rgb(33, 0, 0)');+test_computed_value('color', 'rgb(clamp(33, 30, none) 0 0)', 'rgb(33, 0, 0)');+test_computed_value('color', 'rgb(clamp(none, 30, none) 0 0)', 'rgb(30, 0, 0)');++// Relative colors+test_computed_value('color', 'rgb(from red clamp(r, 30, 300) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(30, 300, r) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(3, r, 300) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(3, r, r + 30) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(r - 30, r, 300) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(3, r, none) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(r, 30, none) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(none, r, 300) g b)', 'color(srgb 1 0 0)');+test_computed_value('color', 'rgb(from red clamp(none, r, r + 30) g b)', 'color(srgb 1 0 0)');+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-integer-computed.html b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-integer-computed.htmlnew file mode 100644index 00000000000..1016c957179--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-integer-computed.html@@ -0,0 +1,14 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-values/#funcdef-clamp">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../support/computed-testcommon.js"></script>+<div id="target"></div>+<script>+test_computed_value('z-index', 'clamp(10, 20, 30)', '20');+test_computed_value('z-index', 'clamp(none, 30, 33)', '30');+test_computed_value('z-index', 'clamp(none, 33, 30)', '30');+test_computed_value('z-index', 'clamp(30, 33, none)', '33');+test_computed_value('z-index', 'clamp(33, 30, none)', '33');+test_computed_value('z-index', 'clamp(none, 30, none)', '30');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-length-serialize.html b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-length-serialize.htmlnew file mode 100644index 00000000000..4c0265be44c--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-length-serialize.html@@ -0,0 +1,51 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">+<link rel="author" title="Xiaocheng Hu" href="mailto:[email protected]">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../support/parsing-testcommon.js"></script>+<script>+function test_valid_length(value, expected) {+ test_valid_value('margin-top', value, expected);+ test_valid_value('margin-top', `calc(${value})`, expected);+}++test_valid_length('clamp(1px, 2px, 3px)', 'calc(2px)');+test_valid_length('clamp(1px, 2px, clamp(2px, 3px, 4px))', 'calc(2px)');++test_valid_length('clamp(10px, 5px, 30px)', 'calc(10px)');+test_valid_length('clamp(10px, 35px, 30px)', 'calc(30px)');+test_valid_length('clamp(10px, 35px , 30px)', 'calc(30px)');+test_valid_length('clamp(10px, 35px /*foo*/, 30px)', 'calc(30px)');+test_valid_length('clamp(10px /* foo */ , 35px, 30px)', 'calc(30px)');+test_valid_length('clamp(10px , 35px, 30px)', 'calc(30px)');++// clamp(MIN, VAL, MAX) is identical to max(MIN, min(VAL, MAX)),+// so MIN wins over MAX if they are in the wrong order.+test_valid_length('clamp(30px, 100px, 20px)', 'calc(30px)');++// also test with negative values+test_valid_length('clamp(-30px, -20px, -10px)', 'calc(-20px)');+test_valid_length('clamp(-30px, -100px, -10px)', 'calc(-30px)');+test_valid_length('clamp(-30px, 100px, -10px)', 'calc(-10px)');+test_valid_length('clamp(-10px, 100px, -30px)', 'calc(-10px)');+test_valid_length('clamp(-10px, -100px, -30px)', 'calc(-10px)');++// and negating the result of clamp+test_valid_length('calc(0px + clamp(10px, 20px, 30px))', 'calc(20px)');+test_valid_length('calc(0px - clamp(10px, 20px, 30px))', 'calc(-20px)');+test_valid_length('calc(0px + clamp(30px, 100px, 20px))', 'calc(30px)');+test_valid_length('calc(0px - clamp(30px, 100px, 20px))', 'calc(-30px)');++// mixed units that can't be resolved until computed-value time+test_valid_length('clamp(1px, 1em, 1vh)', 'clamp(1px, 1em, 1vh)');+test_valid_length('clamp(-18px, 3vw, -3vw)', 'clamp(-18px, 3vw, -3vw)', 'clamp(-18px, 3vw, -3vw)');+test_valid_length('calc(0px + clamp(1px, 1em, 1vh))', 'calc(0px + clamp(1px, 1em, 1vh))');+test_valid_length('calc(0px - clamp(1px, 1em, 1vh))', 'calc(0px - clamp(1px, 1em, 1vh))');++// "none" values+test_valid_length('clamp(none, 33px, 30px)', 'calc(30px)');+test_valid_length('clamp(33px, 30px, none)', 'calc(33px)');+test_valid_length('clamp(none, 30px, none)', 'calc(30px)');++</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-none-whitespace.html b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-none-whitespace.htmlnew file mode 100644index 00000000000..72f0a10bf6c--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-values/clamp-none-whitespace.html@@ -0,0 +1,41 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Values: clamp() accepts whitespace around a 'none' argument</title>+<link rel="help" href="https://drafts.csswg.org/css-values-4/#funcdef-clamp">+<meta name="assert" content="clamp( [ <calc-sum> | none ], <calc-sum>, [ <calc-sum> | none ] ) must accept optional whitespace around the 'none' keyword, including before the following comma and after a trailing 'none', exactly as it does for a <calc-sum> argument.">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<div id="log"></div>+<script>+// Returns the serialized specified value of 'width' for the given declaration,+// or "" if the declaration was rejected as invalid.+function serializeWidth(value) {+ const el = document.createElement("div");+ el.style.width = value;+ return el.style.width;+}++// The 'none' argument with insignificant whitespace must parse identically to+// the same value without that whitespace. Comparing against the no-whitespace+// control avoids hard-coding clamp()'s canonical serialization.+test(() => {+ const control = serializeWidth("clamp(none, 5px, 10px)");+ assert_not_equals(control, "", "clamp() with 'none' as the min argument is supported");+ assert_equals(serializeWidth("clamp(none , 5px, 10px)"), control,+ "whitespace between 'none' and the following comma");+}, "clamp() accepts whitespace between a 'none' min argument and the following comma");++test(() => {+ const control = serializeWidth("clamp(5px, 6px, none)");+ assert_not_equals(control, "", "clamp() with 'none' as the max argument is supported");+ assert_equals(serializeWidth("clamp(5px, 6px, none )"), control,+ "whitespace after a trailing 'none'");+}, "clamp() accepts whitespace after a trailing 'none' max argument");++test(() => {+ const control = serializeWidth("clamp(none, 5px, none)");+ assert_not_equals(control, "", "clamp() with 'none' as both bounds is supported");+ assert_equals(serializeWidth("clamp( none , 5px , none )"), control,+ "whitespace around both 'none' bounds");+}, "clamp() accepts whitespace around 'none' for both bounds");+</script>