tor-browser

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

test_bug1339758.html (2409B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1339758
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1339758</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="/tests/SimpleTest/EventUtils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12  <script type="application/javascript">
     13 
     14  /** Test for Bug 1339758 */
     15  var expectNonZeroCoordinates = false;
     16  SimpleTest.waitForExplicitFinish();
     17 
     18  function testCoordinates(e) {
     19   var coordinateProperties =
     20     [ "screenX",
     21       "screenY",
     22       "clientX",
     23       "clientY",
     24       "offsetX",
     25       "offsetY",
     26       "movementX",
     27       "movementY",
     28       "layerX",
     29       "layerY",
     30       "x",
     31       "y" ];
     32    for (var i in coordinateProperties) {
     33      if (e[coordinateProperties[i]] != 0) {
     34        ok(expectNonZeroCoordinates, e.target.id + " got at least some non-zero coordinate property: " + i);
     35        return;
     36      }
     37    }
     38    ok(!expectNonZeroCoordinates, "Non-zero coordinates weren't expected");
     39  }
     40 
     41  function runTests() {
     42    info("Testing click events which should have only 0 coordinates.");
     43    document.getElementById("div_target").click();
     44    document.getElementById("a_target").focus();
     45    sendKey("RETURN");
     46    document.getElementById("input_target").focus();
     47    sendKey("RETURN");
     48 
     49    info("Testing click events which should have also non-zero coordinates.");
     50    expectNonZeroCoordinates = true;
     51    // Test script created MouseEvents
     52    sendMouseEvent({ type: "click"}, document.getElementById("a_target"));
     53    sendMouseEvent({ type: "click"}, document.getElementById("input_target"));
     54 
     55    // Test widget level mouse events
     56    synthesizeMouse(document.getElementById("a_target"), 2, 2, {});
     57    synthesizeMouse(document.getElementById("input_target"), 2, 2, {});
     58    SimpleTest.finish();
     59  }
     60 
     61  SimpleTest.waitForFocus(runTests);
     62 
     63 
     64  </script>
     65 </head>
     66 <body>
     67 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1339758">Mozilla Bug 1339758</a>
     68 <p id="display"></p>
     69 
     70 <div id="div_target" onclick="testCoordinates(event)">&nbsp;</div>
     71 <a href="#" id="a_target" onclick="testCoordinates(event);">test link</a><br>
     72 <input type="button" id="input_target" onclick="testCoordinates(event);" value="test button">
     73 
     74 <div id="content" style="display: none">
     75 
     76 </div>
     77 <pre id="test">
     78 </pre>
     79 </body>
     80 </html>