content/base/test/test_bug333198.html

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

mercurial