await does not work in Browser Console

RESOLVED FIXED in Firefox 64

Status

defect
P1
normal
RESOLVED FIXED
7 months ago
6 months ago

People

(Reporter: mythmon, Assigned: nchevobbe)

Tracking

unspecified
Firefox 64
x86_64
Linux
Dependency tree / graph

Firefox Tracking Flags

(firefox64 fixed)

Details

(Whiteboard: [good first verify])

Attachments

(1 attachment)

(Reporter)

Description

7 months ago
Although `await 42;` works as expected in the Web Console, the Browser Toolbox, and the Browser Content Toolbox (printing 42), in the Browser Console it returns the error "SyntaxError: await is only valid in async functions and async generators".

STR:

1. Open the Browser Console (Tools > Web Developer > Browser Console, or Ctrl+Shift+J on Linux)
2. Type "await 42;" and press enter.

Expected:

The console prints "42".

Actual:

The console prints an error.

This might be a dupe of bug 1494726, but I'm not sure where the error happened in that bug.
This isn't a dupe of bug 1494726, it's a separate issue. The problem is that the parser worker is fetched through the toolbox object, and when we are in the Browser Console there's no toolbox available.

I hope that we can expose parser-worker as a separate module that could be accessed from the webconsole (or any other tool that wants to use it) directly.

Nicolas, is there a technical reason the parserService needs to be exposed through the toolbox and couldn't be used by a window like the Browser Console directly? https://searchfox.org/mozilla-central/rev/1ce4e8a5601da8e744ca6eda69e782318afab54d/devtools/client/framework/toolbox.js#691. IOW: do we need the debugger frontend or backend to be available for that to work, or is it independent?
Flags: needinfo?(nchevobbe)
(Assignee)

Comment 2

7 months ago
We don't need the debugger frontend at all, only the parser worker.
It was put on the toolbox as `parserService` so it could be use across all panels, but as you say, the browser console does not have a toolbox.
I think this could be fixed, I'll have a look soon.
Flags: needinfo?(nchevobbe)
(Assignee)

Updated

7 months ago
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Priority: -- → P1
(Assignee)

Comment 3

7 months ago
This patch moves the parserService from the toolbox,
which isn't accessible in the case of the Browser Console,
to the console itself.
A lightweight test is added to ensure top-level await is
supported in the browser console.

Comment 4

7 months ago
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/21f2d2802b18
Add top-level await support to the Browser Console; r=bgrins.

Comment 5

7 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/21f2d2802b18
Status: ASSIGNED → RESOLVED
Last Resolved: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 64
Whiteboard: [good first verify]
Depends on: 1506118
You need to log in before you can comment on or make changes to this bug.