tor-browser

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

test_selection_cross_shadow_boundary_2_backward_click.html (1855B)


      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 
     17 
     18  const inner2 = root2.firstChild;
     19  const rect = inner2.getBoundingClientRect();
     20 
     21  // Click the bottom right of "InnerText2"
     22  synthesizeMouse(inner2, rect.width, rect.height, { type: "mousedown" });
     23  synthesizeMouse(inner2, rect.width, rect.height, { type: "mouseup" });
     24 
     25  // Click the top left of "OuterText1"
     26  synthesizeMouse(document.getElementById("outer1"), 0, 0, { type: "mousedown", shiftKey: true});
     27  synthesizeMouse(document.getElementById("outer1"), 0, 0, { type: "mouseup" , shiftKey: true});
     28 
     29  // Above clicks selects should select
     30  // "OuterText1", "OuterText2", "InnerText1" and "InnerText2".
     31  const sel = document.getSelection().getComposedRanges(root2)[0];
     32 
     33  // backward selection
     34  is(sel.endContainer, inner2.firstChild, "endContainer is the InnerText2");
     35  is(sel.endOffset, 10, "endOffset ends at the last character");
     36  is(sel.startContainer, outer1.firstChild, "startContainer is the OuterText1");
     37  is(sel.startOffset, 0, "startOffset starts at the first character");
     38 
     39  SimpleTest.finish();
     40 }
     41 </script>
     42 <body onload="SimpleTest.waitForFocus(run);">
     43  <span id="outer1">OuterText1</span>
     44  <div id="host1"></div>
     45  <span id="outer2">OuterText2</span>
     46  <div id="host2"></div>
     47 </body>