Upstream wpt_internal display-lock WPTs
Some of these tests should have been upstreamed already, and some of
them test scroll to text fragment which I previously thought were not
tested in WPT.
This patch moves over everything that doesn't use content_shell internal
APIs which can't be move to WPT.
Change-Id: I59cb579202f82fbc3d9d1ef3433b75df0d29f74b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4957457
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1212775}
diff --git a/css/css-contain/content-visibility/content-visibility-auto-text-fragment.html b/css/css-contain/content-visibility/content-visibility-auto-text-fragment.html
new file mode 100644
index 0000000..d5184d7
--- /dev/null
+++ b/css/css-contain/content-visibility/content-visibility-auto-text-fragment.html
@@ -0,0 +1,46 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>Content Visibility: navigating to a text fragment.</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<meta name="timeout" content="long">
+<meta name="assert" content="content-visibility: auto subtrees are 'searchable' by text fragment links">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/common/utils.js"></script>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<script>
+promise_test(t => new Promise((resolve, reject) => {
+ const fragment = '#:~:text=hiddentext';
+ const key = token();
+ test_driver.bless("Open a URL with a text fragment directive", () => {
+ window.open(`./resources/text-fragment-target-matchable.html?key=${key}${fragment}`,
+ '_blank',
+ 'noopener');
+ });
+ fetchResults(key, resolve, reject);
+}).then(data => {
+ assert_equals(data.scrollPosition, "text");
+ assert_equals(data.target, "text");
+}), "Fragment navigation with content-visibility; single text");
+
+promise_test(t => new Promise((resolve, reject) => {
+ const fragment = '#:~:text=start,end';
+ const key = token();
+ test_driver.bless("Open a URL with a text fragment directive", () => {
+ window.open(`./resources/text-fragment-target-matchable.html?key=${key}${fragment}`,
+ '_blank',
+ 'noopener');
+ });
+ fetchResults(key, resolve, reject);
+}).then(data => {
+ assert_equals(data.scrollPosition, "text2");
+ assert_equals(data.target, "text2and3ancestor");
+}), "Fragment navigation with content-visibility; range across blocks");
+</script>
+
diff --git a/css/css-contain/content-visibility/locked-frame-crash.html b/css/css-contain/content-visibility/locked-frame-crash.html
new file mode 100644
index 0000000..dce0baa
--- /dev/null
+++ b/css/css-contain/content-visibility/locked-frame-crash.html
@@ -0,0 +1,8 @@
+<link rel="help" href="https://drafts.csswg.org/css-contain/#content-visibility">
+<link rel="help" href="https://crbug.com/1309693">
+
+<iframe id="target" width=320 height=320></iframe>
+<style>
+:first-child { content-visibility: hidden; }
+html,body,ol { -webkit-column-count: 2; }
+</style>
diff --git a/css/css-contain/content-visibility/resources/text-fragment-target-matchable.html b/css/css-contain/content-visibility/resources/text-fragment-target-matchable.html
new file mode 100644
index 0000000..6d57a2e
--- /dev/null
+++ b/css/css-contain/content-visibility/resources/text-fragment-target-matchable.html
@@ -0,0 +1,61 @@
+<!doctype html>
+<title>Text fragment navigation helper.</title>
+
+<script src="/scroll-to-text-fragment/stash.js"></script>
+<script>
+function isInView(element) {
+ let rect = element.getBoundingClientRect();
+ return rect.top >= 0 && rect.top <= window.innerHeight
+ && rect.left >= 0 && rect.left <= window.innerWidth;
+}
+function checkScroll() {
+ let position = 'unknown';
+ if (window.scrollY == 0)
+ position = 'top';
+ else if(isInView(document.getElementById("text")))
+ position = 'text';
+ else if(isInView(document.getElementById("text2")))
+ position = 'text2';
+ else if(isInView(document.getElementById("text3")))
+ position = 'text3';
+
+ const target = document.querySelector(":target");
+ let results = {
+ scrollPosition: position,
+ href: window.location.href,
+ target: target ? target.id : 'undefined'
+ };
+ let key = (new URL(document.location)).searchParams.get("key");
+ stashResultsThenClose(key, results);
+}
+function doubleRafCheckScroll() {
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ checkScroll();
+ });
+ });
+}
+</script>
+
+<style>
+.spacer {
+ height: 10000px;
+}
+</style>
+
+<body onload="doubleRafCheckScroll()">
+<div class=spacer></div>
+<div hidden=until-found>
+ <div id=text>hiddentext</div>
+</div>
+<div class=spacer></div>
+<div id=text2and3ancestor>
+ <div hidden=until-found>
+ <div id=text2>start</div>
+ </div>
+ <div class=spacer></div>
+ <div hidden=until-found>
+ <div id=text3>end</div>
+ </div>
+</div>
+</body>
diff --git a/html/editing/the-hidden-attribute/beforematch-scroll-to-text-fragment.html b/html/editing/the-hidden-attribute/beforematch-scroll-to-text-fragment.html
new file mode 100644
index 0000000..dddab4c
--- /dev/null
+++ b/html/editing/the-hidden-attribute/beforematch-scroll-to-text-fragment.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>beforematch fired on ScrollToTextFragment</title>
+<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+
+<script src="/common/utils.js"></script>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<script>
+promise_test(t => new Promise((resolve, reject) => {
+ const key = token();
+ test_driver.bless('Open a scroll to text fragment URL', () => {
+ window.open(
+ `resources/beforematch-scroll-to-text-fragment-basic.html?key=${key}#:~:text=foo`,
+ '_blank',
+ 'noopener');
+ });
+ fetchResults(key, resolve, reject);
+}).then(results => {
+ assert_equals(results.pageYOffsetDuringBeforematch, 0,
+ 'Scrolling should happen after beforematch is fired.');
+ assert_true(results.beforematchFiredOnFoo,
+ 'Foo was searched for, so it should get a beforematch event.');
+ assert_false(results.beforematchFiredOnBar,
+ 'Bar was not searched for, so it should not get a beforematch event.');
+ assert_true(results.pageYOffsetAfterRaf > 0,
+ 'The page should be scrolled down to foo.');
+}), 'Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation.');
+
+promise_test(t => new Promise((resolve, reject) => {
+ const key = token();
+ test_driver.bless('Open a scroll to text fragment URL', () => {
+ window.open(
+ `resources/beforematch-scroll-to-text-fragment-with-anchor.html?key=${key}#:~:text=foo`,
+ '_blank',
+ 'noopener');
+ });
+ fetchResults(key, resolve, reject);
+}).then(results => {
+ assert_true(results.beforematchFiredOnFoo,
+ 'foo was searched for, so it should get the beforematch event.');
+ assert_false(results.beforematchFiredOnBar,
+ 'bar should not get the beforematch event despite being the target of an element fragment due to the text fragment.');
+}), 'Verifies that beforematch is only fired on elements targeted by a text fragment when there is both a text fragment and an element fragment.');
+
+promise_test(t => new Promise((resolve, reject) => {
+ const key = token();
+ test_driver.bless('Open a scroll to text fragment URL', () => {
+ window.open(
+ `resources/beforematch-scroll-to-text-fragment-bubble.html?key=${key}#:~:text=foo`,
+ '_blank',
+ 'noopener');
+ });
+ fetchResults(key, resolve, reject);
+}).then(results => {
+ assert_true(results.beforematchFiredOnChild,
+ 'The element containing the searched text should have beforematch fired on it.');
+ assert_true(results.beforematchFiredOnParent,
+ 'The parent element of the element containing the matching text should have the beforematch event fired on it because the event should bubble.');
+}), 'Verifies that the beforematch event bubbles with scroll to text fragment.');
+
+// TODO(jarhar): Write more tests here once we decide on a behavior here: https://github.com/WICG/display-locking/issues/150
+</script>
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-001.html b/html/editing/the-hidden-attribute/hidden-until-found-001.html
new file mode 100644
index 0000000..3c87b98
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-001.html
@@ -0,0 +1,49 @@
+<!doctype HTML>
+
+<html class="reftest-wait">
+<meta charset="utf8">
+<title>content-visibility changes after a delay</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<link rel="match" href="./resources/container-ref.html">
+<meta name="assert" content="scrollIntoView has no effect on hidden=until-found">
+<script src="/common/reftest-wait.js"></script>
+
+<style>
+#container {
+ width: 150px;
+ height: 150px;
+ background: lightblue;
+}
+#child {
+ width: 50px;
+ height: 50px;
+ background: lightgreen;
+}
+</style>
+
+<div id=container hidden=until-found>
+ Text.
+ <div id=child></div>
+</div>
+
+
+<script>
+
+function runTest() {
+ document.getElementById("container").scrollIntoView();
+ takeScreenshot();
+}
+
+window.onload = requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ runTest();
+ });
+ });
+});
+
+</script>
+</html>
+
+
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-002.html b/html/editing/the-hidden-attribute/hidden-until-found-002.html
new file mode 100644
index 0000000..a454e3a
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-002.html
@@ -0,0 +1,43 @@
+<!doctype HTML>
+<meta charset="utf8">
+<title>Content Visibility: tab order navigation ignores hidden=until-found subtrees</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<meta name="assert" content="tab order navigation ignores hidden=until-found subtrees.">
+
+<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>
+
+<input id=one type=text></input>
+<div hidden=until-found>
+ <input id=two type=text></input>
+ <input id=three type=text></input>
+ <input id=four type=text></input>
+</div>
+<input id=five type=text></input>
+
+<script>
+async_test((t) => {
+ const tab = "\t";
+ async function step1() {
+ await test_driver.send_keys(document.body, tab);
+ t.step(() => {
+ assert_equals(document.activeElement, document.getElementById("one"));
+ });
+ requestAnimationFrame(step2);
+ }
+
+ async function step2() {
+ await test_driver.send_keys(document.body, tab);
+ t.step(() => {
+ assert_equals(document.activeElement, document.getElementById("five"));
+ });
+ t.done();
+ }
+
+ window.onload = () => { requestAnimationFrame(step1); };
+}, "Tab order navigation skips hidden=until-found subtrees");
+</script>
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-004.html b/html/editing/the-hidden-attribute/hidden-until-found-004.html
new file mode 100644
index 0000000..3ca6feb
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-004.html
@@ -0,0 +1,28 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>hidden=until-found does not paint</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<link rel="match" href="./resources/container-ref.html">
+<meta name="assert" content="content-visibility subtrees are not painted">
+
+<style>
+#container {
+ width: 150px;
+ height: 150px;
+ background: lightblue;
+}
+#child {
+ width: 50px;
+ height: 50px;
+ background: lightgreen;
+}
+</style>
+
+<div id=container hidden=until-found>
+ Text.
+ <div id=child></div>
+ <span>inline child</span>
+</div>
+</html>
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-005-ref.html b/html/editing/the-hidden-attribute/hidden-until-found-005-ref.html
new file mode 100644
index 0000000..0ca7784
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-005-ref.html
@@ -0,0 +1,17 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>Content Visibility: hidden-matchable and size contained (reference)</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+
+<style>
+div {
+ border: 1px solid black;
+}
+</style>
+
+Test passes if there is a empty div with border below.
+<div></div>
+</html>
+
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-005.html b/html/editing/the-hidden-attribute/hidden-until-found-005.html
new file mode 100644
index 0000000..fabf636
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-005.html
@@ -0,0 +1,22 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>hidden=until-found and size contained</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<link rel="match" href="hidden-until-found-005-ref.html">
+<meta name="assert" content="hidden=until-found puts in size containment">
+
+<style>
+div {
+ border: 1px solid black;
+}
+</style>
+
+Test passes if there is a empty div with border below.
+<div hidden=until-found>
+ This text is not visible, and neither should be the div below.
+ <div style="width: 100px; height: 100px; background: red"></div>
+</div>
+</html>
+
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-006-ref.html b/html/editing/the-hidden-attribute/hidden-until-found-006-ref.html
new file mode 100644
index 0000000..e14ba82
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-006-ref.html
@@ -0,0 +1,40 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>content-visibility hidden-matchable + scrollIntoView (reference)</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+
+<style>
+.spacer {
+ height: 1000px;
+ background: lightgreen;
+}
+#container {
+ width: 150px;
+ height: 150px;
+ background: lightblue;
+}
+#target {
+ position: relative;
+ top: 75px;
+ visibility: hidden;
+
+ width: 50px;
+ height: 50px;
+ background: red;
+}
+</style>
+
+<div>top of the page</div>
+<div class=spacer></div>
+<div id=container>
+ <div id=target></div>
+</div>
+<div class=spacer></div>
+<div>bottom of the page</div>
+
+<script>
+onload = () => document.getElementById("target").scrollIntoView();
+</script>
+</html>
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-007.html b/html/editing/the-hidden-attribute/hidden-until-found-007.html
new file mode 100644
index 0000000..7b11a92
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-007.html
@@ -0,0 +1,52 @@
+<!doctype HTML>
+
+<html class="reftest-wait">
+<meta charset="utf8">
+<title>hidden=until-found + focus</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<link rel="match" href="./resources/spacer-and-container-ref.html">
+<meta name="assert" content="focus does not scroll or focus element under hidden=until-found">
+<script src="/common/reftest-wait.js"></script>
+
+<style>
+.spacer {
+ width: 150px;
+ height: 3000px;
+ background: lightblue;
+}
+#container {
+ width: 150px;
+ height: 150px;
+ background: lightblue;
+}
+#target {
+ position: relative;
+ top: 75px;
+
+ width: 50px;
+ height: 50px;
+ background: red;
+}
+</style>
+
+<div class=spacer></div>
+<div id=container hidden=until-found>
+ <div id=target tabindex=0></div>
+</div>
+
+<script>
+function runTest() {
+ document.getElementById("target").focus();
+ requestAnimationFrame(takeScreenshot);
+}
+
+window.onload = requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ runTest();
+ });
+ });
+});
+</script>
+</html>
diff --git a/html/editing/the-hidden-attribute/hidden-until-found-text-fragment.html b/html/editing/the-hidden-attribute/hidden-until-found-text-fragment.html
new file mode 100644
index 0000000..05220f7
--- /dev/null
+++ b/html/editing/the-hidden-attribute/hidden-until-found-text-fragment.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>beforematch fired on ScrollToTextFragment</title>
+<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+
+<script src="/common/utils.js"></script>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<script>
+promise_test(t => new Promise((resolve, reject) => {
+ const key = token();
+ test_driver.bless('Open a scroll to text fragment URL', () => {
+ window.open(
+ `resources/hidden-until-found-text-fragment.html?key=${key}#:~:text=foo`,
+ '_blank',
+ 'noopener');
+ });
+ fetchResults(key, resolve, reject);
+}).then(results => {
+ assert_false(results.targetHasHiddenAttribute,
+ 'The matching hidden=until-found element should have its hidden attribute removed so it can be scrolled to.');
+ assert_true(results.pageYOffsetAfterRaf > 0,
+ 'The page should be scrolled down to foo.');
+}), 'Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation.');
+</script>
diff --git a/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-basic.html b/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-basic.html
new file mode 100644
index 0000000..884e9a6
--- /dev/null
+++ b/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-basic.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<!-- This test is navigated to with the fragment #:~:text=foo -->
+
+<body>
+ <div style="height: 4000px;">spacer</div>
+ <script>
+ const results = {};
+
+ const foo = document.createElement('div');
+ foo.textContent = 'foo';
+ foo.hidden = 'until-found';
+ document.body.appendChild(foo);
+ window.beforematchFiredOnFoo = false;
+ foo.addEventListener('beforematch', () => {
+ // This should be zero. Scrolling should happen after beforematch is
+ // fired.
+ results.pageYOffsetDuringBeforematch = window.pageYOffset;
+ window.beforematchFiredOnFoo = true;
+ });
+
+ const bar = document.createElement('div');
+ bar.textContent = 'bar';
+ document.body.appendChild(bar);
+ window.beforematchFiredOnBar = false;
+ bar.addEventListener('beforematch', () => {
+ window.beforematchFiredOnBar = true;
+ });
+
+ requestAnimationFrame(() => {
+ requestAnimationFrame(async () => {
+ // This should be true. Foo was searched for, so it should get a
+ // beforematch event.
+ results.beforematchFiredOnFoo = window.beforematchFiredOnFoo;
+ // This should be false. Bar was not searched for, so it should not get
+ // a beforematch event.
+ results.beforematchFiredOnBar = window.beforematchFiredOnBar;
+ // This should be greater than zero. The page should be scrolled down
+ // to foo.
+ results.pageYOffsetAfterRaf = window.pageYOffset;
+
+ params = new URLSearchParams(window.location.search);
+ stashResultsThenClose(params.get('key'), results);
+ });
+ });
+ </script>
+</body>
diff --git a/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-bubble.html b/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-bubble.html
new file mode 100644
index 0000000..abfe8dd
--- /dev/null
+++ b/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-bubble.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<!-- This test is navigated to with the fragment #:~:text=foo -->
+
+<div id=parentid>
+ <div id=childid hidden=until-found>foo</div>
+</div>
+
+<script>
+ const results = {
+ beforematchFiredOnChild: false,
+ beforematchFiredOnParent: false
+ };
+
+ childid.addEventListener('beforematch', () => {
+ results.beforematchFiredOnChild = true;
+ });
+
+ parentid.addEventListener('beforematch', () => {
+ results.beforematchFiredOnParent = true;
+ });
+
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ const params = new URLSearchParams(window.location.search);
+ stashResultsThenClose(params.get('key'), results);
+ });
+ });
+</script>
diff --git a/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-with-anchor.html b/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-with-anchor.html
new file mode 100644
index 0000000..3506c6e
--- /dev/null
+++ b/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-with-anchor.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<!-- This test is navigated to with the fragment #bar:~:text=foo -->
+
+<body>
+ <div id=foo hidden=until-found>foo</div>
+ <div id=bar hidden=until-found>bar</div>
+ <script>
+ window.beforematchFiredOnFoo = false;
+ foo.addEventListener('beforematch', () => {
+ window.beforematchFiredOnFoo = true;
+ });
+
+ window.beforematchFiredOnBar = false;
+ bar.addEventListener('beforematch', () => {
+ window.beforematchFiredOnBar = true;
+ });
+
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ const results = {};
+ // This should be true. Foo was searched for, so it should get the
+ // beforematch event.
+ results.beforematchFiredOnFoo = window.beforematchFiredOnFoo;
+ // This should be false. Bar should not get the beforematch event
+ // despite being the target of an element fragment due to the text
+ // fragment.
+ results.beforematchFiredOnBar = window.beforematchFiredOnBar;
+
+ params = new URLSearchParams(window.location.search);
+ stashResultsThenClose(params.get('key'), results);
+ });
+ });
+ </script>
+</body>
diff --git a/html/editing/the-hidden-attribute/resources/container-ref.html b/html/editing/the-hidden-attribute/resources/container-ref.html
new file mode 100644
index 0000000..e2df590
--- /dev/null
+++ b/html/editing/the-hidden-attribute/resources/container-ref.html
@@ -0,0 +1,17 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>CSS Content Visibility: container (reference)</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+
+<style>
+#container {
+ width: 150px;
+ height: 150px;
+ background: lightblue;
+}
+</style>
+
+<div id=container></div>
+
diff --git a/html/editing/the-hidden-attribute/resources/hidden-until-found-text-fragment.html b/html/editing/the-hidden-attribute/resources/hidden-until-found-text-fragment.html
new file mode 100644
index 0000000..fe89b40
--- /dev/null
+++ b/html/editing/the-hidden-attribute/resources/hidden-until-found-text-fragment.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<!-- This test is navigated to with the fragment #:~:text=foo -->
+
+<body>
+ <div style="height: 4000px;">spacer</div>
+ <div id=target hidden=until-found>foo</div>
+ <script>
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ const results = {};
+ // This should be false. The hidden=until-found attribute should be
+ // removed in response to ScrollToTextFragment.
+ results.targetHasHiddenAttribute = document.getElementById('target').hasAttribute('hidden');
+ // This should be greater than zero. The page should be scrolled down
+ // to foo.
+ results.pageYOffsetAfterRaf = window.pageYOffset;
+
+ params = new URLSearchParams(window.location.search);
+ stashResultsThenClose(params.get('key'), results);
+ });
+ });
+ </script>
+</body>
diff --git a/html/editing/the-hidden-attribute/resources/spacer-and-container-ref.html b/html/editing/the-hidden-attribute/resources/spacer-and-container-ref.html
new file mode 100644
index 0000000..816a6c9
--- /dev/null
+++ b/html/editing/the-hidden-attribute/resources/spacer-and-container-ref.html
@@ -0,0 +1,23 @@
+<!doctype HTML>
+<html>
+<meta charset="utf8">
+<title>Content Visibility: spacer and a container (reference)</title>
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+
+<style>
+.spacer {
+ width: 150px;
+ height: 3000px;
+ background: lightblue;
+}
+#container {
+ contain: style layout;
+ width: 150px;
+ height: 150px;
+}
+</style>
+
+<div class="spacer"></div>
+<div id="container"></div>
+</html>
diff --git a/html/rendering/the-details-element/auto-expand-details-text-fragment.html b/html/rendering/the-details-element/auto-expand-details-text-fragment.html
new file mode 100644
index 0000000..321d82c
--- /dev/null
+++ b/html/rendering/the-details-element/auto-expand-details-text-fragment.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>beforematch fired on ScrollToTextFragment</title>
+<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
+<link rel="help" href="https://github.com/WICG/display-locking">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+
+<script src="/common/utils.js"></script>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<script>
+promise_test(t => new Promise((resolve, reject) => {
+ const key = token();
+ test_driver.bless('Open a scroll to text fragment URL', () => {
+ window.open(
+ `resources/auto-expand-details-text-fragment.html?key=${key}#:~:text=foo`,
+ '_blank',
+ 'noopener');
+ });
+ fetchResults(key, resolve, reject);
+}).then(results => {
+ assert_true(results.detailsHasOpenAttribute,
+ 'The matching closed details element should be open.');
+ assert_true(results.pageYOffsetAfterRaf > 0,
+ 'The page should be scrolled down to the match.');
+}), 'Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation.');
+</script>
diff --git a/html/rendering/the-details-element/resources/auto-expand-details-text-fragment.html b/html/rendering/the-details-element/resources/auto-expand-details-text-fragment.html
new file mode 100644
index 0000000..b95459f
--- /dev/null
+++ b/html/rendering/the-details-element/resources/auto-expand-details-text-fragment.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="/scroll-to-text-fragment/stash.js"></script>
+
+<!-- This test is navigated to with the fragment #:~:text=foo -->
+
+<body>
+ <div style="height: 4000px;">spacer</div>
+ <details>
+ <div>foo</div>
+ </details>
+ <script>
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ const results = {};
+ // This should be true. The details element should be opened by
+ // ScrollToTextFragment because it has matching text.
+ results.detailsHasOpenAttribute = document.querySelector('details').hasAttribute('open');
+ // This should be greater than zero. The page should be scrolled down
+ // to the matching target.
+ results.pageYOffsetAfterRaf = window.pageYOffset;
+
+ params = new URLSearchParams(window.location.search);
+ stashResultsThenClose(params.get('key'), results);
+ });
+ });
+ </script>
+</body>