Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 type="application/javascript" 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">
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
20 /** Test for Bug 457672 **/
22 var windowBlurCount = 0;
24 function setUserPref(reset) {
25 if (reset) {
26 SpecialPowers.clearUserPref("browser.link.open_newwindow");
27 } else {
28 SpecialPowers.setIntPref("browser.link.open_newwindow", 3);
29 }
30 }
32 function listener(evt) {
33 if (evt.type == "focus") {
34 is(windowBlurCount, 1,
35 "Window should have got blur event when opening a new tab!");
36 setUserPref(true);
37 document.getElementsByTagName("a")[0].focus();
38 SimpleTest.finish();
39 } else if (evt.type == "blur") {
40 ++windowBlurCount;
41 }
42 document.getElementById('log').textContent += evt.target + ":" + evt.type + "\n";
43 }
45 function startTest() {
46 setUserPref(false);
47 document.getElementsByTagName("a")[0].focus();
48 // Note, focus/blur don't bubble
49 window.addEventListener("focus", listener, false);
50 window.addEventListener("blur", listener, false);
51 window.open("bug457672.html", "", "");
52 }
54 addLoadEvent(startTest);
55 SimpleTest.waitForExplicitFinish();
57 </script>
58 </pre>
59 <pre id="log">
60 </pre>
61 </body>
62 </html>