diff --git a/Tests/LibWeb/Text/expected/Streams/ReadableStreamBYOBReader-respondWithNewView.txt b/Tests/LibWeb/Text/expected/Streams/ReadableStreamBYOBReader-respondWithNewView.txt
new file mode 100644
index 00000000000..72557e8cfe0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/Streams/ReadableStreamBYOBReader-respondWithNewView.txt
@@ -0,0 +1,4 @@
+abcdefghijklmnopqrstuvwxyz
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
+0123456789!@#$%^&*()-=_+,<
+Done!
diff --git a/Tests/LibWeb/Text/input/Streams/ReadableStreamBYOBReader-respondWithNewView.html b/Tests/LibWeb/Text/input/Streams/ReadableStreamBYOBReader-respondWithNewView.html
new file mode 100644
index 00000000000..0926b8efe36
--- /dev/null
+++ b/Tests/LibWeb/Text/input/Streams/ReadableStreamBYOBReader-respondWithNewView.html
@@ -0,0 +1,80 @@
+
+
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.cpp
index f7bc1eacb39..9f53144368c 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.cpp
+++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.cpp
@@ -60,4 +60,21 @@ WebIDL::ExceptionOr ReadableStreamBYOBRequest::respond(WebIDL::UnsignedLon
return readable_byte_stream_controller_respond(*m_controller, bytes_written);
}
+// https://streams.spec.whatwg.org/#rs-byob-request-respond-with-new-view
+WebIDL::ExceptionOr ReadableStreamBYOBRequest::respond_with_new_view(JS::Handle const& view)
+{
+ auto& realm = this->realm();
+
+ // 1. If this.[[controller]] is undefined, throw a TypeError exception.
+ if (!m_controller)
+ return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Controller is undefined"_string };
+
+ // 2. If ! IsDetachedBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ if (view->viewed_array_buffer()->is_detached())
+ return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Unable to respond with a detached ArrayBuffer"_string };
+
+ // 3. Return ? ReadableByteStreamControllerRespondWithNewView(this.[[controller]], view).
+ return TRY(readable_byte_stream_controller_respond_with_new_view(realm, *m_controller, *view));
+}
+
}
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.h b/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.h
index f5a6007b5f9..0bf6e6315fc 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.h
+++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.h
@@ -30,6 +30,7 @@ public:
void set_view(JS::GCPtr value) { m_view = value; }
WebIDL::ExceptionOr respond(WebIDL::UnsignedLongLong bytes_written);
+ WebIDL::ExceptionOr respond_with_new_view(JS::Handle const& view);
private:
explicit ReadableStreamBYOBRequest(JS::Realm&);
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.idl b/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.idl
index 36ce9d8d622..66514449104 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.idl
+++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.idl
@@ -4,5 +4,5 @@ interface ReadableStreamBYOBRequest {
readonly attribute ArrayBufferView? view;
undefined respond([EnforceRange] unsigned long long bytesWritten);
- // FIXME: undefined respondWithNewView(ArrayBufferView view);
+ undefined respondWithNewView(ArrayBufferView view);
};