diff --git a/Tests/LibWeb/Text/expected/Streams/init-from-fetch.txt b/Tests/LibWeb/Text/expected/Streams/init-from-fetch.txt
new file mode 100644
index 0000000000..0670438aaf
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/Streams/init-from-fetch.txt
@@ -0,0 +1 @@
+Was able to create a reader from a Fetch response!
diff --git a/Tests/LibWeb/Text/input/Streams/init-from-fetch.html b/Tests/LibWeb/Text/input/Streams/init-from-fetch.html
new file mode 100644
index 0000000000..851d540070
--- /dev/null
+++ b/Tests/LibWeb/Text/input/Streams/init-from-fetch.html
@@ -0,0 +1,14 @@
+
+
diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp
index 4fe430520b..95bcf05a78 100644
--- a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp
@@ -8,7 +8,10 @@
#include
#include
#include
+#include
#include
+#include
+#include
#include
#include
#include
@@ -33,6 +36,8 @@ WebIDL::ExceptionOr safely_extract_body(JS::Realm&
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
WebIDL::ExceptionOr extract_body(JS::Realm& realm, BodyInitOrReadableBytes const& object, bool keepalive)
{
+ HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+
auto& vm = realm.vm();
// 1. Let stream be null.
@@ -44,14 +49,12 @@ WebIDL::ExceptionOr extract_body(JS::Realm& realm,
}
// 3. Otherwise, if object is a Blob object, set stream to the result of running object’s get stream.
else if (auto const* blob_handle = object.get_pointer>()) {
- // FIXME: "set stream to the result of running object’s get stream"
- (void)blob_handle;
- stream = realm.heap().allocate(realm, realm);
+ stream = TRY(blob_handle->cell()->get_stream());
}
- // 4. Otherwise, set stream to a new ReadableStream object, and set up stream.
+ // 4. Otherwise, set stream to a new ReadableStream object, and set up stream with byte reading support.
else {
- // FIXME: "set up stream"
stream = realm.heap().allocate(realm, realm);
+ TRY(Streams::set_up_readable_stream_controller_with_byte_reading_support(*stream));
}
// 5. Assert: stream is a ReadableStream object.