Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 1be1928

Browse files
committed
Bug 851231 - Output Console.jsm API calls to the browser console; r=jwalker
1 parent 868d221 commit 1be1928

5 files changed

Lines changed: 489 additions & 58 deletions

File tree

browser/devtools/webconsole/test/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ MOCHITEST_BROWSER_FILES = \
121121
browser_console_variables_view_while_debugging.js \
122122
browser_console.js \
123123
browser_longstring_hang.js \
124+
browser_console_consolejsm_output.js \
124125
head.js \
125126
$(NULL)
126127

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Any copyright is dedicated to the Public Domain.
3+
* http://creativecommons.org/publicdomain/zero/1.0/
4+
*/
5+
6+
// Test that Console.jsm outputs messages to the Browser Console, bug 851231.
7+
8+
function test()
9+
{
10+
HUDConsoleUI.toggleBrowserConsole().then(consoleOpened);
11+
let hud = null;
12+
13+
function consoleOpened(aHud)
14+
{
15+
hud = aHud;
16+
hud.jsterm.clearOutput(true);
17+
18+
let console = Cu.import("resource://gre/modules/devtools/Console.jsm", {}).console;
19+
20+
console.time("foobarTimer");
21+
let foobar = { bug851231prop: "bug851231value" };
22+
23+
console.log("bug851231-log");
24+
console.info("bug851231-info");
25+
console.warn("bug851231-warn");
26+
console.error("bug851231-error", foobar);
27+
console.debug("bug851231-debug");
28+
console.trace();
29+
console.dir(document);
30+
console.timeEnd("foobarTimer");
31+
32+
info("wait for the Console.jsm messages");
33+
34+
waitForMessages({
35+
webconsole: hud,
36+
messages: [
37+
{
38+
name: "console.log output",
39+
text: "bug851231-log",
40+
category: CATEGORY_WEBDEV,
41+
severity: SEVERITY_LOG,
42+
},
43+
{
44+
name: "console.info output",
45+
text: "bug851231-info",
46+
category: CATEGORY_WEBDEV,
47+
severity: SEVERITY_INFO,
48+
},
49+
{
50+
name: "console.warn output",
51+
text: "bug851231-warn",
52+
category: CATEGORY_WEBDEV,
53+
severity: SEVERITY_WARNING,
54+
},
55+
{
56+
name: "console.error output",
57+
text: /\bbug851231-error\b.+\[object Object\]/,
58+
category: CATEGORY_WEBDEV,
59+
severity: SEVERITY_ERROR,
60+
objects: true,
61+
},
62+
{
63+
name: "console.debug output",
64+
text: "bug851231-debug",
65+
category: CATEGORY_WEBDEV,
66+
severity: SEVERITY_LOG,
67+
},
68+
{
69+
name: "console.trace output",
70+
consoleTrace: {
71+
file: "browser_console_consolejsm_output.js",
72+
fn: "consoleOpened",
73+
},
74+
},
75+
{
76+
name: "console.dir output",
77+
consoleDir: "[object XULDocument]",
78+
},
79+
{
80+
name: "console.time output",
81+
consoleTime: "foobarTimer",
82+
},
83+
{
84+
name: "console.timeEnd output",
85+
consoleTimeEnd: "foobarTimer",
86+
},
87+
],
88+
}).then((aResults) => {
89+
let consoleErrorMsg = aResults[3];
90+
ok(consoleErrorMsg, "console.error message element found");
91+
let clickable = consoleErrorMsg.clickableElements[0];
92+
ok(clickable, "clickable object found for console.error");
93+
94+
let onFetch = (aEvent, aVar) => {
95+
// Skip the notification from console.dir variablesview-fetched.
96+
if (aVar._variablesView != hud.jsterm._variablesView) {
97+
return;
98+
}
99+
hud.jsterm.off("variablesview-fetched", onFetch);
100+
101+
ok(aVar, "object inspector opened on click");
102+
103+
findVariableViewProperties(aVar, [{
104+
name: "bug851231prop",
105+
value: "bug851231value",
106+
}], { webconsole: hud }).then(finishTest);
107+
};
108+
109+
hud.jsterm.on("variablesview-fetched", onFetch);
110+
111+
scrollOutputToNode(clickable);
112+
113+
info("wait for variablesview-fetched");
114+
executeSoon(() =>
115+
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow));
116+
});
117+
}
118+
}

browser/devtools/webconsole/test/browser_longstring_hang.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ function test()
4242

4343
function onInitialString(aResults)
4444
{
45-
let msg = [...aResults[0].matched][0];
46-
ok(msg, "console.log result message element");
47-
48-
let clickable = msg.querySelector(".longStringEllipsis");
45+
let clickable = aResults[0].longStrings[0];
4946
ok(clickable, "long string ellipsis is shown");
5047

51-
scrollToVisible(clickable);
48+
scrollOutputToNode(clickable);
5249

5350
executeSoon(() => {
5451
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
@@ -73,16 +70,4 @@ function test()
7370
}).then(finishTest);
7471
});
7572
}
76-
77-
function scrollToVisible(aNode)
78-
{
79-
let richListBoxNode = aNode.parentNode;
80-
while (richListBoxNode.tagName != "richlistbox") {
81-
richListBoxNode = richListBoxNode.parentNode;
82-
}
83-
84-
let boxObject = richListBoxNode.scrollBoxObject;
85-
let nsIScrollBoxObject = boxObject.QueryInterface(Ci.nsIScrollBoxObject);
86-
nsIScrollBoxObject.ensureElementIsVisible(aNode);
87-
}
8873
}

0 commit comments

Comments
 (0)