forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser_dbg-returnvalues.js
More file actions
61 lines (49 loc) · 1.93 KB
/
Copy pathbrowser_dbg-returnvalues.js
File metadata and controls
61 lines (49 loc) · 1.93 KB
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
function getLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "scopeValue", index).innerText;
}
async function testReturnValue(dbg, val) {
invokeInTab("return_something", val);
await waitForPaused(dbg);
// "Step in" 2 times to get to the point where the debugger can
// see the return value.
await stepIn(dbg);
await stepIn(dbg);
is(getLabel(dbg, 1), "return_something", "check for return_something");
// We don't show "undefined" but we do show other falsy values.
let label = getLabel(dbg, 2);
if (val === "undefined") {
ok(label !== "<return>", "do not show <return> for undefined");
} else {
is(label, "<return>", "check for <return>");
// The "uneval" call here gives us the way one would write `val` as
// a JavaScript expression, similar to the way the debugger
// displays values, so this test works when `val` is a string.
is(getValue(dbg, 2), uneval(val), `check value is ${uneval(val)}`);
}
await resume(dbg);
assertNotPaused(dbg);
}
async function testThrowValue(dbg, val) {
invokeInTab("throw_something", val);
await waitForPaused(dbg);
// "Step in" once to get to the point where the debugger can see the
// exception.
await stepIn(dbg);
is(getLabel(dbg, 1), "callee", "check for callee");
is(getLabel(dbg, 2), "<exception>", "check for <exception>");
// The "uneval" call here gives us the way one would write `val` as
// a JavaScript expression, similar to the way the debugger
// displays values, so this test works when `val` is a string.
is(getValue(dbg, 2), uneval(val), `check exception is ${uneval(val)}`);
await resume(dbg);
assertNotPaused(dbg);
}
add_task(async function() {
const dbg = await initDebugger("doc-return-values.html");
await togglePauseOnExceptions(dbg, true, true);
await testReturnValue(dbg, "to sender");
await testThrowValue(dbg, "a fit");
});