tor-browser

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

test_bug603550.html (3032B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=603550
      5 -->
      6 <head>
      7  <title>Test for Bug 603550</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  <style>
     12  .test {
     13    width: 20px;
     14    height: 20px;
     15    border: 1px solid black;
     16    -moz-user-select: none;
     17  }
     18  </style>
     19 </head>
     20 <body onload="setTimeout('runTest()', 0)">
     21 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=603550">Mozilla Bug 603550</a>
     22 <p id="display"></p>
     23 <div id="content" style="display: none">
     24  
     25 </div>
     26 <pre id="test">
     27 <script type="application/javascript">
     28 
     29 /** Test for Bug 603550 */
     30 
     31 SimpleTest.waitForExplicitFinish();
     32 
     33 function sendMouseMoveFaraway(el) {
     34  synthesizeMouse(el, 5000, 5000, { type: "mousemove" });
     35 }
     36 
     37 function sendMouseDown(el) {
     38  synthesizeMouse(el, 5, 5, { type: "mousedown" });
     39 }
     40 
     41 function sendMouseUp(el) {
     42  synthesizeMouse(el, 5, 5, { type: "mouseup" });
     43 }
     44 
     45 function fireEvent(target, event) {
     46  var utils = SpecialPowers.getDOMWindowUtils(window);
     47  utils.dispatchDOMEventViaPresShellForTesting(target, event);
     48 }
     49 
     50 function fireDrop(element) {
     51  var ds = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"].
     52    getService(SpecialPowers.Ci.nsIDragService);
     53 
     54  ds.startDragSessionForTests(
     55    window,
     56    SpecialPowers.Ci.nsIDragService.DRAGDROP_ACTION_MOVE |
     57      SpecialPowers.Ci.nsIDragService.DRAGDROP_ACTION_COPY |
     58      SpecialPowers.Ci.nsIDragService.DRAGDROP_ACTION_LINK
     59  ); // Session for getting dataTransfer object.
     60  try {
     61    var event = document.createEvent("DragEvent");
     62    event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
     63    fireEvent(element, event);
     64 
     65    event = document.createEvent("DragEvent");
     66    event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
     67    fireEvent(element, event);
     68  } finally {
     69    ds.getCurrentSession().endDragSession(false);
     70    ok(!ds.getCurrentSession(), "There shouldn't be a drag session anymore!");
     71  }
     72 }
     73 
     74 function runTest() {
     75  var d1 = document.getElementById("d1");
     76  var didGetMouseMove = false;
     77  sendMouseDown(d1);
     78  document.addEventListener("mousemove",
     79    function (e) {
     80      didGetMouseMove = (e.target == document);
     81    },
     82    true);
     83  sendMouseMoveFaraway(d1);
     84  ok(didGetMouseMove, "Should have got mousemove!");
     85  sendMouseUp(d1);
     86  
     87  didGetMouseMove = false;
     88  document.addEventListener("mousedown",
     89    function (e) {
     90      e.preventDefault();
     91    },
     92    true);
     93  sendMouseDown(d1);
     94  sendMouseMoveFaraway(d1);
     95  ok(didGetMouseMove, "Should have got mousemove! (2)");
     96  sendMouseUp(d1);
     97  
     98  didGetMouseMove = false;
     99  sendMouseDown(d1);
    100  fireDrop(d1);
    101  sendMouseMoveFaraway(d1);
    102  ok(!didGetMouseMove, "Shouldn't have got mousemove!");
    103  
    104  
    105  
    106  SimpleTest.finish();
    107 }
    108 
    109 
    110 </script>
    111 </pre>
    112 <div class="test" id="d1">&nbsp;</div>
    113 </body>
    114 </html>