summaryrefslogtreecommitdiffstats
path: root/layout/reftests/webcomponents/cross-tree-selection-1.html
blob: 1e4f027479e31ba7291736211db7241c4e0cd4eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
  <script>
    function tweak() {
      var host = document.getElementById("host");
      var shadow = host.createShadowRoot();

      var textNode = document.createTextNode(" World");
      shadow.appendChild(textNode);

      // Create a selection with focus preceeding anchor
      var selection = window.getSelection();
      var range = document.createRange();
      range.setStart(shadow, 1);
      range.setEnd(shadow, 1);
      selection.addRange(range);
      selection.extend(shadow, 0);

      // Extend selection into a different node tree
      // (from ShadowRoot into the previous node in the parent node tree).
      setTimeout(function() {
        selection.extend(document.getElementById("previous"), 0);
        document.documentElement.className = '';
      }, 100);
    }
  </script>
</head>
<body onload="tweak()">
<span id="previous">Hello</span><span id="host"></span>
</body>
</html>