tor-browser

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

test_bug333198.html (2145B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=333198
      5 -->
      6 <head>
      7  <title>Test for Bug 333198</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 <!-- setTimeout so that the test starts after paint suppression ends -->
     13 <body onload="setTimeout(runTest,0);">
     14 <iframe id="ifr"></iframe><br>
     15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=333198">Mozilla Bug 333198</a>
     16 <p id="display"></p>
     17 <div id="content" style="display: none">
     18  
     19 </div>
     20 <pre id="test">
     21 <script type="application/javascript">
     22 
     23 /** Test for Bug 333198 */
     24 
     25 var focusTester;
     26 var focusTester2;
     27 var focusCount = 0;
     28 var eventCount = 0;
     29 function clickHandler() {
     30  ++eventCount;
     31 }
     32 
     33 function suppressEvents(suppress) {
     34  SpecialPowers.DOMWindowUtils.suppressEventHandling(suppress);
     35 }
     36 
     37 function sendEvents() {
     38  synthesizeMouseAtPoint(1, 1, {});
     39  synthesizeMouseAtPoint(1, 1, {}, document.getElementById("ifr").contentWindow);
     40 }
     41 
     42 function runTest() {
     43  window.focus();
     44  focusTester = document.getElementsByTagName("input")[0];
     45  focusTester.blur();
     46  window.addEventListener("click", clickHandler, true);
     47  var ifr = document.getElementById("ifr")
     48  ifr.contentWindow.addEventListener("click", clickHandler, true);
     49  sendEvents();
     50  is(eventCount, 2, "Wrong event count(1)");
     51  suppressEvents(true);
     52  sendEvents();
     53  is(eventCount, 2, "Wrong event count(2)");
     54  suppressEvents(false);
     55  sendEvents();
     56  is(eventCount, 4, "Wrong event count(2)");
     57 
     58  is(focusCount, 0, "Wrong focus count (1)");
     59  var xhr = new XMLHttpRequest();
     60  xhr.open("GET", window.location, false);
     61  xhr.onload = function() {
     62                 focusTester.focus();
     63                 is(focusCount, 1, "Wrong focus count (2)");
     64                 focusTester.blur();
     65               }
     66  xhr.send();
     67 
     68  focusTester.focus();
     69  is(focusCount, 2, "Wrong focus count (3)");
     70 
     71  SimpleTest.finish();
     72 }
     73 
     74 SimpleTest.waitForExplicitFinish();
     75 
     76 </script>
     77 </pre>
     78 <input type="text" onfocus="++focusCount;">
     79 </body>
     80 </html>