summaryrefslogtreecommitdiffstats
path: root/layout/reftests/webcomponents/cross-tree-selection-1.html
blob: 01e7317f23c07e2d26d3502d0af11a45ff9bde22 (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
33
34
35
36
37
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
  <script>
    function tweak() {
      if (!document.body.createShadowRoot) {
        document.documentElement.className = "";
        return;
      }

      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>