diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp index 36b60d245c4..3da29a57dfe 100644 --- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp +++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp @@ -54,7 +54,7 @@ GC::Ref Body::clone(JS::Realm& realm) // To clone a body body, run these steps: // 1. Let « out1, out2 » be the result of teeing body’s stream. - auto [out1, out2] = m_stream->tee().release_value_but_fixme_should_propagate_errors(); + auto [out1, out2] = m_stream->tee(&realm).release_value_but_fixme_should_propagate_errors(); // 2. Set body’s stream to out1. m_stream = out1; diff --git a/Libraries/LibWeb/Streams/ReadableStream.cpp b/Libraries/LibWeb/Streams/ReadableStream.cpp index d1bb21b7fb5..4c61f264a73 100644 --- a/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -173,10 +173,13 @@ GC::Ref ReadableStream::pipe_to(WritableStream& destination, St } // https://streams.spec.whatwg.org/#readablestream-tee -WebIDL::ExceptionOr ReadableStream::tee() +WebIDL::ExceptionOr ReadableStream::tee(GC::Ptr target_realm) { + if (!target_realm) + target_realm = &realm(); + // To tee a ReadableStream stream, return ? ReadableStreamTee(stream, true). - return TRY(readable_stream_tee(realm(), *this, true)); + return TRY(readable_stream_tee(*target_realm, *this, true)); } // https://streams.spec.whatwg.org/#readablestream-close diff --git a/Libraries/LibWeb/Streams/ReadableStream.h b/Libraries/LibWeb/Streams/ReadableStream.h index a82c7b161e6..ebb63435e08 100644 --- a/Libraries/LibWeb/Streams/ReadableStream.h +++ b/Libraries/LibWeb/Streams/ReadableStream.h @@ -80,7 +80,7 @@ public: WebIDL::ExceptionOr get_reader(ReadableStreamGetReaderOptions const& = {}); WebIDL::ExceptionOr> pipe_through(ReadableWritablePair transform, StreamPipeOptions const& = {}); GC::Ref pipe_to(WritableStream& destination, StreamPipeOptions const& = {}); - WebIDL::ExceptionOr tee(); + WebIDL::ExceptionOr tee(GC::Ptr target_realm = {}); void close(); void error(JS::Value);