Open Bug 2062918 Opened 3 months ago Updated 3 months ago

WebDriver BiDi: support script evaluation (with `awaitPromise`) in worker realm

Categories

(Core :: JavaScript: Debugger API, enhancement, P3)

enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: aslushnikov, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36

Steps to reproduce:

We (Playwright's Firefox automation, a.k.a. juggler) implement evaluation in
dedicated workers on top of the WorkerDebugger API, and we used the
Debugger.onPromiseSettled hook to await promise-returning evaluations.
That hook was removed in bug 2044167, and there is no replacement that works
in a worker debugger context:

  • On the main thread, one can dereference the promise and attach reactions
    from the privileged compartment (this is what BiDi's windowglobal script
    module and the DevTools console do for awaitPromise / top-level await).
  • In a worker debugger global there are no Xrays, so the dereferenced promise
    is an opaque wrapper and .then is not callable.

As a workaround, we now attach reactions inside the debuggee that execute a
debugger statement upon settlement, and observe it via the
Debugger.onDebuggerStatement hook — as far as we can tell, the only
remaining way to react to promise settlement from a worker debugger context.

We would love to have a proper way to await evaluation results in worker
contexts. BiDi will need the same primitive once script.evaluate /
script.callFunction support worker realms, which the spec implies via realm
targeting.

The Bugbug bot thinks this bug should belong to the 'Core::JavaScript Engine' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core
See Also: → 2044167
Component: JavaScript Engine → JavaScript: Debugger API
Severity: -- → N/A
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.