summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/selection
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /testing/web-platform/tests/selection
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/selection')
-rw-r--r--testing/web-platform/tests/selection/crashtests/selection-details-editor-ui.html19
-rw-r--r--testing/web-platform/tests/selection/crashtests/selection-modify-line-next-to-input-and-make-it-invisible.html23
-rw-r--r--testing/web-platform/tests/selection/onselectionchange-on-distinct-text-controls.html47
-rw-r--r--testing/web-platform/tests/selection/onselectionchange-on-document.html73
-rw-r--r--testing/web-platform/tests/selection/selection-nested-video.html25
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1-ref.html6
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1.html10
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2-ref.html7
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2.html11
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3-ref.html12
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3.html17
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-4.html21
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5-ref.html13
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5.html20
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6-ref.html12
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6.html44
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img-ref.html9
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img.html26
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document-ref.html9
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document.html12
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root-ref.html11
-rw-r--r--testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root.html24
-rw-r--r--testing/web-platform/tests/selection/textcontrols/selectionchange.html4
23 files changed, 453 insertions, 2 deletions
diff --git a/testing/web-platform/tests/selection/crashtests/selection-details-editor-ui.html b/testing/web-platform/tests/selection/crashtests/selection-details-editor-ui.html
new file mode 100644
index 0000000000..444306207a
--- /dev/null
+++ b/testing/web-platform/tests/selection/crashtests/selection-details-editor-ui.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<meta charset=utf-8>
+<style>
+*:nth-child(odd) {
+ display: table-header-group;
+}
+</style>
+<script>
+document.addEventListener("DOMContentLoaded", () => {
+ document.execCommand("enableObjectResizing", false)
+ document.addEventListener("selectionchange", () => {
+ document.execCommand("insertImage", false, "x")
+ document.execCommand("selectAll", false)
+ }, { once: true });
+ document.getSelection().collapse(a)
+})
+</script>
+<details open="" contenteditable="true">
+<details id="a">
diff --git a/testing/web-platform/tests/selection/crashtests/selection-modify-line-next-to-input-and-make-it-invisible.html b/testing/web-platform/tests/selection/crashtests/selection-modify-line-next-to-input-and-make-it-invisible.html
new file mode 100644
index 0000000000..09e018f581
--- /dev/null
+++ b/testing/web-platform/tests/selection/crashtests/selection-modify-line-next-to-input-and-make-it-invisible.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<script>
+document.addEventListener("DOMContentLoaded", () => {
+ getSelection().addRange(document.createRange());
+ const range = document.createRange();
+ range.selectNode(document.querySelector("meter"));
+ getSelection().addRange(range);
+ getSelection().modify('move', 'left', 'line');
+ document.querySelector("input").style.display = "none";
+ getSelection().modify('move', 'left', 'lineboundary');
+})
+</script>
+</head>
+<body>
+<input>
+<div contenteditable>
+<meter>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/selection/onselectionchange-on-distinct-text-controls.html b/testing/web-platform/tests/selection/onselectionchange-on-distinct-text-controls.html
new file mode 100644
index 0000000000..ee26928699
--- /dev/null
+++ b/testing/web-platform/tests/selection/onselectionchange-on-distinct-text-controls.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="help" href="https://w3c.github.io/selection-api/#selectionchange-event">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<input id="input1" value="hello">
+<input id="input2" value="world">
+<textarea id="textarea1">hello</textarea>
+<textarea id="textarea2">world</textarea>
+<script>
+
+promise_test(() => {
+ return (async function() {
+ let selectionChangeCount1 = 0;
+ let selectionChangeCount2 = 0;
+ input1.addEventListener("selectionchange", () => ++selectionChangeCount1);
+ input2.addEventListener("selectionchange", () => ++selectionChangeCount2);
+ input1.setSelectionRange(1, 2);
+ input1.setSelectionRange(2, 3);
+ input2.setSelectionRange(1, 3);
+ assert_equals(selectionChangeCount1, 0);
+ assert_equals(selectionChangeCount2, 0);
+ await new Promise(setTimeout);
+ assert_equals(selectionChangeCount1, 1);
+ assert_equals(selectionChangeCount2, 1);
+ })();
+}, "selectionchange event on each input element fires independently");
+
+promise_test(() => {
+ return (async function() {
+ let selectionChangeCount1 = 0;
+ let selectionChangeCount2 = 0;
+ textarea1.addEventListener("selectionchange", () => ++selectionChangeCount1);
+ textarea2.addEventListener("selectionchange", () => ++selectionChangeCount2);
+ textarea1.setSelectionRange(1, 2);
+ textarea1.setSelectionRange(2, 3);
+ textarea2.setSelectionRange(1, 3);
+ assert_equals(selectionChangeCount1, 0);
+ assert_equals(selectionChangeCount2, 0);
+ await new Promise(setTimeout);
+ assert_equals(selectionChangeCount1, 1);
+ assert_equals(selectionChangeCount2, 1);
+ })();
+}, "selectionchange event on each textarea element fires independently");
+
+</script>
diff --git a/testing/web-platform/tests/selection/onselectionchange-on-document.html b/testing/web-platform/tests/selection/onselectionchange-on-document.html
new file mode 100644
index 0000000000..4e06165377
--- /dev/null
+++ b/testing/web-platform/tests/selection/onselectionchange-on-document.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="help" href="https://w3c.github.io/selection-api/#selectionchange-event">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div id="container"><br><br></div>
+<script>
+
+promise_test(() => {
+ return new Promise(resolve => {
+ let didFireSelectionChangeEvent = false;
+ document.addEventListener("selectionchange", () => { didFireSelectionChangeEvent = true; resolve(); }, {once: true});
+ getSelection().setPosition(container, 0);
+ assert_false(didFireSelectionChangeEvent);
+ });
+}, "selectionchange event on document fires");
+
+promise_test(() => {
+ return (async function() {
+ let selectionChangeCount = 0;
+ document.addEventListener("selectionchange", () => ++selectionChangeCount);
+ container.innerHTML = '<span><br></span><span><br></span>';
+ getSelection().setPosition(container, 0);
+ assert_equals(selectionChangeCount, 0);
+ getSelection().setPosition(container, 2);
+ assert_equals(selectionChangeCount, 0);
+ await new Promise(setTimeout);
+ assert_equals(selectionChangeCount, 1);
+ })();
+}, "selectionchange event on document fires once");
+
+promise_test(() => {
+ return (async function() {
+ let selectionChangeCount = 0;
+ document.addEventListener("selectionchange", () => ++selectionChangeCount);
+ container.innerHTML = '<span><br></span><span><br></span>';
+ getSelection().setPosition(container, 0);
+ assert_equals(selectionChangeCount, 0);
+ getSelection().setPosition(container, 2);
+ assert_equals(selectionChangeCount, 0);
+ await new Promise(setTimeout);
+ assert_equals(selectionChangeCount, 1);
+ getSelection().setPosition(container, 0);
+ assert_equals(selectionChangeCount, 1);
+ getSelection().setPosition(container, 2);
+ assert_equals(selectionChangeCount, 1);
+ await new Promise(setTimeout);
+ assert_equals(selectionChangeCount, 2);
+ })();
+}, "task to fire selectionchange event gets queued each time selection is mutated");
+
+promise_test(() => {
+ return (async function() {
+ let selectionChangeCount = 0;
+ document.addEventListener("selectionchange", () => {
+ if (!selectionChangeCount) {
+ getSelection().setPosition(container, 2);
+ getSelection().setPosition(container, 0);
+ }
+ ++selectionChangeCount;
+ });
+ container.innerHTML = '<b><br></b><b><br></b>';
+ getSelection().setPosition(container, 0);
+ assert_equals(selectionChangeCount, 0);
+ await new Promise(setTimeout);
+ assert_equals(selectionChangeCount, 1);
+ await new Promise(setTimeout);
+ assert_equals(selectionChangeCount, 2);
+ })();
+}, "has scheduled selectionchange event is set to false at the beginning of a task to fire selectionchange event");
+
+</script>
diff --git a/testing/web-platform/tests/selection/selection-nested-video.html b/testing/web-platform/tests/selection/selection-nested-video.html
new file mode 100644
index 0000000000..9777d7d992
--- /dev/null
+++ b/testing/web-platform/tests/selection/selection-nested-video.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Selection with nested videos doesn't crash</title>
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1887963">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ document.addEventListener("DOMContentLoaded", () => {
+ let c = a.attachShadow({mode: "open"});
+ const sel = window.getSelection();
+
+ sel.setBaseAndExtent(b, 0, c, 0);
+
+ assert_equals(sel.anchorNode, b);
+ assert_equals(sel.anchorOffset, 0);
+ assert_equals(sel.focusNode, b);
+ assert_equals(sel.focusOffset, 0);
+ t.done();
+ })
+});
+</script>
+<div id="a">A</div>
+<video>
+<video id="b">
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1-ref.html
new file mode 100644
index 0000000000..9cc7affd67
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1-ref.html
@@ -0,0 +1,6 @@
+<!doctype html>
+OuterText
+<div>innerText</div>
+<script>
+ getSelection().selectAllChildren(document.body);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1.html
new file mode 100644
index 0000000000..58d7e9f8e4
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-1.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<head>
+<link rel="match" href="cross-shadow-boundary-1-ref.html"/>
+</head>
+OuterText
+<div id="host"></div>
+<script>
+ document.getElementById("host").attachShadow({mode: "open"}).innerHTML = "innerText";
+ getSelection().selectAllChildren(document.body);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2-ref.html
new file mode 100644
index 0000000000..c9e0068c51
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2-ref.html
@@ -0,0 +1,7 @@
+<!doctype html>
+OuterText
+<div>innerText</div>
+OuterText
+<script>
+ getSelection().selectAllChildren(document.body);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2.html
new file mode 100644
index 0000000000..e0d3a14f48
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-2.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<head>
+<link rel="match" href="cross-shadow-boundary-2-ref.html" />
+</head>
+OuterText
+<div id="host"></div>
+OuterText
+<script>
+ document.getElementById("host").attachShadow({ mode: "open" }).innerHTML = "innerText";
+ getSelection().selectAllChildren(document.body);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3-ref.html
new file mode 100644
index 0000000000..189ab35c41
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3-ref.html
@@ -0,0 +1,12 @@
+<!doctype html>
+OuterText
+<div id="host1">innerText1</div>
+OuterText
+<div id="host2">innerText2</div>
+<script>
+ const host1 = document.getElementById("host1");
+ const host2 = document.getElementById("host2");
+
+ getSelection().setBaseAndExtent(
+ host1.firstChild, 3, host2.firstChild, 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3.html
new file mode 100644
index 0000000000..3eb2ab37b1
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-3.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<head>
+<link rel="match" href="cross-shadow-boundary-3-ref.html" />
+</head>
+OuterText
+<div id="host1"></div>
+OuterText
+<div id="host2"></div>
+<script>
+ const root1 = document.getElementById("host1").attachShadow({ mode: "open" });
+ root1.innerHTML = "innerText1";
+
+ const root2 = document.getElementById("host2").attachShadow({ mode: "open" });
+ root2.innerHTML = "innerText2";
+
+ getSelection().setBaseAndExtent(root1.firstChild, 3, root2.firstChild, 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-4.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-4.html
new file mode 100644
index 0000000000..a93bf77aaa
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-4.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<head>
+<!--Intentionally to use cross-shadow-boundary-3-ref.html here-->
+<link rel=match href="cross-shadow-boundary-3-ref.html">
+</head>
+OuterText
+<div id="host1"></div>
+OuterText
+<div id="host2"></div>
+<script>
+ const root1 = document.getElementById("host1").attachShadow({ mode: "open" });
+ root1.innerHTML = "innerText1";
+
+ const root2 = document.getElementById("host2").attachShadow({ mode: "open" });
+ root2.innerHTML = "<div></div>";
+
+ const root3 = root2.querySelector("div").attachShadow({ mode: "open" });
+ root3.innerHTML = "innerText2";
+
+ getSelection().setBaseAndExtent(root1.firstChild, 3, root3.firstChild, 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5-ref.html
new file mode 100644
index 0000000000..2abfd911ec
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5-ref.html
@@ -0,0 +1,13 @@
+<!doctype html>
+OuterText1
+<div>innerText1</div>
+OuterText2
+<div>innerText2</div>
+OuterText3
+<script>
+ getSelection().setBaseAndExtent(
+ document.body.firstChild,
+ 3,
+ document.body.childNodes[4],
+ 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5.html
new file mode 100644
index 0000000000..75c0525ade
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-5.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<head>
+<link rel=match href="cross-shadow-boundary-5-ref.html">
+</head>
+OuterText1
+<div id="host1"></div>
+OuterText2
+<div id="host2"></div>
+OuterText3
+<script>
+ const root1 = document.getElementById("host1").attachShadow({ mode: "open" });
+ root1.innerHTML = "innerText1";
+
+ const root2 = document.getElementById("host2").attachShadow({ mode: "open" });
+ root2.innerHTML = "<div></div>";
+
+ const root3 = root2.querySelector("div").attachShadow({ mode: "open" });
+ root3.innerHTML = "innerText2";
+ getSelection().setBaseAndExtent(document.body.firstChild, 3, document.body.childNodes[4], 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6-ref.html
new file mode 100644
index 0000000000..b7441c7bbc
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6-ref.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<span id="span">Start
+<div>
+ <span id="inner1">inner1</p>
+ <span id="inner2">inner2</p>
+</div>
+</span>
+<script>
+ const start = document.getElementById("span").firstChild;
+ const end = document.getElementById("inner2");
+ window.getSelection().setBaseAndExtent(start, 3, end.firstChild, 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6.html
new file mode 100644
index 0000000000..cc264a6668
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-6.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<html class="reftest-wait">
+<head>
+<link rel=match href="cross-shadow-boundary-6-ref.html">
+</head>
+<span id="span">Start
+<div>
+ <template shadowrootmode="open">
+ <span id="inner1">inner1</p>
+ <span id="inner2">inner2</p>
+ </template>
+</div>
+</span>
+<script>
+ const start = document.getElementById("span").firstChild;
+ const end = document.querySelector('div').shadowRoot.getElementById("inner2");
+
+ async function waitForRAFs() {
+ return new Promise(resolve => {
+ window.requestAnimationFrame(() => {
+ window.requestAnimationFrame(() => {
+ window.requestAnimationFrame(() => {
+ resolve();
+ });
+ });
+ });
+ });
+ }
+
+ async function runTest() {
+ window.getSelection().setBaseAndExtent(start, 3, end.firstChild, 3);
+ await waitForRAFs();
+
+ window.getSelection().removeAllRanges();
+ await waitForRAFs();
+
+ window.getSelection().setBaseAndExtent(start, 3, end.firstChild, 3);
+ await waitForRAFs();
+ document.documentElement.className = "";
+ }
+
+ runTest();
+</script>
+</html>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img-ref.html
new file mode 100644
index 0000000000..7f3b03ace6
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img-ref.html
@@ -0,0 +1,9 @@
+<!doctype html>
+OuterText1
+<div>innerText1</div>
+OuterText2
+<div><img style="width: 10px; height: 10px; background-color: black"></img></div>
+OuterText3
+<script>
+ getSelection().setBaseAndExtent(document.body.firstChild, 3, document.body.childNodes[4], 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img.html
new file mode 100644
index 0000000000..46e8d70833
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-img.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<head>
+<link rel=match href="cross-shadow-boundary-img-ref.html">
+</head>
+OuterText1
+<div id="host1"></div>
+OuterText2
+<div id="host2"></div>
+OuterText3
+<script>
+ const root1 = document.getElementById("host1").attachShadow({ mode: "open" });
+ root1.innerHTML = "innerText1";
+
+ const root2 = document.getElementById("host2").attachShadow({ mode: "open" });
+ root2.innerHTML = "<div></div>";
+
+ const root3 = root2.querySelector("div").attachShadow({ mode: "open" });
+ root3.innerHTML = "<img>";
+
+ const img = root3.querySelector("img");
+ img.style.width = "10px";
+ img.style.height = "10px";
+ img.style.backgroundColor = "black";
+
+ getSelection().setBaseAndExtent(document.body.firstChild, 3, document.body.childNodes[4], 3);
+</script>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document-ref.html
new file mode 100644
index 0000000000..0312000bc0
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document-ref.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<html>
+ <div>CONTENT</div>
+ <script>
+ const div = document.querySelector("div");
+ getSelection().setBaseAndExtent(div.firstChild, 0, div.firstChild, 2);
+ </script>
+</html>
+
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document.html
new file mode 100644
index 0000000000..9eb298abbf
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-document.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel=match href="cross-shadow-boundary-select-document-ref.html">
+ </head>
+ <div></div>
+ <script>
+ const root = document.querySelector("div").attachShadow({mode: "open"});
+ root.innerHTML = "CONTENT";
+ getSelection().setBaseAndExtent(document, 0, root.firstChild, 2);
+ </script>
+</html>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root-ref.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root-ref.html
new file mode 100644
index 0000000000..fe74406acd
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root-ref.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+ <body>
+ <div id="outerText">OuterText1</div>
+ <div>InnerText1</div>
+ <div>OuterText2</div>
+ <div id="host">InnerText2</div>
+ <script>
+ window.getSelection().setBaseAndExtent(outerText, 0, host, host.childNodes.length);
+ </script>
+</body></html>
diff --git a/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root.html b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root.html
new file mode 100644
index 0000000000..f64dd0f3b0
--- /dev/null
+++ b/testing/web-platform/tests/selection/shadow-dom/cross-shadow-boundary-select-root.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<head>
+<link rel=match href="cross-shadow-boundary-select-root-ref.html">
+</head>
+<div id="outerText1">OuterText1</div>
+<div id="host1"></div>
+<div id="outerText2">OuterText2</div>
+<div id="host2"></div>
+<div id="host3"></div>
+<script>
+ const outerText1 = document.getElementById("outerText1");
+ const outerText2 = document.getElementById("outerText2");
+
+ const host1 = document.getElementById("host1");
+ const root1 = host1.attachShadow({mode: "open"});
+ root1.innerHTML = "InnerText1";
+
+ const host2 = document.getElementById("host2");
+ const root2 = host2.attachShadow({mode: "open"});
+ root2.innerHTML = "InnerText2";
+
+ getSelection().setBaseAndExtent(outerText1, 0, root2, root2.childNodes.length);
+</script>
+
diff --git a/testing/web-platform/tests/selection/textcontrols/selectionchange.html b/testing/web-platform/tests/selection/textcontrols/selectionchange.html
index 2b43cfe44b..1c4ddf2b9b 100644
--- a/testing/web-platform/tests/selection/textcontrols/selectionchange.html
+++ b/testing/web-platform/tests/selection/textcontrols/selectionchange.html
@@ -184,7 +184,7 @@
target.setRangeText("foo", 2, 6);
await data.assert_empty_spin();
- assert_equals(collector.events.length, 2);
+ assert_equals(collector.events.length, 1);
}, `Calling setRangeText() after select() on ${name}`);
promise_test(async () => {
@@ -196,7 +196,7 @@
target.setRangeText("", 10, 12);
await data.assert_empty_spin();
- assert_equals(collector.events.length, 4);
+ assert_equals(collector.events.length, 1);
}, `Calling setRangeText() repeatedly on ${name}`);
promise_test(async () => {