Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f8dd5342df32e060f207ff181494e0308d4f7fee
      
https://github.com/WebKit/WebKit/commit/f8dd5342df32e060f207ff181494e0308d4f7fee
  Author: Youenn Fablet <[email protected]>
  Date:   2026-01-07 (Wed, 07 Jan 2026)

  Changed paths:
    M LayoutTests/TestExpectations
    M Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp

  Log Message:
  -----------
  
imported/w3c/web-platform-tests/fetch/api/response/response-body-read-task-handling.html
 is flaky without JS built-in streams
rdar://165386906
https://bugs.webkit.org/show_bug.cgi?id=303084

Reviewed by Chris Dumez.

When resolving a promise, we synchronously get the `then` value, which can 
trigger JavaScript execution.
We should normally do this execution in an event loop task as per spec, but we 
are not always doing so.

If resolving a promise outside of an event loop task, we would execute the then 
getter with an empty execution context stack.
In that case, if calling a callback from the JS code, for instance as done by 
response-body-read-task-handling.html with acceptNode callback,
we would trigger a microtask checkpoint when exiting of the acceptNode 
callback, as the execution context stack is empty,
as per https://webidl.spec.whatwg.org/#call-a-user-objects-operation step 15, 
which calls 
https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script.

To still allow to resolve a promise outside of an event loop task without 
causing unnecessary microtask checkpoints, we are making sure that the 
execution context stack is not empty.
This is done by setting the currentState of threadGlobalDataSingleton to a non 
null value before resolving the promise if the currentState is nullptr.
We make sure to set the currentState back to nullptr just after the promise 
resolution.

* LayoutTests/TestExpectations:
* Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp:
(WebCore::DeferredPromise::callFunction):

Canonical link: https://commits.webkit.org/305209@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to