Skip to content

Browsers don't agree with the incumbent settings handling for Promise reactions #11686

@arai-a

Description

@arai-a

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.

https://github.com/web-platform-tests/wpt/blob/master/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-job-queue/promise-job-incumbent.html

At the point of reporting this, only Firefox passes this test.

https://wpt.fyi/results/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-job-queue?label=experimental&label=master&aligned

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions