tor-browser

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

test_bug417418.html (2558B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=417418
      5 -->
      6 <head>
      7  <title>Test for Bug 417418</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417418">Mozilla Bug 417418</a>
     14 <div id="display" contenteditable="true">
     15 <p id="coin">first paragraph</p>
     16 <p>second paragraph. <img id="img" src="green.png"></p>
     17 </div>
     18 <div id="content" style="display: none">
     19 
     20 </div>
     21 <pre id="test">
     22 <script class="testbody" type="text/javascript">
     23 
     24 /** Test for Bug 417418 */
     25 SimpleTest.waitForExplicitFinish();
     26 SimpleTest.waitForFocus(runTest);
     27 
     28 function resetSelection() {
     29  window.getSelection().collapse(document.getElementById("coin"), 0);
     30 }
     31 
     32 function runTest() {
     33    var rightClickDown = {type: "mousedown", button: 2},
     34        rightClickUp = {type: "mouseup", button: 2},
     35        singleClickDown = {type: "mousedown", button: 0},
     36        singleClickUp = {type: "mouseup", button: 0};
     37    var selection = window.getSelection();
     38 
     39    var div = document.getElementById("display");
     40    var img = document.getElementById("img");
     41    var divRect = div.getBoundingClientRect();
     42    var imgselected;
     43 
     44    resetSelection();
     45    synthesizeMouse(div, divRect.width - 1, divRect.height - 1, rightClickDown);
     46    synthesizeMouse(div, divRect.width - 1, divRect.height - 1, rightClickUp);
     47    ok(selection.isCollapsed, "selection is not collapsed");
     48 
     49    resetSelection();
     50    synthesizeMouse(div, divRect.width - 1, divRect.height - 1, singleClickDown);
     51    synthesizeMouse(div, divRect.width - 1, divRect.height - 1, singleClickUp);
     52    ok(selection.isCollapsed, "selection is not collapsed");
     53 
     54    resetSelection();
     55    synthesizeMouseAtCenter(img, rightClickDown);
     56    synthesizeMouseAtCenter(img, rightClickUp);
     57    imgselected = selection.anchorNode == img.parentNode &&
     58                      selection.anchorOffset === 1 &&
     59                      selection.rangeCount === 1;
     60    ok(imgselected, "image is not selected");
     61 
     62    resetSelection();
     63    synthesizeMouseAtCenter(img, singleClickDown);
     64    synthesizeMouseAtCenter(img, singleClickUp);
     65    imgselected = selection.anchorNode == img.parentNode &&
     66                      selection.anchorOffset === 1 &&
     67                      selection.rangeCount === 1;
     68    ok(imgselected, "image is not selected");
     69 
     70    SimpleTest.finish();
     71 }
     72 
     73 
     74 </script>
     75 </pre>
     76 </body>
     77 </html>