Skip to content

Commit

Permalink
Bug 1786805 - [devtools] Disable instant evaluation for top-level awa…
Browse files Browse the repository at this point in the history
…it expressions. r=jdescottes.

Differential Revision: https://phabricator.services.mozilla.com/D155687
  • Loading branch information
nchevobbe committed Aug 26, 2022
1 parent d72e2d4 commit e3dc5f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions devtools/client/webconsole/actions/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ function terminalInputChanged(expression, force = false) {
let mapped;
({ expression, mapped } = await getMappedExpression(hud, expression));

// We don't want to evaluate top-level await expressions (see Bug 1786805)
if (mapped?.await) {
return dispatch({
type: SET_TERMINAL_EAGER_RESULT,
expression,
result: null,
});
}

const response = await commands.scriptCommand.execute(expression, {
frameActor: hud.getSelectedFrameActorID(),
selectedNodeActor: webConsoleUI.getSelectedNodeActorID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ add_task(async function() {
setInputValue(hud, "4 + 7");
await waitForEagerEvaluationResult(hud, "11");

// go back to inline layout.
await toggleLayout(hud);

setInputValue(hud, "typeof new Proxy({}, {})");
await waitForEagerEvaluationResult(hud, `"object"`);

Expand Down Expand Up @@ -236,8 +239,10 @@ add_task(async function() {
setInputValue(hud, "array");
await waitForEagerEvaluationResult(hud, "Array(3) [ 1, 2, 3 ]");

// go back to inline layout.
await toggleLayout(hud);
info("Check that top-level await expression are not evaluated");
setInputValue(hud, "await 1; 2 + 3;");
await waitForNoEagerEvaluationResult(hud);
ok(true, "instant evaluation is disabled for top-level await expressions");
});

// Test that the currently selected autocomplete result is eagerly evaluated.
Expand Down

0 comments on commit e3dc5f6

Please sign in to comment.