LibWeb: Perform writes during ReadableStreamPipeTo asynchronously

I don't quite see what spec text requires this, but it is explicitly
checked by WPT. We used to pass this test, but that regressed after
commit 3c6010c663.
This commit is contained in:
Timothy Flynn 2025-04-14 15:45:40 -04:00
parent 95288e594b
commit 1536d51c5c
2 changed files with 11 additions and 4 deletions

View file

@ -497,8 +497,15 @@ private:
auto on_chunk = GC::create_function(heap(), [this](JS::Value chunk) {
m_unwritten_chunks.append(chunk);
write_chunk();
process();
if (check_for_error_and_close_states())
return;
HTML::queue_a_microtask(nullptr, GC::create_function(m_realm->heap(), [this]() {
HTML::TemporaryExecutionContext execution_context { m_realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
write_chunk();
process();
}));
});
auto on_complete = GC::create_function(heap(), [this]() {

View file

@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
1 Fail
Fail enqueue() must not synchronously call write algorithm
1 Pass
Pass enqueue() must not synchronously call write algorithm