diff --git a/Userland/Libraries/LibWeb/Fetch/Body.cpp b/Userland/Libraries/LibWeb/Fetch/Body.cpp index abe4dbc3b3..748f851c94 100644 --- a/Userland/Libraries/LibWeb/Fetch/Body.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Body.cpp @@ -109,7 +109,7 @@ WebIDL::ExceptionOr package_data(JS::Realm& realm, ByteBuffer bytes, // Return a Blob whose contents are bytes and type attribute is mimeType. // NOTE: If extracting the mime type returns failure, other browsers set it to an empty string - not sure if that's spec'd. auto mime_type_string = mime_type.has_value() ? mime_type->serialized() : DeprecatedString::empty(); - return FileAPI::Blob::create(realm, move(bytes), move(mime_type_string)); + return TRY(FileAPI::Blob::create(realm, move(bytes), move(mime_type_string))); } case PackageDataType::FormData: // If mimeType’s essence is "multipart/form-data", then: diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index f9690dd243..cdf8f900d4 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -15,9 +15,9 @@ namespace Web::FileAPI { -JS::NonnullGCPtr Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type) +WebIDL::ExceptionOr> Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type) { - return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(byte_buffer), move(type))); } // https://w3c.github.io/FileAPI/#convert-line-endings-to-native diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.h b/Userland/Libraries/LibWeb/FileAPI/Blob.h index 9abbf258c8..d3eb0e8b9f 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.h +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.h @@ -33,7 +33,7 @@ class Blob : public Bindings::PlatformObject { public: virtual ~Blob() override; - static JS::NonnullGCPtr create(JS::Realm&, ByteBuffer, DeprecatedString type); + static WebIDL::ExceptionOr> create(JS::Realm&, ByteBuffer, DeprecatedString type); static WebIDL::ExceptionOr> create(JS::Realm&, Optional> const& blob_parts = {}, Optional const& options = {}); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Optional> const& blob_parts = {}, Optional const& options = {}); diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 4182badfed..a6ac6ae150 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -161,7 +161,7 @@ WebIDL::ExceptionOr XMLHttpRequest::response() } // 6. Otherwise, if this’s response type is "blob", set this’s response object to a new Blob object representing this’s received bytes with type set to the result of get a final MIME type for this. else if (m_response_type == Bindings::XMLHttpRequestResponseType::Blob) { - auto blob_part = FileAPI::Blob::create(realm(), m_received_bytes, get_final_mime_type().type()); + auto blob_part = TRY(FileAPI::Blob::create(realm(), m_received_bytes, get_final_mime_type().type())); auto blob = TRY(FileAPI::Blob::create(realm(), Vector { JS::make_handle(*blob_part) })); m_response_object = JS::Value(blob.ptr()); }