summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-overscroll-behavior
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/css/css-overscroll-behavior
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-overscroll-behavior')
-rw-r--r--testing/web-platform/tests/css/css-overscroll-behavior/META.yml4
-rw-r--r--testing/web-platform/tests/css/css-overscroll-behavior/inheritance.html24
-rw-r--r--testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior-logical.html49
-rw-r--r--testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior.html198
-rw-r--r--testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-computed.html26
-rw-r--r--testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-invalid.html28
-rw-r--r--testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-valid.html36
7 files changed, 365 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-overscroll-behavior/META.yml b/testing/web-platform/tests/css/css-overscroll-behavior/META.yml
new file mode 100644
index 0000000000..8b83e50d1e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overscroll-behavior/META.yml
@@ -0,0 +1,4 @@
+spec: https://drafts.csswg.org/css-overscroll/
+suggested_reviewers:
+ - majido
+ - theres-waldo
diff --git a/testing/web-platform/tests/css/css-overscroll-behavior/inheritance.html b/testing/web-platform/tests/css/css-overscroll-behavior/inheritance.html
new file mode 100644
index 0000000000..823d623947
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overscroll-behavior/inheritance.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Inheritance of CSS Overscroll Behavior properties</title>
+<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior/#property-index">
+<meta name="assert" content="Properties inherit or not according to the spec.">
+<meta name="assert" content="Properties have initial values according to the spec.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/inheritance-testcommon.js"></script>
+</head>
+<body>
+<div id="container">
+ <div id="target"></div>
+</div>
+<script>
+assert_not_inherited('overscroll-behavior-block', 'auto', 'contain');
+assert_not_inherited('overscroll-behavior-inline', 'auto', 'contain');
+assert_not_inherited('overscroll-behavior-x', 'auto', 'contain');
+assert_not_inherited('overscroll-behavior-y', 'auto', 'contain');
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior-logical.html b/testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior-logical.html
new file mode 100644
index 0000000000..a06132feaa
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior-logical.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test flow-relative versions of overscroll-behavior properties</title>
+<link rel="author" title="Majid Valipour">
+<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior-1/#overscroll-behavior-longhands-logical">
+<link rel="help" href="https://drafts.csswg.org/css-logical/#box">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+div {
+ overscroll-behavior-block: contain;
+ overscroll-behavior-inline: none;
+}
+#horizontal {
+ writing-mode: horizontal-tb;
+}
+#vertical {
+ writing-mode: vertical-rl;
+}
+#horizontalreversed {
+ writing-mode: horizontal-tb;
+ direction: rtl;
+}
+</style>
+<body>
+ <div id="horizontal"></div>
+ <div id="vertical"></div>
+ <div id="horizontalreversed"></div>
+</body>
+
+<script>
+test(function() {
+ var element = document.getElementById("horizontal");
+ assert_equals(getComputedStyle(element).overscrollBehaviorX, "none");
+ assert_equals(getComputedStyle(element).overscrollBehaviorY, "contain");
+}, "Logical overscroll-behavior maps correctly when element has horizontal-tb writing mode");
+
+test(function() {
+ var element = document.getElementById("vertical");
+ assert_equals(getComputedStyle(element).overscrollBehaviorX, "contain");
+ assert_equals(getComputedStyle(element).overscrollBehaviorY, "none");
+}, "Logical overscroll-behavior maps correctly when element has vertical-rl writing mode");
+
+test(function() {
+ var element = document.getElementById("horizontalreversed");
+ assert_equals(getComputedStyle(element).overscrollBehaviorX, "none");
+ assert_equals(getComputedStyle(element).overscrollBehaviorY, "contain");
+}, "Logical overscroll-behavior maps correctly when element has horizontal-tb writing mode and is not affected by rtl direction");
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior.html b/testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior.html
new file mode 100644
index 0000000000..dcd981e92e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior.html
@@ -0,0 +1,198 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/css/css-scroll-snap/support/common.js"></script>
+<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior">
+
+<style>
+.outer {
+ height: 400px;
+ width: 1000px;
+ background: white
+}
+.content {
+ height: 600px;
+ width: 1200px;
+}
+#root {
+ overflow: scroll;
+ height: 600px;
+ width: 800px;
+ background: white;
+}
+#container {
+ overflow: scroll;
+}
+#non_scrollable {
+ overflow: none;
+}
+#green {
+ background: repeating-linear-gradient(to bottom right, green 15%, white 30%);
+}
+#blue {
+ background: repeating-linear-gradient(to bottom right, blue 15%, white 30%);
+}
+</style>
+
+<div id='root'>
+ <div id='non_scrollable' class='outer'>
+ <div id='green' class='content'></div>
+ </div>
+ <div id='container' class='outer'>
+ <div id='blue' class='content'></div>
+ </div>
+</div>
+<input type="button" id="btnDone" value="DONE" style="width: 100px; height: 50px;"/>
+<h1>overscroll-behavior</h1>
+<h4>Tests that overscroll-behavior prevents scroll-propagation in the area and direction as specified.</h4>
+<ol>
+ <li id="i1">Make two scrolls on <span style="color: blue">BLUE</span>, in this order: scroll UP (or drag down), then scroll LEFT (or drag right). Scroll (or drag) until nothing is scrolling. Then tap on DONE.</li>
+ <li id="i2">Repeat the same scrolls as in step 1 and then tap on DONE.</li>
+ <li id="i3">Repeat the same scrolls as in step 1 and then tap on DONE.</li>
+ <li id="i4">Make two separate scrolls on <span style="color: green">GREEN</span>, in this order: scroll UP (or drag down), then scroll LEFT (or drag right). Scroll (or drag) until nothing is scrolling. Then tap on DONE.</li>
+</ol>
+
+
+<script>
+setup({explicit_timeout: true});
+const container = document.getElementById('container');
+const non_scrollable = document.getElementById('non_scrollable');
+const root = document.getElementById('root');
+const btnDone = document.getElementById('btnDone');
+var test = async_test("overscroll-behavior prevents scroll-propagation in the area and direction as specified");
+var instruction1 = document.getElementById("i1");
+var instruction2 = document.getElementById("i2");
+var instruction3 = document.getElementById("i3");
+var instruction4 = document.getElementById("i4");
+var actions_promise;
+
+scrollTop = () => container.scrollTop;
+scrollLeft = () => container.scrollLeft;
+
+function smoothScrollByXY(xPosition, yPosition, xScrollOffset, yScrollOffset) {
+ return new test_driver.Actions()
+ .scroll(xPosition, yPosition, xScrollOffset, yScrollOffset)
+ .send();
+}
+
+function setUpForRoot(offset) {
+ root.scrollTop = offset;
+ root.scrollLeft = offset;
+}
+
+function setUpForContainer(offset) {
+ container.scrollTop = offset;
+ container.scrollLeft = offset
+}
+
+function set_boundary_prevents_y() {
+ instruction1.style.color = 'red';
+ instruction1.style.fontWeight = 'bold';
+ container.style.overscrollBehaviorX = 'auto';
+ container.style.overscrollBehaviorY = 'none';
+ setUpForRoot(100);
+ setUpForContainer(0);
+ window.scrollTo(0, 0);
+}
+
+function verify_y_prevented_and_set_boundary_prevents_x() {
+ instruction1.style.fontWeight = 'normal';
+ instruction2.style.fontWeight = 'bold';
+ test.step(function() {
+ assert_equals(root.scrollTop, 100, "overscroll-behavior-y: none should prevent scroll propagation on y axis.");
+ assert_equals(root.scrollLeft, 0, "overscroll-behavior-y: none should only prevent scroll propagation on y axis.");
+ window.scrollTo(0, 0);
+ });
+
+ container.style.overscrollBehaviorX = 'none';
+ container.style.overscrollBehaviorY = 'auto';
+ setUpForRoot(100);
+ setUpForContainer(0);
+ window.scrollTo(0, 0);
+}
+
+function verify_x_prevented_and_set_boundary_allows_inner() {
+ instruction2.style.fontWeight = 'normal';
+ instruction3.style.fontWeight = 'bold';
+ test.step(function() {
+ assert_equals(root.scrollTop, 0, "overscroll-behavior-x: none should only prevent scroll propagation on x axis.");
+ assert_equals(root.scrollLeft, 100, "overscroll-behavior-x: none should prevent scroll propagation on x axis." );
+ });
+
+ container.style.overscrollBehaviorX = 'none';
+ container.style.overscrollBehaviorY = 'none';
+ setUpForRoot(100);
+ setUpForContainer(100);
+ window.scrollTo(0, 0);
+}
+
+function verify_inner_allowed_and_set_nonscrollable_allows_propagation() {
+ instruction1.style.color = 'black';
+ instruction4.style.color = 'red';
+ instruction3.style.fontWeight = 'normal';
+ instruction4.style.fontWeight = 'bold';
+ test.step(function() {
+ assert_equals(container.scrollTop, 0, "overscroll-behavior should latch the scroll to the inner container.");
+ assert_equals(container.scrollLeft, 0, "overscroll-behavior should latch the scroll to the inner container.");
+ assert_equals(root.scrollTop, 100, "overscroll-behavior should latch the scroll to the inner container.");
+ assert_equals(root.scrollLeft, 100, "overscroll-behavior should latch the scroll to the inner container.");
+ });
+
+ non_scrollable.style.overscrollBehaviorX = 'none';
+ non_scrollable.style.overscrollBehaviorY = 'none';
+ setUpForRoot(100);
+ window.scrollTo(0, 0);
+}
+
+function verify_non_scrollable_allows_propagation() {
+ test.step(function() {
+ assert_equals(root.scrollLeft, 0, "overscroll-behavior on non-scrollable area should not affect scroll propagation.");
+ assert_equals(root.scrollTop, 0, "overscroll-behavior on non-scrollable area should not affect scroll propagation.");
+ });
+ actions_promise.then( () => {
+ test.done();
+ });
+}
+
+var verifyAndSetupForNext = [
+ set_boundary_prevents_y,
+ verify_y_prevented_and_set_boundary_prevents_x,
+ verify_x_prevented_and_set_boundary_allows_inner,
+ verify_inner_allowed_and_set_nonscrollable_allows_propagation,
+ verify_non_scrollable_allows_propagation];
+
+on_event(btnDone, "click", function() {
+ if (current_test < verifyAndSetupForNext.length)
+ verifyAndSetupForNext[current_test++]();
+});
+
+var current_test = 0;
+verifyAndSetupForNext[current_test++]();
+
+// Inject scroll actions.
+const test_cases = [
+ { x: 200, y: 500, dx: -200, dy: -200 },
+ { x: 200, y: 500, dx: -200, dy: -200 },
+ { x: 200, y: 500, dx: -200, dy: -200 },
+ { x: 200, y: 100, dx: -200, dy: -200 },
+];
+
+actions_promise = new Promise( (resolve) => {resolve();} );
+for (let action of test_cases) {
+ actions_promise = actions_promise.then(() => {
+ return smoothScrollByXY(action.x, action.y, 0, action.dy);
+ }).then(() => {
+ return waitForAnimationEnd(scrollTop);
+ }).then(() => {
+ return smoothScrollByXY(action.x, action.y, action.dx, 0);
+ }).then(() => {
+ return waitForAnimationEnd(scrollLeft);
+ }).then(() => {
+ return test_driver.click(btnDone);
+ });
+}
+
+</script>
diff --git a/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-computed.html b/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-computed.html
new file mode 100644
index 0000000000..e7b40d95c5
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-computed.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Overscroll Behavior: getComputedStyle().overscrollBehavior*</title>
+<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior/#overscroll-behavior-properties">
+<meta name="assert" content="overscroll-behavior-x computed value is as specified.">
+<meta name="assert" content="overscroll-behavior-y computed value is as specified.">
+<meta name="assert" content="overscroll-behavior-inline computed value is as specified.">
+<meta name="assert" content="overscroll-behavior-block 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>
+<div id="target"></div>
+<script>
+'use strict';
+for (let property of ["overscroll-behavior-x", "overscroll-behavior-y", "overscroll-behavior-inline", "overscroll-behavior-block"]) {
+ test_computed_value(property, "contain");
+ test_computed_value(property, "none");
+ test_computed_value(property, "auto");
+}
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-invalid.html b/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-invalid.html
new file mode 100644
index 0000000000..02ada4576c
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-invalid.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Overscroll Behavior: parsing overscroll-behavior with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior/#propdef-overscroll-behavior">
+<meta name="assert" content="overscroll-behavior supports only the grammar '[ contain | none | auto ]{1,2}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+'use strict';
+test_invalid_value("overscroll-behavior", "normal");
+test_invalid_value("overscroll-behavior", "0");
+test_invalid_value("overscroll-behavior", "contain contain contain");
+
+
+for (let property of ["overscroll-behavior-x", "overscroll-behavior-y", "overscroll-behavior-inline", "overscroll-behavior-block"]) {
+ test_invalid_value(property, "normal");
+ test_invalid_value(property, "0");
+ test_invalid_value(property, "contain contain");
+}
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-valid.html b/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-valid.html
new file mode 100644
index 0000000000..45d90d485f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overscroll-behavior/parsing/overscroll-behavior-valid.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Overscroll Behavior: parsing overscroll-behavior with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior/#propdef-overscroll-behavior">
+<meta name="assert" content="overscroll-behavior supports the full grammar '[ contain | none | auto ]{1,2}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+'use strict';
+test_valid_value("overscroll-behavior", "contain");
+test_valid_value("overscroll-behavior", "none");
+test_valid_value("overscroll-behavior", "auto");
+
+test_valid_value("overscroll-behavior", "contain none");
+test_valid_value("overscroll-behavior", "none auto");
+test_valid_value("overscroll-behavior", "auto contain");
+
+test_valid_value("overscroll-behavior", "contain contain", "contain");
+test_valid_value("overscroll-behavior", "none none", "none");
+test_valid_value("overscroll-behavior", "auto auto", "auto");
+
+
+for (let property of ["overscroll-behavior-x", "overscroll-behavior-y", "overscroll-behavior-inline", "overscroll-behavior-block"]) {
+ test_valid_value(property, "contain");
+ test_valid_value(property, "none");
+ test_valid_value(property, "auto");
+}
+</script>
+</body>
+</html>