|
3 | 3 |
|
4 | 4 | "use strict"; |
5 | 5 |
|
6 | | -// Tests that pretty-printing updates console messages. |
| 6 | +async function waitForConsoleLink(dbg, text) { |
| 7 | + const toolbox = dbg.toolbox; |
| 8 | + const console = await toolbox.selectTool("webconsole"); |
| 9 | + const hud = console.hud; |
| 10 | + |
| 11 | + return waitFor(() => { |
| 12 | + // Wait until the message updates. |
| 13 | + const found = hud.ui.outputNode.querySelector(".frame-link-source"); |
| 14 | + if (!found) { |
| 15 | + return false; |
| 16 | + } |
| 17 | + |
| 18 | + const linkText = found.textContent; |
| 19 | + if (!text) { |
| 20 | + return linkText; |
| 21 | + } |
| 22 | + |
| 23 | + return linkText == text ? linkText : null; |
| 24 | + }); |
| 25 | +} |
7 | 26 |
|
| 27 | +// Tests that pretty-printing updates console messages. |
8 | 28 | add_task(async function() { |
9 | 29 | const dbg = await initDebugger("doc-minified.html"); |
10 | 30 | invokeInTab("arithmetic"); |
11 | 31 |
|
12 | 32 | info("Switch to console and check message"); |
13 | | - const toolbox = dbg.toolbox; |
14 | | - const console = await toolbox.selectTool("webconsole"); |
15 | | - const hud = console.hud; |
16 | | - |
17 | | - let node = await waitFor(() => |
18 | | - hud.ui.outputNode.querySelector(".frame-link-source") |
19 | | - ); |
20 | | - const initialLocation = "math.min.js:3:65"; |
21 | | - is(node.textContent, initialLocation, "location is correct in minified code"); |
| 33 | + await waitForConsoleLink(dbg, "math.min.js:3:65"); |
22 | 34 |
|
23 | 35 | info("Switch back to debugger and pretty-print"); |
24 | | - await toolbox.selectTool("jsdebugger"); |
| 36 | + await dbg.toolbox.selectTool("jsdebugger"); |
25 | 37 | await selectSource(dbg, "math.min.js", 2); |
26 | | - await waitForSelectedSource(dbg, "math.min.js"); |
27 | 38 |
|
28 | 39 | clickElement(dbg, "prettyPrintButton"); |
29 | | - |
30 | | - await waitForSource(dbg, "math.min.js:formatted"); |
31 | | - const ppSrc = findSource(dbg, "math.min.js:formatted"); |
32 | | - |
33 | | - ok(ppSrc, "Pretty-printed source exists"); |
| 40 | + await waitForSelectedSource(dbg, "math.min.js:formatted"); |
34 | 41 |
|
35 | 42 | info("Switch back to console and check message"); |
36 | | - node = await waitFor(() => { |
37 | | - // Wait until the message updates. |
38 | | - const found = hud.ui.outputNode.querySelector(".frame-link-source"); |
39 | | - if (found.textContent == initialLocation) { |
40 | | - return null; |
41 | | - } |
42 | | - return found; |
43 | | - }); |
44 | | - |
45 | | - is( |
46 | | - node.textContent, |
47 | | - "math.min.js:formatted:22", |
48 | | - "location is correct in minified code" |
49 | | - ); |
| 43 | + await waitForConsoleLink(dbg, "math.min.js:formatted:22"); |
| 44 | + ok(true); |
50 | 45 | }); |
0 commit comments