summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-070.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-070.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-070.html')
-rw-r--r--testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-070.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-070.html b/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-070.html
new file mode 100644
index 0000000000..a41b513e62
--- /dev/null
+++ b/testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-070.html
@@ -0,0 +1,112 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>Content Visibility: off-screen selection</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-contain/#content-visibility">
+<meta name="assert" content="content-visibility auto element remains non-skipped when elements in its subtree have selection.">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<style>
+body, html {
+ padding: 0;
+ margin: 0;
+}
+
+.spacer {
+ height: 3000px;
+ background: lightblue;
+}
+#container {
+ background: lightgreen;
+ contain-intrinsic-size: 50px 100px;
+ content-visibility: auto;
+}
+#selectable {
+ width: 10px;
+ height: 10px;
+}
+</style>
+
+<div class=spacer></div>
+<div id=container>
+ <div id=selectable>hello</div>
+</div>
+<div class=spacer></div>
+
+<script>
+async_test((t) => {
+ const selection = window.getSelection();
+ const range = document.createRange();
+ range.selectNodeContents(selectable);
+
+ // Initially container should be 3000px offscreen with contained height 100px.
+ function step1() {
+ const r = container.getBoundingClientRect();
+ t.step(() => {
+ assert_equals(r.y, 3000, "step1 offset");
+ assert_equals(r.height, 100, "step1 height");
+ });
+
+ selection.removeAllRanges();
+ selection.addRange(range);
+
+ requestAnimationFrame(step2);
+ }
+ // The container has a selection so it should be smaller now, height 10px.
+ function step2() {
+ const r = container.getBoundingClientRect();
+ t.step(() => {
+ assert_equals(r.y, 3000, "step2 offset");
+ assert_equals(r.height, 10, "step2 height");
+ });
+ document.scrollingElement.scrollTop = 3000;
+ requestAnimationFrame(step3);
+ }
+ // After scrolling the container should be closer and still height 10px.
+ function step3() {
+ const r = container.getBoundingClientRect();
+ t.step(() => {
+ assert_less_than(r.y, 3000, "step3 offset");
+ assert_equals(r.height, 10, "step3 height");
+ });
+ document.scrollingElement.scrollTop = 0;
+ requestAnimationFrame(step4);
+ }
+ // Scrolling back to the top we should remain at height 10px.
+ function step4() {
+ const r = container.getBoundingClientRect();
+ t.step(() => {
+ assert_equals(r.y, 3000, "step4 offset");
+ assert_equals(r.height, 10, "step4 height");
+ });
+ requestAnimationFrame(step5);
+ }
+ // Repeat step4 to ensure we're in a stable situation.
+ function step5() {
+ const r = container.getBoundingClientRect();
+ t.step(() => {
+ assert_equals(r.y, 3000, "step5 offset");
+ assert_equals(r.height, 10, "step5 height");
+ });
+
+ selection.removeAllRanges();
+
+ requestAnimationFrame(step6);
+ }
+ // After removing the selection we should go back to the contained
+ // height of 100px.
+ function step6() {
+ const r = container.getBoundingClientRect();
+ t.step(() => {
+ assert_equals(r.y, 3000, "step5 offset");
+ assert_equals(r.height, 100, "step5 height");
+ });
+ t.done();
+ }
+ step1();
+});
+</script>
+</html>