tor-browser

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

test_bug411236.html (1973B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=411236
      5 -->
      6 <head>
      7  <title>Test for Bug 411236</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=411236">Mozilla Bug 411236</a>
     14 <p id="display"></p>
     15 <div id="content">
     16  <input type="file" onfocus="window.oTarget = event.originalTarget;"
     17         onclick="window.fileInputGotClick = true; return false;"
     18         id="fileinput">
     19 </div>
     20 <pre id="test">
     21 <script class="testbody" type="text/javascript">
     22 
     23 /** Test for Bug 411236 */
     24 
     25 window.oTarget = null;
     26 window.fileInputGotClick = false;
     27 
     28 function test() {
     29  // Try to find the '<input>' using tabbing.
     30  var i = 0;
     31  while (!window.oTarget && i < 100) {
     32    ++i;
     33    synthesizeKey("KEY_Tab");
     34  }
     35 
     36  if (i >= 100) {
     37    ok(false, "Couldn't find an input element!");
     38    SimpleTest.finish();
     39    return;
     40  }
     41 
     42  ok(window.oTarget instanceof HTMLInputElement, "Should have focused the input element!");
     43  var e = document.createEvent("mouseevents");
     44  e.initMouseEvent("click", true, true, window, 0, 1, 1, 1, 1,
     45                    false, false, false, false, 0, null);
     46  SpecialPowers.wrap(window.oTarget).dispatchEvent(e);
     47  ok(window.fileInputGotClick,
     48     "File input should have got a click event, but not open the file dialog.");
     49  SimpleTest.finish();
     50 }
     51 
     52 function beginTest() {
     53  // accessibility.tabfocus must be set to value 7 before running test also
     54  // on a mac.
     55  SpecialPowers.pushPrefEnv({"set": [["accessibility.tabfocus", 7]]}, do_test);
     56 }
     57 
     58 function do_test() {
     59  window.focus();
     60  document.getElementById('fileinput').focus();
     61  setTimeout(test, 100);
     62 }
     63 
     64 SimpleTest.waitForExplicitFinish();
     65 SimpleTest.requestFlakyTimeout("untriaged");
     66 addLoadEvent(beginTest);
     67 
     68 </script>
     69 </pre>
     70 </body>
     71 </html>