mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-28 04:39:07 -10:00
This patch turns the current top-level handling, which relies on the console API to print the result of the await expression, into something natively handled by the server. First, we don't add a .then handler to the generated async iife by the mapper. We also removes the case we added in the JsTerm to *not* print the result for top-level await expression. In order to make the server capable of handling generated async iife caused by the mapper, we send to evaluateJsAsync the `mapped` object that `mapExpression` returns. This way, the server can check if an expression was originally a top-level await. If it is the case, we get the promise from the async iife and wait for it to settle. If it resolves, we simply return the result, as a grip, to the client. If it rejects, we return a special packet indicating to not print anything to the client. The error will be reported by the engine as `uncaught exception: …`. We add several tests and modify the existing one to make sure we handle top level await correctly in different situation (resolving, rejecting, when paused in the debugger, when using $_, …). Differential Revision: https://phabricator.services.mozilla.com/D6903