Skip to content

Truly independent web browser

LibWeb: Import oversized sticky box coverage

Andreas Kling12f538b38043
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-position/sticky/position-sticky-left-and-right-overconstrained.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-position/sticky/position-sticky-left-and-right-overconstrained.txt
new file mode 100644
index 00000000000..1f8f75a4a18
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-position/sticky/position-sticky-left-and-right-overconstrained.txt
@@ -0,0 +1,10 @@
+Harness status: OK
+
+Found 4 tests
+
+1 Pass
+3 Fail
+Fail start of scroll container
+Fail right before the in-flow position of the sticky box
+Fail right after the in-flow position the sticky box
+Pass end of scroll container
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-position/sticky/position-sticky-top-and-bottom-overconstrained.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-position/sticky/position-sticky-top-and-bottom-overconstrained.txt
new file mode 100644
index 00000000000..1f8f75a4a18
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-position/sticky/position-sticky-top-and-bottom-overconstrained.txt
@@ -0,0 +1,10 @@
+Harness status: OK
+
+Found 4 tests
+
+1 Pass
+3 Fail
+Fail start of scroll container
+Fail right before the in-flow position of the sticky box
+Fail right after the in-flow position the sticky box
+Pass end of scroll container
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-position/sticky/position-sticky-left-and-right-overconstrained.html b/Tests/LibWeb/Text/input/wpt-import/css/css-position/sticky/position-sticky-left-and-right-overconstrained.html
new file mode 100644
index 00000000000..95c0807c728
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-position/sticky/position-sticky-left-and-right-overconstrained.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<title>position:sticky elements with width larger than the space available between left and right</title>
+<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" />
+<meta name="assert" content="This test checks that the end edge is adjusted when the sticky view rectangle width ends up smaller than the width of the sticky element border box" />
+
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+
+<style>
+
+.scroller {
+ width: 100px;
+ height: 100px;
+ overflow: auto;
+ position: relative;
+ display: flex;
+}
+.padding {
+ width: 200px;
+ height: 100px;
+ flex: none;
+}
+.sticky {
+ position: sticky;
+ background: green;
+ left: 20px;
+ right: 0;
+ width: 200px;
+ height: 100px;
+ flex: none;
+}
+</style>
+
+<body>
+ <div class="scroller">
+ <div class="padding"></div>
+ <div class="sticky"></div>
+ <div class="padding"></div>
+ </div>
+</body>
+
+<script>
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollLeft = 0;
+ assert_equals(element.offsetLeft, 20);
+}, 'start of scroll container');
+
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollLeft = 160;
+ assert_equals(element.offsetLeft, 180);
+}, 'right before the in-flow position of the sticky box');
+
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollLeft = 220;
+ assert_equals(element.offsetLeft, 240);
+}, 'right after the in-flow position the sticky box');
+
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollLeft = 500;
+ assert_equals(element.offsetLeft, 400);
+}, 'end of scroll container');
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-position/sticky/position-sticky-top-and-bottom-overconstrained.html b/Tests/LibWeb/Text/input/wpt-import/css/css-position/sticky/position-sticky-top-and-bottom-overconstrained.html
new file mode 100644
index 00000000000..a56e9df1a91
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-position/sticky/position-sticky-top-and-bottom-overconstrained.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<title>position:sticky elements with height larger than the space available between top and bottom</title>
+<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" />
+<meta name="assert" content="This test checks that the end edge is adjusted when the sticky view rectangle height ends up smaller than the height of the sticky element border box" />
+
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+
+<style>
+
+.scroller {
+ height: 100px;
+ overflow: auto;
+ position: relative;
+}
+.padding {
+ height: 200px;
+}
+.sticky {
+ position: sticky;
+ background: green;
+ top: 20px;
+ bottom: 0;
+ height: 200px;
+}
+</style>
+
+<body>
+ <div class="scroller">
+ <div class="padding"></div>
+ <div class="sticky"></div>
+ <div class="padding"></div>
+ </div>
+</body>
+
+<script>
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollTop = 0;
+ assert_equals(element.offsetTop, 20);
+}, 'start of scroll container');
+
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollTop = 160;
+ assert_equals(element.offsetTop, 180);
+}, 'right before the in-flow position of the sticky box');
+
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollTop = 220;
+ assert_equals(element.offsetTop, 240);
+}, 'right after the in-flow position the sticky box');
+
+test(() => {
+ const scroller = document.querySelector('.scroller');
+ const element = document.querySelector('.sticky');
+ scroller.scrollTop = 500;
+ assert_equals(element.offsetTop, 400);
+}, 'end of scroll container');
+</script>