Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=608030
5 -->
6 <head>
7 <title>Test for MozAfterPaint pref Bug 608030</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=608030">Mozilla Bug 608030</a>
13 <div id="display" style="width: 10em; height: 5em; background-color: red"></div>
14 <pre id="test">
15 <script type="application/javascript">
17 /** Test for Bug 608030 **/
19 function get_pref()
20 {
21 return SpecialPowers.getBoolPref("dom.send_after_paint_to_content");
22 }
24 function set_pref(val)
25 {
26 SpecialPowers.setBoolPref("dom.send_after_paint_to_content", val);
27 }
29 SimpleTest.waitForExplicitFinish();
31 window.addEventListener("load", step0, false);
33 is(get_pref(), true, "pref defaults to true in mochitest harness");
35 function print_rect(rect) {
36 return "(top=" + rect.top + ",left=" + rect.left + ",width=" + rect.width + ",height=" + rect.height + ")";
37 }
39 function print_event(event) {
40 var res = "boundingClientRect=" + print_rect(event.boundingClientRect);
41 var rects = event.clientRects;
42 for (var i = 0; i < rects.length; ++i) {
43 res += " clientRects[" + i + "]=" + print_rect(rects[i]);
44 }
45 return res;
46 }
48 function step0(event) {
49 // Wait until we get the MozAfterPaint following the load event
50 // before starting.
51 ok(true, "loaded");
52 window.addEventListener("MozAfterPaint", step1, false);
54 // Ensure a MozAfterPaint event is fired
55 div.style.backgroundColor = "yellow";
56 }
58 var start;
59 var div = document.getElementById("display");
61 function step1(event)
62 {
63 ok(true, "step1 reached: " + print_event(event));
64 window.removeEventListener("MozAfterPaint", step1, false);
66 start = Date.now();
68 window.addEventListener("MozAfterPaint", step2, false);
70 div.style.backgroundColor = "blue";
71 }
73 function step2(event)
74 {
75 ok(true, "step2 reached: " + print_event(event));
76 window.removeEventListener("MozAfterPaint", step2, false);
78 var end = Date.now();
79 var timeout = 3 * Math.max(end - start, 300);
81 ok(true, "got MozAfterPaint (timeout for next step is " + timeout + "ms)");
83 // Set the pref for our second test
84 set_pref(false);
86 // When there was previously another page in our window, we seem to
87 // get duplicate events, simultaneously, so we need to register our
88 // next listener after a zero timeout.
89 setTimeout(step3, 0, timeout);
90 }
91 function step3(timeout)
92 {
93 ok(true, "step3 reached");
94 window.addEventListener("MozAfterPaint", failstep, false);
96 div.style.backgroundColor = "fuchsia";
98 setTimeout(step4, timeout);
99 }
101 function failstep(event)
102 {
103 ok(true, "failstep reached: " + print_event(event));
104 ok(false, "got MozAfterPaint when we should not have");
105 }
107 function step4()
108 {
109 ok(true, "step4 reached"); // If we didn't get the failure in failstep,
110 // then we passed.
112 window.removeEventListener("MozAfterPaint", failstep, false);
114 // Set the pref back in its initial state.
115 set_pref(true);
117 SimpleTest.finish();
118 }
120 </script>
121 </pre>
122 </body>
123 </html>