Files
tubestation/testing/web-platform/tests/selection/selection-nested-video.html
Di Zhang a9c7f9fed0 Bug 1911701 [wpt PR 47476] - [Selection API] Add composed range endpoints, a=testonly
Automatic update from web-platform-tests
[Selection API] Add composed range endpoints

We update Range API to support composed range. Previously, when setting
the start/end range endpoints, if they are in different node trees,
they will be collapsed. Now, if start/end are in different node trees,
but same document, composed_range_ will be set to track those cross
shadow tree endpoints.

We update Selection::GetComposedRanges to use composed start and end
to create a composed StaticRange.

We fix Selection::GetComposedRanges to use
IsShadowIncludingInclusiveAncestorOf for Rescoping and add a test.

Change-Id: Ib46497382fb83809394499182b5c8e4ee08925b7
Bug: 40286116
Fixed: 335245347
Fixed: 355630554
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5744732
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: Siye Liu <siliu@microsoft.com>
Commit-Queue: Di Zhang <dizhangg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1337611}

--

wpt-commits: 82f206603878dfa7dfa8c2a608e069c13767f90b
wpt-pr: 47476
2024-08-08 07:20:38 +00:00

28 lines
831 B
HTML

<!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();
})
}, 'selection have the same anchor and focus nodes because b and c are in different tree scopes.');
</script>
<div id="a">A</div>
<video>
<video id="b"></video>
</video>