-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use context of then function for PromiseResolveThenableJob
When a microtask is executed, we need to use an appropriate, non-detached Context for its execution. Currently with PromiseResolveThenableJobs [1], the Context used is always drawn from the realm of the Promise constructor being used. This may cause non-intuitive behavior, such as in the following case: const DeadPromise = iframe.contentWindow.Promise; const p = DeadPromise.resolve({ then() { return { success: true }; } }); p.then(result => { console.log(result); }); // Some time later, but synchronously... iframe.src = "http://example.com"; // navigate away. // DeadPromise's Context is detached state now. // p never gets resolved, and its reaction handler never gets called. To fix this behavior, when PromiseResolveThenableJob is being queued up, the `then` method of the thenable should be used to determine the context of the resultant microtask. Doing so aligns with Firefox, and also with the latest HTML spec [2][3]. This change is analogous to CL 1465902, which uses the realm of the reaction handlers to determine the Context PromiseReactionJobs run in. [1]: https://tc39.es/ecma262/#sec-promiseresolvethenablejob [2]: https://html.spec.whatwg.org/C/#enqueuejob(queuename,-job,-arguments) [3]: whatwg/html#5212 Bug: v8:10200 Change-Id: I2312788eeea0f9e870c13cf3cb5730a87d15609e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2071624 Commit-Queue: Timothy Gu <timothygu@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/master@{#66507}
- Loading branch information
Showing
5 changed files
with
119 additions
and
35 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
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