This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix display of return value / thrown exception in scopes (#4569)
- Loading branch information
1 parent
e12186b
commit 2af4814
Showing
6 changed files
with
232 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function getLabel(dbg, index) { | ||
return findElement(dbg, "scopeNode", index).innerText; | ||
} | ||
|
||
function getValue(dbg, index) { | ||
return findElement(dbg, "scopeValue", index).innerText; | ||
} | ||
|
||
function toggleScopes(dbg) { | ||
return findElement(dbg, "scopesHeader").click(); | ||
} | ||
|
||
async function testReturnValue(dbg, val) { | ||
invokeInTab("return_something", val); | ||
await waitForPaused(dbg); | ||
|
||
// "Step in" 3 times to get to the point where the debugger can | ||
// see the return value. | ||
await stepIn(dbg); | ||
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); | ||
await waitForPaused(dbg); | ||
await resume(dbg); | ||
assertNotPaused(dbg); | ||
} | ||
|
||
add_task(async function() { | ||
const dbg = await initDebugger("doc-return-values.html"); | ||
toggleScopes(dbg); | ||
await togglePauseOnExceptions(dbg, true, false); | ||
|
||
await testReturnValue(dbg, "to sender"); | ||
await testThrowValue(dbg, "a fit"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.