summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Body.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp16
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp10
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h4
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp2
10 files changed, 21 insertions, 25 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp
index d4f18928e4..3986f8d61b 100644
--- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp
+++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp
@@ -219,7 +219,7 @@ JS::GCPtr<DOM::Document> load_document(Optional<HTML::NavigationParams> navigati
}
};
- auto process_body_error = [](auto&) {
+ auto process_body_error = [](auto) {
// FIXME: Load html page with an error if read of body failed.
TODO();
};
diff --git a/Userland/Libraries/LibWeb/Fetch/Body.cpp b/Userland/Libraries/LibWeb/Fetch/Body.cpp
index 65046ce99a..f1ed223df7 100644
--- a/Userland/Libraries/LibWeb/Fetch/Body.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/Body.cpp
@@ -158,13 +158,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> consume_body(JS::Realm& realm
// 3. Let errorSteps given error be to reject promise with error.
// NOTE: `promise` and `realm` is protected by JS::SafeFunction.
- auto error_steps = [promise, &realm](JS::Object& error) {
+ auto error_steps = [promise, &realm](JS::GCPtr<WebIDL::DOMException> error) {
// NOTE: Not part of the spec, but we need to have an execution context on the stack to call native functions.
// (In this case, Promise's reject function)
auto& environment_settings_object = Bindings::host_defined_environment_settings_object(realm);
environment_settings_object.prepare_to_run_script();
- WebIDL::reject_promise(realm, promise, &error);
+ WebIDL::reject_promise(realm, promise, error);
// See above NOTE.
environment_settings_object.clean_up_after_running_script();
diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
index d1d5daa718..f3fcc8ce64 100644
--- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
@@ -481,27 +481,21 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
if (!request->integrity_metadata().is_empty()) {
// 1. Let processBodyError be this step: run fetch response handover given fetchParams and a network
// error.
- // FIXME: The spec disagrees on whether fully_read()'s process_body_error should take an argument or not.
- // See https://github.com/whatwg/fetch/issues/1636
- // For now, define two versions of processBodyError
- auto process_body_error_no_argument = [&realm, &vm, &fetch_params]() {
- TRY_OR_IGNORE(fetch_response_handover(realm, fetch_params, Infrastructure::Response::network_error(vm, "Response body could not be processed"sv)));
- };
- Infrastructure::Body::ProcessBodyErrorCallback process_body_error = [&realm, &vm, &fetch_params](auto&) {
+ Infrastructure::Body::ProcessBodyErrorCallback process_body_error = [&realm, &vm, &fetch_params](auto) {
TRY_OR_IGNORE(fetch_response_handover(realm, fetch_params, Infrastructure::Response::network_error(vm, "Response body could not be processed"sv)));
};
// 2. If response’s body is null, then run processBodyError and abort these steps.
if (!response->body().has_value()) {
- process_body_error_no_argument();
+ process_body_error({});
return;
}
// 3. Let processBody given bytes be these steps:
- Infrastructure::Body::ProcessBodyCallback process_body = [&realm, &request, &response, &fetch_params, process_body_error = move(process_body_error_no_argument)](ByteBuffer bytes) {
+ Infrastructure::Body::ProcessBodyCallback process_body = [&realm, &request, &response, &fetch_params, process_body_error = move(process_body_error)](ByteBuffer bytes) {
// 1. If bytes do not match request’s integrity metadata, then run processBodyError and abort these steps.
if (!TRY_OR_IGNORE(SRI::do_bytes_match_metadata_list(bytes, request->integrity_metadata()))) {
- process_body_error();
+ process_body_error({});
return;
}
@@ -657,7 +651,7 @@ WebIDL::ExceptionOr<void> fetch_response_handover(JS::Realm& realm, Infrastructu
// 2. Let processBodyError be this step: run fetchParams’s process response consume body given response and
// failure.
- auto process_body_error = [&fetch_params, &response](auto&) {
+ auto process_body_error = [&fetch_params, &response](auto) {
(*fetch_params.algorithms()->process_response_consume_body())(response, Infrastructure::FetchAlgorithms::ConsumeBodyFailureTag {});
};
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp
index bddc0a8e50..d4b0bf3517 100644
--- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp
@@ -57,10 +57,10 @@ WebIDL::ExceptionOr<void> Body::fully_read(JS::Realm& realm, Web::Fetch::Infrast
return {};
};
- // 3. Let errorSteps be to queue a fetch task to run processBodyError, with taskDestination.
- auto error_steps = [process_body_error = move(process_body_error), task_destination_object = JS::make_handle(task_destination_object)](JS::Error& error) mutable {
- queue_fetch_task(*task_destination_object, [process_body_error = move(process_body_error), error = JS::make_handle(error)]() {
- process_body_error(*error);
+ // 3. Let errorSteps optionally given an exception exception be to queue a fetch task to run processBodyError given exception, with taskDestination.
+ auto error_steps = [process_body_error = move(process_body_error), task_destination_object = JS::make_handle(task_destination_object)](JS::GCPtr<WebIDL::DOMException> exception) mutable {
+ queue_fetch_task(*task_destination_object, [process_body_error = move(process_body_error), exception = JS::make_handle(exception)]() {
+ process_body_error(*exception);
});
};
@@ -71,7 +71,7 @@ WebIDL::ExceptionOr<void> Body::fully_read(JS::Realm& realm, Web::Fetch::Infrast
TRY_OR_THROW_OOM(vm, success_steps(*byte_buffer));
} else {
// Empty, Blob, FormData
- error_steps(TRY(JS::InternalError::create(realm, "Reading from Blob, FormData or null source is not yet implemented"sv)));
+ error_steps(WebIDL::DOMException::create(realm, "DOMException", "Reading from Blob, FormData or null source is not yet implemented"sv));
}
return {};
}
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h
index 81b92afbf6..ff40d57ebe 100644
--- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h
+++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h
@@ -24,8 +24,10 @@ namespace Web::Fetch::Infrastructure {
class Body final {
public:
using SourceType = Variant<Empty, ByteBuffer, JS::Handle<FileAPI::Blob>>;
+ // processBody must be an algorithm accepting a byte sequence.
using ProcessBodyCallback = JS::SafeFunction<void(ByteBuffer)>;
- using ProcessBodyErrorCallback = JS::SafeFunction<void(JS::Object&)>;
+ // processBodyError must be an algorithm optionally accepting an exception.
+ using ProcessBodyErrorCallback = JS::SafeFunction<void(JS::GCPtr<WebIDL::DOMException>)>;
explicit Body(JS::Handle<Streams::ReadableStream>);
Body(JS::Handle<Streams::ReadableStream>, SourceType, Optional<u64>);
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
index 62eac657a8..bd583596ad 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
@@ -480,7 +480,7 @@ after_step_6:
auto process_body = [image_request, url_string, this](ByteBuffer data) {
handle_successful_fetch(url_string, image_request, move(data));
};
- auto process_body_error = [this](auto&) {
+ auto process_body_error = [this](auto) {
handle_failed_fetch();
};
// FIXME: See HTMLLinkElement::default_fetch_and_process_linked_resource for thorough notes on the workaround
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
index 58a17ab15f..db12adb5c6 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
@@ -324,7 +324,7 @@ void HTMLLinkElement::default_fetch_and_process_linked_resource()
};
// NOTE: `this` and `unsafe_response` are protected by `fully_read` using JS::SafeFunction.
- auto process_body_error = [this, unsafe_response](auto&) {
+ auto process_body_error = [this, unsafe_response](auto) {
process_linked_resource(false, unsafe_response, Fetch::Infrastructure::FetchAlgorithms::ConsumeBodyFailureTag {});
};
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
index 92031d0ac7..fd4ad61a60 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
@@ -875,7 +875,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::fetch_resource(AK::URL const& url_re
}
VERIFY(response->body().has_value());
- auto empty_algorithm = [](auto&) {};
+ auto empty_algorithm = [](auto) {};
// 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
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp
index d2f71cc9ef..8324aa5ef2 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp
@@ -195,7 +195,7 @@ WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optio
};
VERIFY(response->body().has_value());
- auto empty_algorithm = [](auto&) {};
+ auto empty_algorithm = [](auto) {};
response->body()->fully_read(realm, move(on_image_data_read), move(empty_algorithm), JS::NonnullGCPtr { global }).release_value_but_fixme_should_propagate_errors();
};
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp
index 8833aecb67..d0c5fc068a 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp
@@ -326,7 +326,7 @@ WebIDL::ExceptionOr<void> fetch_classic_script(JS::NonnullGCPtr<HTMLScriptElemen
auto process_body = [response, response_handler](auto bytes) {
response_handler->process_response(response, move(bytes));
};
- auto process_body_error = [response, response_handler](auto&) {
+ auto process_body_error = [response, response_handler](auto) {
response_handler->process_response(response, Fetch::Infrastructure::FetchAlgorithms::ConsumeBodyFailureTag {});
};