|
| 1 | +<!doctype html> |
| 2 | +<meta charset=utf-8> |
| 3 | +<script src=/resources/testharness.js></script> |
| 4 | +<script src=/resources/testharnessreport.js></script> |
| 5 | +<div id="host"> |
| 6 | + <span id="slotted">slotted</span> |
| 7 | +</div> |
| 8 | +<span id="outer">outer</span> |
| 9 | +<script> |
| 10 | +test(function(t) { |
| 11 | + const sel = window.getSelection(); |
| 12 | + sel.setBaseAndExtent(slotted.firstChild, 3, outer.firstChild, 2); |
| 13 | + host.attachShadow({mode: "open"}).innerHTML = "<slot></slot><span>inner</span>"; |
| 14 | + |
| 15 | + assert_equals(sel.anchorNode, slotted.firstChild); |
| 16 | + assert_equals(sel.anchorOffset, 3); |
| 17 | + assert_equals(sel.focusNode, outer.firstChild); |
| 18 | + assert_equals(sel.focusOffset, 2); |
| 19 | + |
| 20 | + const composedRange = sel.getComposedRanges(host.shadowRoot)[0]; |
| 21 | + assert_equals(composedRange.startContainer, slotted.firstChild); |
| 22 | + assert_equals(composedRange.startOffset, 3); |
| 23 | + assert_equals(composedRange.endContainer, outer.firstChild); |
| 24 | + assert_equals(composedRange.endOffset, 2); |
| 25 | + |
| 26 | + sel.empty(); |
| 27 | + |
| 28 | + assert_equals(sel.anchorNode, null); |
| 29 | + assert_equals(sel.anchorOffset, 0); |
| 30 | + assert_equals(sel.focusNode, null); |
| 31 | + assert_equals(sel.focusOffset, 0); |
| 32 | +}, "test to select a light DOM element and it becomes a slotted content after the selection"); |
| 33 | +</script> |
0 commit comments