|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 // Check that cached messages from nested iframes are displayed in the |
|
7 // Web/Browser Console. |
|
8 |
|
9 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-consoleiframes.html"; |
|
10 |
|
11 let expectedMessages = [ |
|
12 { |
|
13 text: "main file", |
|
14 category: CATEGORY_WEBDEV, |
|
15 severity: SEVERITY_LOG, |
|
16 }, |
|
17 { |
|
18 text: "blah", |
|
19 category: CATEGORY_JS, |
|
20 severity: SEVERITY_ERROR |
|
21 }, |
|
22 { |
|
23 text: "iframe 2", |
|
24 category: CATEGORY_WEBDEV, |
|
25 severity: SEVERITY_LOG |
|
26 }, |
|
27 { |
|
28 text: "iframe 3", |
|
29 category: CATEGORY_WEBDEV, |
|
30 severity: SEVERITY_LOG |
|
31 } |
|
32 ]; |
|
33 |
|
34 // "iframe 1" console messages can be coalesced into one if they follow each |
|
35 // other in the sequence of messages (depending on timing). If they do not, then |
|
36 // they will be displayed in the console output independently, as separate |
|
37 // messages. This is why we need to match any of the following two rules. |
|
38 let expectedMessagesAny = [ |
|
39 { |
|
40 name: "iframe 1 (count: 2)", |
|
41 text: "iframe 1", |
|
42 category: CATEGORY_WEBDEV, |
|
43 severity: SEVERITY_LOG, |
|
44 count: 2 |
|
45 }, |
|
46 { |
|
47 name: "iframe 1 (repeats: 2)", |
|
48 text: "iframe 1", |
|
49 category: CATEGORY_WEBDEV, |
|
50 severity: SEVERITY_LOG, |
|
51 repeats: 2 |
|
52 }, |
|
53 ]; |
|
54 |
|
55 function test() |
|
56 { |
|
57 expectUncaughtException(); |
|
58 addTab(TEST_URI); |
|
59 browser.addEventListener("load", function onLoad() { |
|
60 browser.removeEventListener("load", onLoad, true); |
|
61 info("open web console"); |
|
62 openConsole(null, consoleOpened); |
|
63 }, true); |
|
64 } |
|
65 |
|
66 function consoleOpened(hud) |
|
67 { |
|
68 ok(hud, "web console opened"); |
|
69 |
|
70 waitForMessages({ |
|
71 webconsole: hud, |
|
72 messages: expectedMessages, |
|
73 }).then(() => { |
|
74 info("first messages matched"); |
|
75 waitForMessages({ |
|
76 webconsole: hud, |
|
77 messages: expectedMessagesAny, |
|
78 matchCondition: "any", |
|
79 }).then(() => { |
|
80 closeConsole(null, onWebConsoleClose); |
|
81 }); |
|
82 }); |
|
83 } |
|
84 |
|
85 function onWebConsoleClose() |
|
86 { |
|
87 info("web console closed"); |
|
88 HUDService.toggleBrowserConsole().then(onBrowserConsoleOpen); |
|
89 } |
|
90 |
|
91 function onBrowserConsoleOpen(hud) |
|
92 { |
|
93 ok(hud, "browser console opened"); |
|
94 waitForMessages({ |
|
95 webconsole: hud, |
|
96 messages: expectedMessages, |
|
97 }).then(() => { |
|
98 info("first messages matched"); |
|
99 waitForMessages({ |
|
100 webconsole: hud, |
|
101 messages: expectedMessagesAny, |
|
102 matchCondition: "any", |
|
103 }).then(() => { |
|
104 closeConsole(null, finishTest); |
|
105 }); |
|
106 }); |
|
107 } |