tor-browser

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

test_bug457672.html (1480B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=457672
      5 -->
      6 <head>
      7  <title>Test for Bug 457672</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=457672">Mozilla Bug 457672</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15  
     16 </div>
     17 <pre id="test">
     18 <script type="application/javascript">
     19 
     20 /** Test for Bug 457672 */
     21 
     22 var windowBlurCount = 0;
     23 
     24 function listener(evt) {
     25  if (evt.type == "focus") {
     26    is(windowBlurCount, 1,
     27       "Window should have got blur event when opening a new tab!");
     28    document.getElementsByTagName("a")[0].focus();
     29    SimpleTest.finish();
     30  } else if (evt.type == "blur") {
     31    ++windowBlurCount;
     32  }
     33  document.getElementById('log').textContent += evt.target + ":" + evt.type + "\n";
     34 }
     35 
     36 function startTest() {
     37  SpecialPowers.pushPrefEnv({"set": [["browser.link.open_newwindow", 3]]}, function() {
     38    document.getElementsByTagName("a")[0].focus();
     39    // Note, focus/blur don't bubble
     40    window.addEventListener("focus", listener);
     41    window.addEventListener("blur", listener);
     42    var subwin = window.open("about:blank", "", "");
     43    subwin.addEventListener("focus", function(e) { subwin.close(); });
     44  });
     45 }
     46 
     47 addLoadEvent(startTest);
     48 SimpleTest.waitForExplicitFinish();
     49 
     50 </script>
     51 </pre>
     52 <pre id="log">
     53 </pre>
     54 </body>
     55 </html>