test_selection_cross_shadow_boundary_1_backward_drag.html (1369B)
1 <!DOCTYPE HTML> 2 <script src="/tests/SimpleTest/EventUtils.js"></script> 3 <script src="/tests/SimpleTest/SimpleTest.js"></script> 4 <script type="application/javascript" src="/tests/layout/generic/test/selection_cross_shadow_boundary_helper.js"></script> 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 6 <script> 7 SimpleTest.waitForExplicitFinish(); 8 9 function run() { 10 document.getElementById("host").attachShadow({ mode: "open" }).innerHTML = "<span>InnerText</span>"; 11 12 const inner = host.shadowRoot.firstChild; 13 const rect = inner.getBoundingClientRect(); 14 15 // Drag from the bottom right of InnerText to the 16 // top left of OuterText. 17 drag( 18 inner, 19 rect.width, 20 rect.height, 21 document.getElementById("outer"), 22 0, 23 0); 24 25 // Above drag selects both "OuterText" and "InnerText" 26 const sel = document.getSelection().getComposedRanges(host.shadowRoot)[0]; 27 28 // backward selection 29 is(sel.endContainer, inner.firstChild, "endContainer is the InnerText"); 30 is(sel.endOffset, 9, "endOffset ends at the last character"); 31 is(sel.startContainer, outer.firstChild, "startContainer is the OuterText"); 32 is(sel.startOffset, 0, "startOffset starts at the first character"); 33 34 SimpleTest.finish(); 35 } 36 </script> 37 <body onload="SimpleTest.waitForFocus(run);"> 38 <span id="outer">OuterText</span> 39 <div id="host"></div> 40 </body>