-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
What is the issue with the HTML Standard?
The HTML spec stores the incumbent settings into the JobCallback, where JobCallbacks are used for Promise reactions and FinalizationRegistry cleanup callbacks.
https://html.spec.whatwg.org/#hostmakejobcallback
HostMakeJobCallback(callable)
...
1. Let incumbent settings be the incumbent settings object.
...
5. Return the JobCallback Record {
[[Callback]]: callable,
[[HostDefined]]: {
[[IncumbentSettings]]: incumbent settings,
[[ActiveScriptContext]]: script execution context
}
}.
https://html.spec.whatwg.org/#hostcalljobcallback
HostCallJobCallback(callback, V, argumentsList)
...
1. Let incumbent settings be callback.[[HostDefined]].[[IncumbentSettings]].
...
3. Prepare to run a callback with incumbent settings.
...
7. Clean up after running a callback with incumbent settings.
The behavior for the Promise reactions is covered by the followng WPT testcase.
At the point of reporting this, only Firefox passes this test.
In Firefox implementation, supporting the incumbent settings in Promise reactions has been a problem around the complexity and performance, and if the incumbent settings handling for JobCallback is removed from the spec, it helps much.
Then, to my understanding, Chrome and Safari don't agree with which global to use for the case where the incumbent global is supposed to be used, and it's also different from Firefox, which means the behavior is completely different between browsers. This implies that there's almost no website that actually relies on the incumbent settings handling in Promise reactions (presumably, thanks to the efforts to minimize the incumbent usage in #1430 ), and also which global is used in such case. Thus, removing the incumbent settings handling for the Promise JobCallbacks from the spec and the Firefox implementation won't result in major web-compat issues.
So, I'd like to propose removing the incumbent settings handling from the JobCallback.
Things to do:
- Investigate the FinalizationRegistry usage. If Chrome and Safari also don't implement incumbent settings for FinalizationRegistry, then we can simply remove [[IncumbentSettings]] field. Otherwise we might need to reduce the scope to Promise's case only
- Check how this affect the Prioritized Task Scheduling (Chrome passes the tests for this), which is another consumer of the [[HostDefined]] field
- Check what actually happens in terms of the spec if we just remove the [[IncumbentSettings]]. Which global should be used instead, and which browser matches the behavior right now?
See also: