summaryrefslogtreecommitdiffstats
path: root/layout/reftests/printing/test-print-selection-shadow-dom.html
blob: c2681319947025d60f7b929f47338a7a75260178 (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
<!DOCTYPE html>
<html reftest-print-range="selection">
<head>
  <meta charset="utf-8">
  <link href="print.css" rel="stylesheet">
  <script>
    function selectNodesInShadowTree() {
      let host = document.getElementById("host");
      host.attachShadow({ mode: "open" }).innerHTML = `
        <p>This text should not be there</p>
        <p id="selection">This text should appear on page 1</p>
        <p>This text should not be there</p>
      `;
      let rng = document.createRange();
      rng.selectNode(host.shadowRoot.getElementById("selection"));
      window.getSelection().addRange(rng);
    }
  </script>
</head>
<body onload="selectNodesInShadowTree()">
  <p>This text should not be there</p>
  <div id="host">Shouldn't show up (in the shadows)</div>
  <p>This text should not be there</p>
</body>
</html>