summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/ranges/Range-intersectsNode-shadow.html
blob: 8219ba8285a0085355beaa4646e40fb8b9f081b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!doctype html>
<title>Range.intersectsNode with Shadow DOM</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="host"></div>
<script>
test(() => {
  const host = document.getElementById("host");
  host.attachShadow({ mode: "open" }).innerHTML = `<span>ABC</span>`;

  const range = document.createRange();
  range.selectNode(document.body);

  assert_true(range.intersectsNode(host), "Should intersect host");
  assert_false(range.intersectsNode(host.shadowRoot), "Should not intersect shadow root");
  assert_false(range.intersectsNode(host.shadowRoot.firstElementChild), "Should not intersect shadow span");
}, "Range.intersectsNode() doesn't return true for shadow children in other trees");
</script>