tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_selection_cross_shadow_boundary_1_backward_click.html (1494B)


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