1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that message source links for js errors and console API calls open in
// the jsdebugger when clicked.
"use strict";
// There are shutdown issues for which multiple rejections are left uncaught.
// See bug 1018184 for resolving these issues.
PromiseTestUtils.allowMatchingRejectionsGlobally(/Component not initialized/);
PromiseTestUtils.allowMatchingRejectionsGlobally(/this\.worker is null/);
const TEST_URI =
"http://example.com/browser/devtools/client/webconsole/" +
"test/browser/" +
"test-stacktrace-location-debugger-link.html";
add_task(async function () {
const hud = await openNewTabAndConsole(TEST_URI);
const toolbox = await gDevTools.getToolboxForTab(gBrowser.selectedTab);
await testOpenFrameInDebugger(hud, toolbox, "console.trace()");
await testOpenFrameInDebugger(hud, toolbox, "myErrorObject");
});
async function testOpenFrameInDebugger(hud, toolbox, text) {
info(`Testing message with text "${text}"`);
const messageNode = await waitFor(() => findConsoleAPIMessage(hud, text));
const framesNode = await waitFor(() => messageNode.querySelector(".frames"));
const frameNodes = framesNode.querySelectorAll(".frame");
is(
frameNodes.length,
3,
"The message does have the expected number of frames in the stacktrace"
);
for (const frameNode of frameNodes) {
await checkMousedownOnNode(hud, toolbox, frameNode);
info("Selecting the console again");
await toolbox.selectTool("webconsole");
}
}
async function checkMousedownOnNode(hud, toolbox, frameNode) {
info("checking click on node location");
const onSourceInDebuggerOpened = once(hud, "source-in-debugger-opened");
EventUtils.sendMouseEvent(
{ type: "mousedown" },
frameNode.querySelector(".location")
);
await onSourceInDebuggerOpened;
const url = frameNode.querySelector(".filename").textContent;
const dbg = toolbox.getPanel("jsdebugger");
is(
dbg._selectors.getSelectedSource(dbg._getState()).url,
url,
`Debugger is opened at expected source url (${url})`
);
}
|