test_selection_cross_shadow_boundary_2_backward_drag.html (1630B)
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 const root1 = document.getElementById("host1").attachShadow({ mode: "open" }); 11 root1.innerHTML = "InnerText1"; 12 13 const root2 = document.getElementById("host2").attachShadow({ mode: "open" }); 14 root2.innerHTML = "<span>InnerText2</span>"; 15 16 const inner2 = root2.firstChild; 17 const rect = inner2.getBoundingClientRect(); 18 19 const outer1 = document.getElementById("outer1"); 20 // Drag from the bottom right of InnerText2 to 21 // the top left of OuterText1. 22 drag( 23 inner2, 24 rect.width, 25 rect.height, 26 outer1, 27 0, 28 0); 29 30 // Above drag should selects 31 // "OuterText1", "OuterText2", "InnerText1" and "InnerText2". 32 const sel = document.getSelection().getComposedRanges(root2)[0]; 33 34 // backward selection 35 is(sel.endContainer, inner2.firstChild, "endContainer is the InnerText2"); 36 is(sel.endOffset, 10, "endOffset ends at the last character"); 37 is(sel.startContainer, outer1.firstChild, "startContainer is the OuterText1"); 38 is(sel.startOffset, 0, "startOffset starts at the first character"); 39 40 SimpleTest.finish(); 41 } 42 </script> 43 <body onload="SimpleTest.waitForFocus(run);"> 44 <span id="outer1">OuterText1</span> 45 <div id="host1"></div> 46 <span id="outer2">OuterText2</span> 47 <div id="host2"></div> 48 </body>