tor-browser

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

test_bug547996-2.xhtml (3563B)


      1 <?xml version="1.0"?>
      2 <html xmlns="http://www.w3.org/1999/xhtml"
      3      xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      4 <!--
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=547996
      6 -->
      7 <head>
      8  <title>Test for Bug 547996</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 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=547996">Mozilla Bug 547996</a>
     15 <p id="display"></p>
     16 <div id="content" style="display: none"></div>
     17 <pre id="test">
     18 <script type="application/javascript"><![CDATA[
     19 
     20 /** Test for Bug 547996 */
     21 /* mouseEvent.mozInputSource attribute */
     22 
     23 var expectedInputSource = null;
     24 
     25 function check(event) {
     26  is(event.mozInputSource, expectedInputSource, ".mozInputSource");
     27 }
     28 
     29 function doTest() {
     30  setup();
     31 
     32  expectedInputSource = MouseEvent.MOZ_SOURCE_KEYBOARD;
     33  testKeyboard();
     34 
     35  expectedInputSource = MouseEvent.MOZ_SOURCE_MOUSE;
     36  testMouse();
     37 
     38  expectedInputSource = MouseEvent.MOZ_SOURCE_UNKNOWN;
     39  testScriptedClicks();
     40 
     41  cleanup();
     42  SimpleTest.finish();
     43 }
     44 
     45 function testKeyboard() {
     46 
     47  $("inputTarget").focus();
     48  synthesizeKey("VK_SPACE", {});
     49  synthesizeKey("VK_RETURN", {});
     50 
     51  $("buttonTarget").focus();
     52  synthesizeKey("VK_SPACE", {});
     53  synthesizeKey("VK_RETURN", {});
     54 
     55  //XUL buttons do not generate click on ENTER or SPACE,
     56  //they do only on accessKey
     57 
     58  $("anchorTarget").focus();
     59  synthesizeKey("VK_RETURN", {});
     60 
     61  synthesizeKey("VK_TAB", {});
     62  synthesizeKey("VK_SPACE", {});
     63  synthesizeKey("VK_RIGHT", {});
     64 
     65  $("checkboxTarget").focus();
     66  synthesizeKey("VK_SPACE", {});
     67 
     68  var accessKeyDetails = (navigator.platform.includes("Mac")) ?
     69                          { ctrlKey : true } : { altKey : true, shiftKey: true };
     70 
     71  synthesizeKey("o", accessKeyDetails);
     72  synthesizeKey("t", accessKeyDetails);
     73 }
     74 
     75 function testMouse() {
     76  synthesizeMouse($("inputTarget"), 0, 0, {});
     77  synthesizeMouse($("buttonTarget"), 0, 0, {});
     78  synthesizeMouse($("anchorTarget"), 0, 0, {});
     79  synthesizeMouse($("radioTarget1"), 0, 0, {});
     80  synthesizeMouse($("radioTarget2"), 0, 0, {});
     81  synthesizeMouse($("checkboxTarget"), 0, 0, {});
     82 }
     83 
     84 function testScriptedClicks() {
     85  $("inputTarget").click();
     86  $("buttonTarget").click();
     87 }
     88 
     89 function setup() {
     90  $("inputTarget").addEventListener("click", check);
     91  $("buttonTarget").addEventListener("click", check);
     92  $("anchorTarget").addEventListener("click", check);
     93  $("radioTarget1").addEventListener("click", check);
     94  $("radioTarget2").addEventListener("click", check);
     95  $("checkboxTarget").addEventListener("click", check);
     96 
     97 }
     98 
     99 function cleanup() {
    100  $("inputTarget").removeEventListener("click", check);
    101  $("buttonTarget").removeEventListener("click", check);
    102  $("anchorTarget").removeEventListener("click", check);
    103  $("radioTarget1").removeEventListener("click", check);
    104  $("radioTarget2").removeEventListener("click", check);
    105  $("checkboxTarget").removeEventListener("click", check);
    106 }
    107 
    108 SimpleTest.waitForExplicitFinish();
    109 SimpleTest.waitForFocus(doTest, window);
    110 
    111 ]]></script>
    112 </pre>
    113 <input type="checkbox" id="checkboxTarget">Checkbox target</input>
    114 <input id="inputTarget" type="button" value="HTML Input" accesskey="o"/>
    115 <button id="buttonTarget">HTML Button</button>
    116 <a href="#" id="anchorTarget">Anchor</a>
    117 <input type="radio" id="radioTarget1" name="group">Radio Target 1</input>
    118 <input type="radio" id="radioTarget2" name="group">Radio Target 2</input>
    119 </body>
    120 </html>