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 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 // Test the basic features of the Browser Console, bug 587757.
8 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html?" + Date.now();
10 function test()
11 {
12 Services.obs.addObserver(function observer(aSubject) {
13 Services.obs.removeObserver(observer, "web-console-created");
14 aSubject.QueryInterface(Ci.nsISupportsString);
16 let hud = HUDService.getBrowserConsole();
17 ok(hud, "browser console is open");
18 is(aSubject.data, hud.hudId, "notification hudId is correct");
20 executeSoon(() => consoleOpened(hud));
21 }, "web-console-created", false);
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 }
29 function consoleOpened(hud)
30 {
31 hud.jsterm.clearOutput(true);
33 expectUncaughtException();
34 executeSoon(() => {
35 foobarExceptionBug587757();
36 });
38 // Add a message from a chrome window.
39 hud.iframeWindow.console.log("bug587757a");
41 // Add a message from a content window.
42 content.console.log("bug587757b");
44 // Test eval.
45 hud.jsterm.execute("document.location.href");
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();
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 }