LibWeb: Change Fetch's ProcessBodyError to accept a plain JS value

This callback is meant to be triggered by streams, which does not always
provide a WebIDL::DOMException. Pass a plain value instead. Of all the
users of this callback, only one actually uses the value, and already
converts the DOMException to a plain value.
This commit is contained in:
Timothy Flynn 2024-04-30 07:20:41 -04:00 committed by Tim Flynn
commit b5ba60f1d1
Notes: sideshowbarker 2024-07-17 06:39:26 +09:00
9 changed files with 14 additions and 14 deletions

View file

@ -548,7 +548,7 @@ WebIDL::ExceptionOr<void> HTMLLinkElement::load_fallback_favicon_if_needed(JS::N
auto process_body = JS::create_heap_function(realm.heap(), [document, request](ByteBuffer body) {
(void)decode_favicon(body, request->url(), document->navigable());
});
auto process_body_error = JS::create_heap_function(realm.heap(), [](JS::GCPtr<WebIDL::DOMException>) {
auto process_body_error = JS::create_heap_function(realm.heap(), [](JS::Value) {
});
// 3. Use response's unsafe response as an icon as if it had been declared using the icon keyword.

View file

@ -1011,7 +1011,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::fetch_resource(URL::URL const& url_r
// 5. Otherwise, incrementally read response's body given updateMedia, processEndOfMedia, an empty algorithm, and global.
VERIFY(response->body());
auto empty_algorithm = JS::create_heap_function(heap(), [](JS::GCPtr<WebIDL::DOMException>) {});
auto empty_algorithm = JS::create_heap_function(heap(), [](JS::Value) {});
// FIXME: We are "fully" reading the response here, rather than "incrementally". Memory concerns aside, this should be okay for now as we are
// always setting byteRange to "entire resource". However, we should switch to incremental reads when that is implemented, and then

View file

@ -203,7 +203,7 @@ WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optio
});
VERIFY(response->body());
auto empty_algorithm = JS::create_heap_function(heap(), [](JS::GCPtr<WebIDL::DOMException>) {});
auto empty_algorithm = JS::create_heap_function(heap(), [](JS::Value) {});
response->body()->fully_read(realm, on_image_data_read, empty_algorithm, JS::NonnullGCPtr { global });
};

View file

@ -90,7 +90,7 @@ void SharedImageRequest::fetch_image(JS::Realm& realm, JS::NonnullGCPtr<Fetch::I
auto mime_type = extracted_mime_type.has_value() ? extracted_mime_type.value().essence().bytes_as_string_view() : StringView {};
handle_successful_fetch(request->url(), mime_type, move(data));
});
auto process_body_error = JS::create_heap_function(heap(), [this](JS::GCPtr<WebIDL::DOMException>) {
auto process_body_error = JS::create_heap_function(heap(), [this](JS::Value) {
handle_failed_fetch();
});