test-print-selection-shadow-dom.html (821B)
1 <!DOCTYPE html> 2 <html reftest-print-range="selection"> 3 <head> 4 <meta charset="utf-8"> 5 <link href="print.css" rel="stylesheet"> 6 <script> 7 function selectNodesInShadowTree() { 8 let host = document.getElementById("host"); 9 host.attachShadow({ mode: "open" }).innerHTML = ` 10 <p>This text should not be there</p> 11 <p id="selection">This text should appear on page 1</p> 12 <p>This text should not be there</p> 13 `; 14 let rng = document.createRange(); 15 rng.selectNode(host.shadowRoot.getElementById("selection")); 16 window.getSelection().addRange(rng); 17 } 18 </script> 19 </head> 20 <body onload="selectNodesInShadowTree()"> 21 <p>This text should not be there</p> 22 <div id="host">Shouldn't show up (in the shadows)</div> 23 <p>This text should not be there</p> 24 </body> 25 </html>