|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 // Test the basic features of the Browser Console, bug 587757. |
|
7 |
|
8 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html?" + Date.now(); |
|
9 |
|
10 function test() |
|
11 { |
|
12 Services.obs.addObserver(function observer(aSubject) { |
|
13 Services.obs.removeObserver(observer, "web-console-created"); |
|
14 aSubject.QueryInterface(Ci.nsISupportsString); |
|
15 |
|
16 let hud = HUDService.getBrowserConsole(); |
|
17 ok(hud, "browser console is open"); |
|
18 is(aSubject.data, hud.hudId, "notification hudId is correct"); |
|
19 |
|
20 executeSoon(() => consoleOpened(hud)); |
|
21 }, "web-console-created", false); |
|
22 |
|
23 let hud = HUDService.getBrowserConsole(); |
|
24 ok(!hud, "browser console is not open"); |
|
25 info("wait for the browser console to open with ctrl-shift-j"); |
|
26 EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window); |
|
27 } |
|
28 |
|
29 function consoleOpened(hud) |
|
30 { |
|
31 hud.jsterm.clearOutput(true); |
|
32 |
|
33 expectUncaughtException(); |
|
34 executeSoon(() => { |
|
35 foobarExceptionBug587757(); |
|
36 }); |
|
37 |
|
38 // Add a message from a chrome window. |
|
39 hud.iframeWindow.console.log("bug587757a"); |
|
40 |
|
41 // Add a message from a content window. |
|
42 content.console.log("bug587757b"); |
|
43 |
|
44 // Test eval. |
|
45 hud.jsterm.execute("document.location.href"); |
|
46 |
|
47 // Check for network requests. |
|
48 let xhr = new XMLHttpRequest(); |
|
49 xhr.onload = () => console.log("xhr loaded, status is: " + xhr.status); |
|
50 xhr.open("get", TEST_URI, true); |
|
51 xhr.send(); |
|
52 |
|
53 waitForMessages({ |
|
54 webconsole: hud, |
|
55 messages: [ |
|
56 { |
|
57 name: "chrome window console.log() is displayed", |
|
58 text: "bug587757a", |
|
59 category: CATEGORY_WEBDEV, |
|
60 severity: SEVERITY_LOG, |
|
61 }, |
|
62 { |
|
63 name: "content window console.log() is displayed", |
|
64 text: "bug587757b", |
|
65 category: CATEGORY_WEBDEV, |
|
66 severity: SEVERITY_LOG, |
|
67 }, |
|
68 { |
|
69 name: "jsterm eval result", |
|
70 text: "browser.xul", |
|
71 category: CATEGORY_OUTPUT, |
|
72 severity: SEVERITY_LOG, |
|
73 }, |
|
74 { |
|
75 name: "exception message", |
|
76 text: "foobarExceptionBug587757", |
|
77 category: CATEGORY_JS, |
|
78 severity: SEVERITY_ERROR, |
|
79 }, |
|
80 { |
|
81 name: "network message", |
|
82 text: "test-console.html", |
|
83 category: CATEGORY_NETWORK, |
|
84 severity: SEVERITY_LOG, |
|
85 }, |
|
86 ], |
|
87 }).then(finishTest); |
|
88 } |