|
1 <!DOCTYPE HTML> |
|
2 <html lang="en"> |
|
3 <head> |
|
4 <meta charset="utf8"> |
|
5 <title>Test for the Reflow Activity</title> |
|
6 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
7 <script type="text/javascript;version=1.8" src="common.js"></script> |
|
8 <!-- Any copyright is dedicated to the Public Domain. |
|
9 - http://creativecommons.org/publicdomain/zero/1.0/ --> |
|
10 </head> |
|
11 <body> |
|
12 <p>Test for reflow events</p> |
|
13 |
|
14 <script class="testbody" type="text/javascript;version=1.8"> |
|
15 SimpleTest.waitForExplicitFinish(); |
|
16 |
|
17 let client; |
|
18 |
|
19 function generateReflow() |
|
20 { |
|
21 top.document.documentElement.style.display = "none"; |
|
22 top.document.documentElement.getBoundingClientRect(); |
|
23 top.document.documentElement.style.display = "block"; |
|
24 } |
|
25 |
|
26 function startTest() |
|
27 { |
|
28 removeEventListener("load", startTest); |
|
29 attachConsole(["ReflowActivity"], onAttach, true); |
|
30 } |
|
31 |
|
32 function onAttach(aState, aResponse) |
|
33 { |
|
34 client = aState.dbgClient; |
|
35 |
|
36 onReflowActivity = onReflowActivity.bind(null, aState); |
|
37 client.addListener("reflowActivity", onReflowActivity); |
|
38 generateReflow(); |
|
39 } |
|
40 |
|
41 // We are expecting 3 reflow events. |
|
42 let expectedEvents = [ |
|
43 { |
|
44 interruptible: false, |
|
45 sourceURL: "chrome://mochitests/content/chrome/toolkit/devtools/webconsole/test/test_reflow.html", |
|
46 functionName: "generateReflow" |
|
47 }, |
|
48 { |
|
49 interruptible: true, |
|
50 sourceURL: null, |
|
51 functionName: null |
|
52 }, |
|
53 { |
|
54 interruptible: true, |
|
55 sourceURL: null, |
|
56 functionName: null |
|
57 }, |
|
58 ]; |
|
59 |
|
60 let receivedEvents = []; |
|
61 |
|
62 |
|
63 function onReflowActivity(aState, aType, aPacket) |
|
64 { |
|
65 info("packet: " + aPacket.message); |
|
66 receivedEvents.push(aPacket); |
|
67 if (receivedEvents.length == expectedEvents.length) { |
|
68 checkEvents(); |
|
69 finish(aState); |
|
70 } |
|
71 } |
|
72 |
|
73 function checkEvents() { |
|
74 for (let i = 0; i < expectedEvents.length; i++) { |
|
75 let a = expectedEvents[i]; |
|
76 let b = receivedEvents[i]; |
|
77 for (let key in a) { |
|
78 is(a[key], b[key], "field " + key + " is valid"); |
|
79 } |
|
80 } |
|
81 } |
|
82 |
|
83 function finish(aState) { |
|
84 client.removeListener("reflowActivity", onReflowActivity); |
|
85 closeDebugger(aState, function() { |
|
86 SimpleTest.finish(); |
|
87 }); |
|
88 } |
|
89 |
|
90 addEventListener("load", startTest); |
|
91 |
|
92 </script> |
|
93 </body> |
|
94 </html> |