|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 // Check that clear output on page reload works - bug 705921. |
|
7 |
|
8 function test() |
|
9 { |
|
10 const PREF = "devtools.webconsole.persistlog"; |
|
11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; |
|
12 let hud = null; |
|
13 |
|
14 Services.prefs.setBoolPref(PREF, false); |
|
15 registerCleanupFunction(() => Services.prefs.clearUserPref(PREF)); |
|
16 |
|
17 addTab(TEST_URI); |
|
18 |
|
19 browser.addEventListener("load", function onLoad() { |
|
20 browser.removeEventListener("load", onLoad, true); |
|
21 openConsole(null, consoleOpened); |
|
22 }, true); |
|
23 |
|
24 function consoleOpened(aHud) |
|
25 { |
|
26 hud = aHud; |
|
27 ok(hud, "Web Console opened"); |
|
28 |
|
29 hud.jsterm.clearOutput(); |
|
30 content.console.log("foobarz1"); |
|
31 waitForMessages({ |
|
32 webconsole: hud, |
|
33 messages: [{ |
|
34 text: "foobarz1", |
|
35 category: CATEGORY_WEBDEV, |
|
36 severity: SEVERITY_LOG, |
|
37 }], |
|
38 }).then(onConsoleMessage); |
|
39 } |
|
40 |
|
41 function onConsoleMessage() |
|
42 { |
|
43 browser.addEventListener("load", onReload, true); |
|
44 content.location.reload(); |
|
45 } |
|
46 |
|
47 function onReload() |
|
48 { |
|
49 browser.removeEventListener("load", onReload, true); |
|
50 |
|
51 content.console.log("foobarz2"); |
|
52 |
|
53 waitForMessages({ |
|
54 webconsole: hud, |
|
55 messages: [{ |
|
56 text: "test-console.html", |
|
57 category: CATEGORY_NETWORK, |
|
58 }, |
|
59 { |
|
60 text: "foobarz2", |
|
61 category: CATEGORY_WEBDEV, |
|
62 severity: SEVERITY_LOG, |
|
63 }], |
|
64 }).then(onConsoleMessageAfterReload); |
|
65 } |
|
66 |
|
67 function onConsoleMessageAfterReload() |
|
68 { |
|
69 is(hud.outputNode.textContent.indexOf("foobarz1"), -1, |
|
70 "foobarz1 has been removed from output"); |
|
71 finishTest(); |
|
72 } |
|
73 } |