You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All promise callbacks are executed on the microtask queue by way of vm.host_enqueue_promise_job. Only one microtask is allowed to execute at a time (see EventLoop::perform_a_microtask_checkpoint).
So, when we write to the iframe, we will eventually fetch the script's source URL in HTMLScriptElement::prepare_script. The call to document.write will block until this fetch is complete here:
But because we are already in a microtask, the promises involved in this inner fetch are not able to complete, as those microtasks are effectively blocked.
trflynn89
changed the title
The fetch process hangs when a fetch completion promise invokes a second fetch via document.write
The fetch process hangs when a microtask invokes fetch via document.writeDec 12, 2024
Repro HTML:
Where empty.js is an empty file.
All promise callbacks are executed on the microtask queue by way of
vm.host_enqueue_promise_job
. Only one microtask is allowed to execute at a time (seeEventLoop::perform_a_microtask_checkpoint
).So, when we write to the iframe, we will eventually fetch the script's source URL in
HTMLScriptElement::prepare_script
. The call todocument.write
will block until this fetch is complete here:ladybird/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
Lines 3035 to 3039 in 66519af
But because we are already in a microtask, the promises involved in this inner fetch are not able to complete, as those microtasks are effectively blocked.
This is reached in the following WPT tests:
https://wpt.fyi/results/upgrade-insecure-requests/gen/iframe-blank-inherit.meta/unset/fetch.https.html?diff=&filter=ADC&run_id=5161602225799168&run_id=5177547862310912
The text was updated successfully, but these errors were encountered: