diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 654ddccd43f..d102c0b6bb9 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -3015,7 +3015,7 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value) auto navigable = this->navigable(); if (navigable && navigable->is_traversable()) { if (!is_decoded_svg()) { - HTML::HTMLLinkElement::load_fallback_favicon_if_needed(*this).release_value_but_fixme_should_propagate_errors(); + HTML::HTMLLinkElement::load_fallback_favicon_if_needed(*this); } navigable->traversable_navigable()->page().client().page_did_finish_loading(url()); } else { diff --git a/Libraries/LibWeb/Fetch/FetchMethod.cpp b/Libraries/LibWeb/Fetch/FetchMethod.cpp index 667a10a3b14..f60c3f551f1 100644 --- a/Libraries/LibWeb/Fetch/FetchMethod.cpp +++ b/Libraries/LibWeb/Fetch/FetchMethod.cpp @@ -116,7 +116,7 @@ GC::Ref fetch(JS::VM& vm, RequestInfo const& input, RequestInit // 5. Resolve p with responseObject. WebIDL::resolve_promise(relevant_realm, promise_capability, response_object); }; - controller_holder->set_controller(MUST(Fetching::fetch( + controller_holder->set_controller(Fetching::fetch( realm, request, Infrastructure::FetchAlgorithms::create(vm, @@ -127,7 +127,7 @@ GC::Ref fetch(JS::VM& vm, RequestInfo const& input, RequestInit .process_response = move(process_response), .process_response_end_of_body = {}, .process_response_consume_body = {}, - })))); + }))); // 11. Add the following abort steps to requestObject’s signal: (void)request_object->signal()->add_abort_algorithm([locally_aborted, request, controller_holder, promise_capability, request_object, response_object, &relevant_realm] { diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index cc9480f7bd2..8c16510d41e 100644 --- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -80,7 +80,7 @@ bool g_http_cache_enabled = false; }) // https://fetch.spec.whatwg.org/#concept-fetch -WebIDL::ExceptionOr> fetch(JS::Realm& realm, Infrastructure::Request& request, Infrastructure::FetchAlgorithms const& algorithms, UseParallelQueue use_parallel_queue) +GC::Ref fetch(JS::Realm& realm, Infrastructure::Request& request, Infrastructure::FetchAlgorithms const& algorithms, UseParallelQueue use_parallel_queue) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'fetch' with: request @ {}", &request); @@ -240,7 +240,7 @@ WebIDL::ExceptionOr> fetch(JS::Realm& r } // 15. Run main fetch given fetchParams. - (void)TRY(main_fetch(realm, fetch_params)); + (void)main_fetch(realm, fetch_params); // 16. Return fetchParams’s controller. return fetch_params->controller(); @@ -295,7 +295,7 @@ void populate_request_from_client(JS::Realm const& realm, Infrastructure::Reques } // https://fetch.spec.whatwg.org/#concept-main-fetch -WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Recursive recursive) +GC::Ptr main_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Recursive recursive) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'main fetch' with: fetch_params @ {}", &fetch_params); @@ -364,7 +364,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra request->current_url().set_scheme("https"_string); } - auto get_response = GC::create_function(vm.heap(), [&realm, &vm, &fetch_params, request]() -> WebIDL::ExceptionOr> { + auto get_response = GC::create_function(vm.heap(), [&realm, &vm, &fetch_params, request]() -> GC::Ref { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'main fetch' get_response() function"); auto const* origin = request->origin().get_pointer(); @@ -443,7 +443,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra auto returned_pending_response = PendingResponse::create(vm, request); // 2. Let corsWithPreflightResponse be the result of running HTTP fetch given fetchParams and true. - auto cors_with_preflight_response = TRY(http_fetch(realm, fetch_params, MakeCORSPreflight::Yes)); + auto cors_with_preflight_response = http_fetch(realm, fetch_params, MakeCORSPreflight::Yes); cors_with_preflight_response->when_loaded([returned_pending_response](GC::Ref cors_with_preflight_response) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'main fetch' cors_with_preflight_response load callback"); // 3. If corsWithPreflightResponse is a network error, then clear cache entries using request. @@ -470,7 +470,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra // 12. If response is null, then set response to the result of running the steps corresponding to the first // matching statement: auto pending_response = !response - ? TRY(get_response->function()()) + ? get_response->function()() : PendingResponse::create(vm, request, *response); // 13. If recursive is true, then return response. @@ -483,10 +483,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra // matching statement: auto pending_response = PendingResponse::create(vm, request, Infrastructure::Response::create(vm)); if (!response) { - auto pending_response_or_error = get_response->function()(); - if (pending_response_or_error.is_error()) - return; - pending_response = pending_response_or_error.release_value(); + pending_response = get_response->function()(); } pending_response->when_loaded([&realm, &vm, &fetch_params, request, response, response_was_null = !response](GC::Ref resolved_response) mutable { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'main fetch' pending_response load callback"); @@ -825,7 +822,7 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const } // https://fetch.spec.whatwg.org/#concept-scheme-fetch -WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params) +GC::Ref scheme_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'scheme fetch' with: fetch_params @ {}", &fetch_params); @@ -858,7 +855,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf } // FIXME: This is actually wrong, see note above. - return TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params)); + return nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params); } // -> "blob" else if (request->current_url().scheme() == "blob"sv) { @@ -968,7 +965,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf } // 8. Let slicedBlob be the result of invoking slice blob given blob, rangeStart, rangeEnd + 1, and type. - auto sliced_blob = TRY(blob->slice(*range_start, *range_end + 1, type)); + auto sliced_blob = MUST(blob->slice(*range_start, *range_end + 1, type)); // 9. Let slicedBodyWithType be the result of safely extracting slicedBlob. auto sliced_body_with_type = safely_extract_body(realm, sliced_blob->raw_bytes()); @@ -1035,7 +1032,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf // For now, unfortunate as it is, file: URLs are left as an exercise for the reader. // When in doubt, return a network error. if (request->origin().has() && (request->origin().get().is_opaque() || request->origin().get().scheme() == "file"sv || request->origin().get().scheme() == "resource"sv)) - return TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params)); + return nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params); else return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'file:' or 'resource:' URL blocked"_string)); } @@ -1053,7 +1050,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf } // https://fetch.spec.whatwg.org/#concept-http-fetch -WebIDL::ExceptionOr> http_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, MakeCORSPreflight make_cors_preflight) +GC::Ref http_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, MakeCORSPreflight make_cors_preflight) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP fetch' with: fetch_params @ {}, make_cors_preflight = {}", &fetch_params, make_cors_preflight == MakeCORSPreflight::Yes ? "Yes"sv : "No"sv); @@ -1144,12 +1141,12 @@ WebIDL::ExceptionOr> http_fetch(JS::Realm& realm, Infra // FIXME: We currently have no cache, so there will always be no header-name cache entry. || !Infrastructure::get_cors_unsafe_header_names(request->header_list()).is_empty())) { // 1. Let preflightResponse be the result of running CORS-preflight fetch given request. - pending_preflight_response = TRY(cors_preflight_fetch(realm, request)); + pending_preflight_response = cors_preflight_fetch(realm, request); // NOTE: Step 2 is performed in pending_preflight_response's load callback below. } - auto fetch_main_content = [request = GC::make_root(request), realm = GC::make_root(realm), fetch_params = GC::make_root(fetch_params)]() -> WebIDL::ExceptionOr> { + auto fetch_main_content = [request = GC::make_root(request), realm = GC::make_root(realm), fetch_params = GC::make_root(fetch_params)]() -> GC::Ref { // 2. If request’s redirect mode is "follow", then set request’s service-workers mode to "none". // NOTE: Redirects coming from the network (as opposed to from a service worker) are not to be exposed to a // service worker. @@ -1171,14 +1168,14 @@ WebIDL::ExceptionOr> http_fetch(JS::Realm& realm, Infra return; } - auto pending_main_content_response = TRY_OR_IGNORE(fetch_main_content()); + auto pending_main_content_response = fetch_main_content(); pending_main_content_response->when_loaded([pending_actual_response](GC::Ref main_content_response) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP fetch' pending_main_content_response load callback"); pending_actual_response->resolve(main_content_response); }); }); } else { - pending_actual_response = TRY(fetch_main_content()); + pending_actual_response = fetch_main_content(); } } else { pending_actual_response = PendingResponse::create(vm, request, Infrastructure::Response::create(vm)); @@ -1249,7 +1246,7 @@ WebIDL::ExceptionOr> http_fetch(JS::Realm& realm, Infra // -> "follow" case Infrastructure::Request::RedirectMode::Follow: // 1. Set response to the result of running HTTP-redirect fetch given fetchParams and response. - inner_pending_response = TRY_OR_IGNORE(http_redirect_fetch(realm, fetch_params, *response)); + inner_pending_response = http_redirect_fetch(realm, fetch_params, *response); break; default: VERIFY_NOT_REACHED(); @@ -1272,7 +1269,7 @@ WebIDL::ExceptionOr> http_fetch(JS::Realm& realm, Infra } // https://fetch.spec.whatwg.org/#concept-http-redirect-fetch -WebIDL::ExceptionOr> http_redirect_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response& response) +GC::Ptr http_redirect_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response& response) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP-redirect fetch' with: fetch_params @ {}, response = {}", &fetch_params, &response); @@ -1696,7 +1693,7 @@ static RefPtr determine_the_http_cache_partition(Infrastructure: } // https://fetch.spec.whatwg.org/#concept-http-network-or-cache-fetch -WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, IsAuthenticationFetch is_authentication_fetch, IsNewConnectionFetch is_new_connection_fetch) +GC::Ref http_network_or_cache_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, IsAuthenticationFetch is_authentication_fetch, IsNewConnectionFetch is_new_connection_fetch) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP-network-or-cache fetch' with: fetch_params @ {}, is_authentication_fetch = {}, is_new_connection_fetch = {}", &fetch_params, is_authentication_fetch == IsAuthenticationFetch::Yes ? "Yes"sv : "No"sv, is_new_connection_fetch == IsNewConnectionFetch::Yes ? "Yes"sv : "No"sv); @@ -1852,7 +1849,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re if (http_request->referrer().has()) { // 1. Let referrerValue be httpRequest’s referrer, serialized and isomorphic encoded. auto referrer_string = http_request->referrer().get().serialize(); - auto referrer_value = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(referrer_string.bytes())); + auto referrer_value = MUST(ByteBuffer::copy(referrer_string.bytes())); // 2. Append (`Referer`, referrerValue) to httpRequest’s header list. auto header = Infrastructure::Header { @@ -1981,7 +1978,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re else if (http_request->current_url().includes_credentials() && is_authentication_fetch == IsAuthenticationFetch::Yes) { auto const& url = http_request->current_url(); auto payload = MUST(String::formatted("{}:{}", URL::percent_decode(url.username()), URL::percent_decode(url.password()))); - authorization_value = TRY_OR_THROW_OOM(vm, encode_base64(payload.bytes())); + authorization_value = MUST(encode_base64(payload.bytes())); } // 4. If authorizationValue is non-null, then append (`Authorization`, authorizationValue) to @@ -2087,7 +2084,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re // 2. Let forwardResponse be the result of running HTTP-network fetch given httpFetchParams, includeCredentials, // and isNewConnectionFetch. - pending_forward_response = TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, *http_fetch_params, include_credentials, is_new_connection_fetch)); + pending_forward_response = nonstandard_resource_loader_file_or_http_network_fetch(realm, *http_fetch_params, include_credentials, is_new_connection_fetch); } else { pending_forward_response = PendingResponse::create(vm, request, Infrastructure::Response::create(vm)); } @@ -2205,7 +2202,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re } // 4. Set response to the result of running HTTP-network-or-cache fetch given fetchParams and true. - inner_pending_response = TRY_OR_IGNORE(http_network_or_cache_fetch(realm, fetch_params, IsAuthenticationFetch::Yes)); + inner_pending_response = http_network_or_cache_fetch(realm, fetch_params, IsAuthenticationFetch::Yes); } inner_pending_response->when_loaded([&realm, &vm, &fetch_params, request, returned_pending_response, is_authentication_fetch, is_new_connection_fetch](GC::Ref response) { @@ -2255,7 +2252,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re } // 2. Set response to the result of running HTTP-network-or-cache fetch given fetchParams, // isAuthenticationFetch, and true. - inner_pending_response = TRY_OR_IGNORE(http_network_or_cache_fetch(realm, fetch_params, is_authentication_fetch, IsNewConnectionFetch::Yes)); + inner_pending_response = http_network_or_cache_fetch(realm, fetch_params, is_authentication_fetch, IsNewConnectionFetch::Yes); } inner_pending_response->when_loaded([returned_pending_response, is_authentication_fetch](GC::Ref response) { @@ -2301,7 +2298,7 @@ static void log_response(auto const& status_code, auto const& headers, auto cons // https://fetch.spec.whatwg.org/#concept-http-network-fetch // Drop-in replacement for 'HTTP-network fetch', but obviously non-standard :^) // It also handles file:// URLs since those can also go through ResourceLoader. -WebIDL::ExceptionOr> nonstandard_resource_loader_file_or_http_network_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, IncludeCredentials include_credentials, IsNewConnectionFetch is_new_connection_fetch) +GC::Ref nonstandard_resource_loader_file_or_http_network_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, IncludeCredentials include_credentials, IsNewConnectionFetch is_new_connection_fetch) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'non-standard HTTP-network fetch' with: fetch_params @ {}", &fetch_params); @@ -2329,18 +2326,15 @@ WebIDL::ExceptionOr> nonstandard_resource_loader_file_o load_request.set_header(ByteString::copy(header.name), ByteString::copy(header.value)); if (auto const* body = request->body().get_pointer>()) { - TRY((*body)->source().visit( - [&](ByteBuffer const& byte_buffer) -> WebIDL::ExceptionOr { - load_request.set_body(TRY_OR_THROW_OOM(vm, ByteBuffer::copy(byte_buffer))); - return {}; + (*body)->source().visit( + [&](ByteBuffer const& byte_buffer) { + load_request.set_body(MUST(ByteBuffer::copy(byte_buffer))); }, - [&](GC::Root const& blob_handle) -> WebIDL::ExceptionOr { - load_request.set_body(TRY_OR_THROW_OOM(vm, ByteBuffer::copy(blob_handle->raw_bytes()))); - return {}; + [&](GC::Root const& blob_handle) { + load_request.set_body(MUST(ByteBuffer::copy(blob_handle->raw_bytes()))); }, - [](Empty) -> WebIDL::ExceptionOr { - return {}; - })); + [](Empty) { + }); } auto pending_response = PendingResponse::create(vm, request); @@ -2528,7 +2522,7 @@ WebIDL::ExceptionOr> nonstandard_resource_loader_file_o } // https://fetch.spec.whatwg.org/#cors-preflight-fetch-0 -WebIDL::ExceptionOr> cors_preflight_fetch(JS::Realm& realm, Infrastructure::Request& request) +GC::Ref cors_preflight_fetch(JS::Realm& realm, Infrastructure::Request& request) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'CORS-preflight fetch' with request @ {}", &request); @@ -2538,7 +2532,7 @@ WebIDL::ExceptionOr> cors_preflight_fetch(JS::Realm& re // request’s initiator, destination is request’s destination, origin is request’s origin, referrer is request’s referrer, // referrer policy is request’s referrer policy, mode is "cors", and response tainting is "cors". auto preflight = Fetch::Infrastructure::Request::create(vm); - preflight->set_method(TRY_OR_THROW_OOM(vm, ByteBuffer::copy("OPTIONS"sv.bytes()))); + preflight->set_method(MUST(ByteBuffer::copy("OPTIONS"sv.bytes()))); preflight->set_url_list(request.url_list()); preflight->set_initiator(request.initiator()); preflight->set_destination(request.destination()); @@ -2569,14 +2563,14 @@ WebIDL::ExceptionOr> cors_preflight_fetch(JS::Realm& re bool first = true; for (auto const& header : headers) { if (!first) - TRY_OR_THROW_OOM(vm, value.try_append(',')); - TRY_OR_THROW_OOM(vm, value.try_append(header)); + value.append(','); + value.append(header); first = false; } // 2. Append (`Access-Control-Request-Headers`, value) to preflight’s header list. temp_header = Infrastructure::Header { - .name = TRY_OR_THROW_OOM(vm, ByteBuffer::copy("Access-Control-Request-Headers"sv.bytes())), + .name = MUST(ByteBuffer::copy("Access-Control-Request-Headers"sv.bytes())), .value = move(value), }; preflight->header_list()->append(move(temp_header)); @@ -2589,7 +2583,7 @@ WebIDL::ExceptionOr> cors_preflight_fetch(JS::Realm& re auto returned_pending_response = PendingResponse::create(vm, request); - auto preflight_response = TRY(http_network_or_cache_fetch(realm, fetch_params)); + auto preflight_response = http_network_or_cache_fetch(realm, fetch_params); preflight_response->when_loaded([&vm, &request, returned_pending_response](GC::Ref response) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'CORS-preflight fetch' preflight_response load callback"); diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.h b/Libraries/LibWeb/Fetch/Fetching/Fetching.h index 993b354b736..025040731ed 100644 --- a/Libraries/LibWeb/Fetch/Fetching/Fetching.h +++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.h @@ -39,16 +39,16 @@ constexpr auto keepalive_maximum_size = 64 * KiB; ENUMERATE_BOOL_PARAMS #undef __ENUMERATE_BOOL_PARAM -WEB_API WebIDL::ExceptionOr> fetch(JS::Realm&, Infrastructure::Request&, Infrastructure::FetchAlgorithms const&, UseParallelQueue use_parallel_queue = UseParallelQueue::No); -WebIDL::ExceptionOr> main_fetch(JS::Realm&, Infrastructure::FetchParams const&, Recursive recursive = Recursive::No); +WEB_API GC::Ref fetch(JS::Realm&, Infrastructure::Request&, Infrastructure::FetchAlgorithms const&, UseParallelQueue use_parallel_queue = UseParallelQueue::No); +GC::Ptr main_fetch(JS::Realm&, Infrastructure::FetchParams const&, Recursive recursive = Recursive::No); void populate_request_from_client(JS::Realm const&, Infrastructure::Request&); void fetch_response_handover(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); -WebIDL::ExceptionOr> scheme_fetch(JS::Realm&, Infrastructure::FetchParams const&); -WebIDL::ExceptionOr> http_fetch(JS::Realm&, Infrastructure::FetchParams const&, MakeCORSPreflight make_cors_preflight = MakeCORSPreflight::No); -WebIDL::ExceptionOr> http_redirect_fetch(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); -WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Realm&, Infrastructure::FetchParams const&, IsAuthenticationFetch is_authentication_fetch = IsAuthenticationFetch::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); -WebIDL::ExceptionOr> nonstandard_resource_loader_file_or_http_network_fetch(JS::Realm&, Infrastructure::FetchParams const&, IncludeCredentials include_credentials = IncludeCredentials::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); -WebIDL::ExceptionOr> cors_preflight_fetch(JS::Realm&, Infrastructure::Request&); +GC::Ref scheme_fetch(JS::Realm&, Infrastructure::FetchParams const&); +GC::Ref http_fetch(JS::Realm&, Infrastructure::FetchParams const&, MakeCORSPreflight make_cors_preflight = MakeCORSPreflight::No); +GC::Ptr http_redirect_fetch(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); +GC::Ref http_network_or_cache_fetch(JS::Realm&, Infrastructure::FetchParams const&, IsAuthenticationFetch is_authentication_fetch = IsAuthenticationFetch::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); +GC::Ref nonstandard_resource_loader_file_or_http_network_fetch(JS::Realm&, Infrastructure::FetchParams const&, IncludeCredentials include_credentials = IncludeCredentials::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); +GC::Ref cors_preflight_fetch(JS::Realm&, Infrastructure::Request&); void set_sec_fetch_dest_header(Infrastructure::Request&); void set_sec_fetch_mode_header(Infrastructure::Request&); void set_sec_fetch_site_header(Infrastructure::Request&); diff --git a/Libraries/LibWeb/HTML/EventSource.cpp b/Libraries/LibWeb/HTML/EventSource.cpp index af1f191afe8..3b3312e6f3e 100644 --- a/Libraries/LibWeb/HTML/EventSource.cpp +++ b/Libraries/LibWeb/HTML/EventSource.cpp @@ -158,7 +158,7 @@ WebIDL::ExceptionOr> EventSource::construct_impl(JS::Realm& }; event_source->m_fetch_algorithms = Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)); - event_source->m_fetch_controller = TRY(Fetch::Fetching::fetch(realm, request, *event_source->m_fetch_algorithms)); + event_source->m_fetch_controller = Fetch::Fetching::fetch(realm, request, *event_source->m_fetch_algorithms); // 16. Return ev. return event_source; @@ -328,7 +328,7 @@ void EventSource::reestablish_the_connection() } // 4. Fetch request and process the response obtained in this fashion, if any, as described earlier in this section. - m_fetch_controller = Fetch::Fetching::fetch(realm(), request, *m_fetch_algorithms).release_value_but_fixme_should_propagate_errors(); + m_fetch_controller = Fetch::Fetching::fetch(realm(), request, *m_fetch_algorithms); })); } diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 77e378f502f..3498742015e 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -449,7 +449,7 @@ void HTMLLinkElement::default_fetch_and_process_linked_resource() if (m_fetch_controller) m_fetch_controller->abort(realm(), {}); - m_fetch_controller = MUST(Fetch::Fetching::fetch(realm(), *request, Fetch::Infrastructure::FetchAlgorithms::create(vm(), move(fetch_algorithms_input)))); + m_fetch_controller = Fetch::Fetching::fetch(realm(), *request, Fetch::Infrastructure::FetchAlgorithms::create(vm(), move(fetch_algorithms_input))); } // https://html.spec.whatwg.org/multipage/links.html#link-type-dns-prefetch:fetch-and-process-the-linked-resource-2 @@ -730,7 +730,7 @@ void HTMLLinkElement::preload(LinkProcessingOptions& options, GC::Ptrfunction()(response); }; - m_fetch_controller = MUST(Fetch::Fetching::fetch(realm, *request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + m_fetch_controller = Fetch::Fetching::fetch(realm, *request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); // 12. Let commit be the following steps given a Document document: auto commit = GC::Function::create(realm.heap(), [entry, report_timing](DOM::Document& document) { @@ -933,7 +933,7 @@ bool HTMLLinkElement::load_favicon_and_use_if_window_is_active() } // https://html.spec.whatwg.org/multipage/links.html#rel-icon:the-link-element-3 -WebIDL::ExceptionOr HTMLLinkElement::load_fallback_favicon_if_needed(GC::Ref document) +void HTMLLinkElement::load_fallback_favicon_if_needed(GC::Ref document) { auto& realm = document->realm(); auto& vm = realm.vm(); @@ -941,9 +941,9 @@ WebIDL::ExceptionOr HTMLLinkElement::load_fallback_favicon_if_needed(GC::R // In the absence of a link with the icon keyword, for Document objects whose URL's scheme is an HTTP(S) scheme, // user agents may instead run these steps in parallel: if (document->has_active_favicon()) - return {}; + return; if (!document->url().scheme().is_one_of("http"sv, "https"sv)) - return {}; + return; // 1. Let request be a new request whose URL is the URL record obtained by resolving the URL "/favicon.ico" against // the Document object's URL, client is the Document object's relevant settings object, destination is "image", @@ -978,8 +978,7 @@ WebIDL::ExceptionOr HTMLLinkElement::load_fallback_favicon_if_needed(GC::R body->fully_read(realm, process_body, process_body_error, global); }; - TRY(Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); - return {}; + Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); } bool HTMLLinkElement::should_fetch_and_process_resource_type() const diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Libraries/LibWeb/HTML/HTMLLinkElement.h index 6ae4f33880b..b10c443110b 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -38,7 +38,7 @@ public: bool has_loaded_icon() const; bool load_favicon_and_use_if_window_is_active(); - static WebIDL::ExceptionOr load_fallback_favicon_if_needed(GC::Ref); + static void load_fallback_favicon_if_needed(GC::Ref); void set_parser_document(Badge, GC::Ref document) { m_parser_document = document; } void set_was_enabled_when_created_by_parser(Badge, bool was_enabled_when_created_by_parser) { m_was_enabled_when_created_by_parser = was_enabled_when_created_by_parser; } diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index b8bb784cd2c..45523e1e5ba 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -1098,7 +1098,7 @@ WebIDL::ExceptionOr HTMLMediaElement::fetch_resource(URL::URL const& url_r response->body()->fully_read(realm, update_media, empty_algorithm, GC::Ref { global }); }; - m_fetch_controller = TRY(Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + m_fetch_controller = Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); break; } diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index e0bf49e0d44..d4a3b13f2b6 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -315,11 +315,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps() }; // 5. Fetch request. - auto result = Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); - if (result.is_error()) { - resource_did_fail(); - return; - } + (void)Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); // Fetching the resource must delay the load event of the element's node document until the task that is // queued by the networking task source once the resource has been fetched (defined next) has been run. diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 707cf385caa..58699e25b10 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -439,7 +439,7 @@ void HTMLScriptElement::prepare_script() // -> "classic" if (m_script_type == ScriptType::Classic) { // Fetch a classic script given url, settings object, options, classic script CORS setting, encoding, and onComplete. - fetch_classic_script(*this, *url, settings_object, move(options), classic_script_cors_setting, encoding.release_value(), on_complete).release_value_but_fixme_should_propagate_errors(); + fetch_classic_script(*this, *url, settings_object, move(options), classic_script_cors_setting, encoding.release_value(), on_complete); } // -> "module" else if (m_script_type == ScriptType::Module) { diff --git a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp index 9daa17de528..29dad33f3c5 100644 --- a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp @@ -247,7 +247,7 @@ void HTMLTrackElement::start_the_track_processing_model_parallel_steps() // 4. Fetch request. m_fetch_algorithms = Fetch::Infrastructure::FetchAlgorithms::create(vm(), move(fetch_algorithms_input)); - m_fetch_controller = MUST(Fetch::Fetching::fetch(realm, request, *m_fetch_algorithms)); + m_fetch_controller = Fetch::Fetching::fetch(realm, request, *m_fetch_algorithms); } else { track_failed_to_load(); return; diff --git a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Libraries/LibWeb/HTML/HTMLVideoElement.cpp index 20e736c6f81..a5a6b151294 100644 --- a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLVideoElement.cpp @@ -182,7 +182,7 @@ WebIDL::ExceptionOr HTMLVideoElement::determine_element_poster_frame(Optio response->body()->fully_read(realm, on_image_data_read, empty_algorithm, GC::Ref { global }); }; - m_fetch_controller = TRY(Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + m_fetch_controller = Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); return {}; } diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp index f581ba00bc5..064898fbfb7 100644 --- a/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Libraries/LibWeb/HTML/Navigable.cpp @@ -834,7 +834,7 @@ static GC::Ref create_navigation_params_from_a_srcdoc_resource } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching -static WebIDL::ExceptionOr create_navigation_params_by_fetching(GC::Ptr entry, GC::Ptr navigable, SourceSnapshotParams const& source_snapshot_params, TargetSnapshotParams const& target_snapshot_params, ContentSecurityPolicy::Directives::Directive::NavigationType csp_navigation_type, UserNavigationInvolvement user_involvement, Optional navigation_id) +static Navigable::NavigationParamsVariant create_navigation_params_by_fetching(GC::Ptr entry, GC::Ptr navigable, SourceSnapshotParams const& source_snapshot_params, TargetSnapshotParams const& target_snapshot_params, ContentSecurityPolicy::Directives::Directive::NavigationType csp_navigation_type, UserNavigationInvolvement user_involvement, Optional navigation_id) { auto& vm = navigable->vm(); VERIFY(navigable->active_window()); @@ -892,7 +892,7 @@ static WebIDL::ExceptionOr create_navigation // 6. If documentResource is a POST resource: if (auto* post_resource = document_resource.get_pointer()) { // 1. Set request's method to `POST`. - request->set_method(TRY_OR_THROW_OOM(vm, ByteBuffer::copy("POST"sv.bytes()))); + request->set_method(MUST(ByteBuffer::copy("POST"sv.bytes()))); // 2. Set request's body to documentResource's request body. request->set_body(document_resource.get().request_body.value()); @@ -1068,7 +1068,7 @@ static WebIDL::ExceptionOr create_navigation response_holder->set_response(fetch_response); }; - fetch_controller = TRY(Fetch::Fetching::fetch( + fetch_controller = Fetch::Fetching::fetch( realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, @@ -1080,7 +1080,7 @@ static WebIDL::ExceptionOr create_navigation .process_response_end_of_body = {}, .process_response_consume_body = {}, }), - Fetch::Fetching::UseParallelQueue::Yes)); + Fetch::Fetching::UseParallelQueue::Yes); } // 6. Otherwise, process the next manual redirect for fetchController. else { @@ -1213,7 +1213,7 @@ static WebIDL::ExceptionOr create_navigation if (response_holder->response()->is_network_error()) { // AD-HOC: We pass the error message if we have one in NullWithError if (response_holder->response()->network_error_message().has_value()) - return response_holder->response()->network_error_message().value(); + return response_holder->response()->network_error_message(); else return Navigable::NullOrError {}; } else if (location_url.is_error() || (location_url.value().has_value() && Fetch::Infrastructure::is_fetch_scheme(location_url.value().value().scheme()))) @@ -1271,7 +1271,7 @@ static WebIDL::ExceptionOr create_navigation } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#populating-a-session-history-entry -WebIDL::ExceptionOr Navigable::populate_session_history_entry_document( +void Navigable::populate_session_history_entry_document( GC::Ptr entry, SourceSnapshotParams const& source_snapshot_params, TargetSnapshotParams const& target_snapshot_params, @@ -1284,7 +1284,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document( { // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window. if (!active_window()) - return {}; + return; // FIXME: 1. Assert: this is running in parallel. @@ -1311,7 +1311,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document( // sourceSnapshotParams, targetSnapshotParams, cspNavigationType, userInvolvement, navigationId, and // navTimingType. else if (Fetch::Infrastructure::is_fetch_scheme(entry->url().scheme()) && (document_resource.has() || allow_POST)) { - navigation_params = TRY(create_navigation_params_by_fetching(entry, this, source_snapshot_params, target_snapshot_params, csp_navigation_type, user_involvement, navigation_id)); + navigation_params = create_navigation_params_by_fetching(entry, this, source_snapshot_params, target_snapshot_params, csp_navigation_type, user_involvement, navigation_id); } // 3. Otherwise, if entry's URL's scheme is not a fetch scheme, then set navigationParams to a new non-fetch // scheme navigation params, with: @@ -1337,7 +1337,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document( // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window. if (!active_window()) - return {}; + return; // 5. Queue a global task on the navigation and traversal task source, given navigable's active window, to run these steps: queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), GC::create_function(heap(), [this, entry, navigation_params = move(navigation_params), navigation_id, user_involvement, completion_steps, csp_navigation_type]() mutable { @@ -1474,8 +1474,6 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document( if (completion_steps) completion_steps->function()(); })); - - return {}; } WebIDL::ExceptionOr Navigable::navigate(NavigateParams params) @@ -1837,7 +1835,7 @@ void Navigable::begin_navigation(NavigateParams params) } finalize_a_cross_document_navigation(*this, to_history_handling_behavior(history_handling), user_involvement, history_entry); })); - })).release_value_but_fixme_should_propagate_errors(); + })); })); } diff --git a/Libraries/LibWeb/HTML/Navigable.h b/Libraries/LibWeb/HTML/Navigable.h index 5e6c71015d5..edc24bd67eb 100644 --- a/Libraries/LibWeb/HTML/Navigable.h +++ b/Libraries/LibWeb/HTML/Navigable.h @@ -118,7 +118,7 @@ public: Variant ongoing_navigation() const { return m_ongoing_navigation; } void set_ongoing_navigation(Variant ongoing_navigation); - WebIDL::ExceptionOr populate_session_history_entry_document( + void populate_session_history_entry_document( GC::Ptr entry, SourceSnapshotParams const& source_snapshot_params, TargetSnapshotParams const& target_snapshot_params, diff --git a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Libraries/LibWeb/HTML/Scripting/Fetching.cpp index 1cab8d9dfc3..2d427bfd5d3 100644 --- a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp +++ b/Libraries/LibWeb/HTML/Scripting/Fetching.cpp @@ -325,7 +325,7 @@ String resolve_a_module_integrity_metadata(URL::URL const& url, EnvironmentSetti } // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-script -WebIDL::ExceptionOr fetch_classic_script(GC::Ref element, URL::URL const& url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete) +void fetch_classic_script(GC::Ref element, URL::URL const& url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete) { auto& realm = element->realm(); auto& vm = realm.vm(); @@ -385,8 +385,7 @@ WebIDL::ExceptionOr fetch_classic_script(GC::Ref elemen on_complete->function()(script); }; - TRY(Fetch::Fetching::fetch(element->realm(), request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); - return {}; + Fetch::Fetching::fetch(element->realm(), request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); } // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script @@ -464,7 +463,7 @@ WebIDL::ExceptionOr fetch_classic_worker_script(URL::URL const& url, Envir else { Fetch::Infrastructure::FetchAlgorithms::Input fetch_algorithms_input {}; fetch_algorithms_input.process_response_consume_body = move(process_response_consume_body); - TRY(Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); } return {}; } @@ -507,7 +506,7 @@ WebIDL::ExceptionOr> fetch_a_classic_worker_imported_scri else { Fetch::Infrastructure::FetchAlgorithms::Input fetch_algorithms_input {}; fetch_algorithms_input.process_response_consume_body = move(process_response_consume_body); - TRY(Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); } // 5. Pause until response is not null. @@ -728,7 +727,7 @@ void fetch_single_module_script(JS::Realm& realm, } else { Fetch::Infrastructure::FetchAlgorithms::Input fetch_algorithms_input {}; fetch_algorithms_input.process_response_consume_body = move(process_response_consume_body); - Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(realm.vm(), move(fetch_algorithms_input))).release_value_but_fixme_should_propagate_errors(); + Fetch::Fetching::fetch(realm, request, Fetch::Infrastructure::FetchAlgorithms::create(realm.vm(), move(fetch_algorithms_input))); } } diff --git a/Libraries/LibWeb/HTML/Scripting/Fetching.h b/Libraries/LibWeb/HTML/Scripting/Fetching.h index 76c158f8680..72590a2d930 100644 --- a/Libraries/LibWeb/HTML/Scripting/Fetching.h +++ b/Libraries/LibWeb/HTML/Scripting/Fetching.h @@ -89,7 +89,7 @@ WebIDL::ExceptionOr> resolve_imports_match(ByteString const& Optional resolve_url_like_module_specifier(StringView specifier, URL::URL const& base_url); ScriptFetchOptions get_descendant_script_fetch_options(ScriptFetchOptions const& original_options, URL::URL const& url, EnvironmentSettingsObject& settings_object); String resolve_a_module_integrity_metadata(URL::URL const& url, EnvironmentSettingsObject& settings_object); -WebIDL::ExceptionOr fetch_classic_script(GC::Ref, URL::URL const&, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete); +void fetch_classic_script(GC::Ref, URL::URL const&, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete); WEB_API WebIDL::ExceptionOr fetch_classic_worker_script(URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); WebIDL::ExceptionOr> fetch_a_classic_worker_imported_script(URL::URL const&, HTML::EnvironmentSettingsObject&, PerformTheFetchHook = nullptr); WEB_API WebIDL::ExceptionOr fetch_module_worker_script_graph(URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); diff --git a/Libraries/LibWeb/HTML/SharedResourceRequest.cpp b/Libraries/LibWeb/HTML/SharedResourceRequest.cpp index 083facd7242..68623ce19ca 100644 --- a/Libraries/LibWeb/HTML/SharedResourceRequest.cpp +++ b/Libraries/LibWeb/HTML/SharedResourceRequest.cpp @@ -109,8 +109,7 @@ void SharedResourceRequest::fetch_resource(JS::Realm& realm, GC::Refheap(), [populated_target_entry, potentially_target_specific_source_snapshot_params, target_snapshot_params, this, allow_POST, navigable, after_document_populated = GC::create_function(this->heap(), move(after_document_populated)), user_involvement] { navigable->populate_session_history_entry_document(populated_target_entry, *potentially_target_specific_source_snapshot_params, target_snapshot_params, user_involvement, {}, Navigable::NullOrError {}, ContentSecurityPolicy::Directives::Directive::NavigationType::Other, allow_POST, GC::create_function(this->heap(), [this, after_document_populated, populated_target_entry]() mutable { - VERIFY(active_window()); - queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), GC::create_function(this->heap(), [after_document_populated, populated_target_entry]() mutable { - after_document_populated->function()(true, populated_target_entry); - })); - })) - .release_value_but_fixme_should_propagate_errors(); + VERIFY(active_window()); + queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), GC::create_function(this->heap(), [after_document_populated, populated_target_entry]() mutable { + after_document_populated->function()(true, populated_target_entry); + })); + })); })); } // Otherwise, run afterDocumentPopulated immediately. diff --git a/Libraries/LibWeb/SVG/SVGScriptElement.cpp b/Libraries/LibWeb/SVG/SVGScriptElement.cpp index d4a25378523..9c38e19e3f3 100644 --- a/Libraries/LibWeb/SVG/SVGScriptElement.cpp +++ b/Libraries/LibWeb/SVG/SVGScriptElement.cpp @@ -141,7 +141,7 @@ void SVGScriptElement::process_the_script_element() response->body()->fully_read(realm, on_data_read, on_error, GC::Ref { global }); }; - auto fetch_promise = Fetch::Fetching::fetch(realm(), request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); + (void)Fetch::Fetching::fetch(realm(), request, Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); // Block until the resource has been fetched or determined invalid HTML::main_thread_event_loop().spin_until(GC::create_function(heap(), [&] { return fetch_done; })); diff --git a/Libraries/LibWeb/ServiceWorker/Job.cpp b/Libraries/LibWeb/ServiceWorker/Job.cpp index 392f428cdcb..eebfdf3971d 100644 --- a/Libraries/LibWeb/ServiceWorker/Job.cpp +++ b/Libraries/LibWeb/ServiceWorker/Job.cpp @@ -237,7 +237,7 @@ static void update(JS::VM& vm, GC::Ref job) // 4. If the isTopLevel flag is unset, then return the result of fetching request. // FIXME: Needs spec issue, this wording is confusing and contradicts the way perform the fetch hook is used in `run a worker` if (top_level == HTML::TopLevelModule::No) { - TRY(Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); return {}; } @@ -376,7 +376,7 @@ static void update(JS::VM& vm, GC::Ref job) process_response_completion_result = WebIDL::ExceptionOr {}; }; - auto fetch_controller = TRY(Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + auto fetch_controller = Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); // FIXME: This feels.. uncomfortable but it should work to block the current task until the fetch has progressed past our processResponse hook or aborted auto& event_loop = job->client ? job->client->responsible_event_loop() : HTML::main_thread_event_loop(); @@ -455,6 +455,7 @@ static void update(JS::VM& vm, GC::Ref job) // FIXME: Credentials mode // FIXME: Use a 'stub' service worker ESO as the fetch "environment" (void)HTML::fetch_module_worker_script_graph(job->script_url, *job->client, Fetch::Infrastructure::Request::Destination::ServiceWorker, *job->client, perform_the_fetch_hook, on_fetch_complete); + break; } } diff --git a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 1b407dab0fc..063f36326f1 100644 --- a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -849,7 +849,7 @@ WebIDL::ExceptionOr XMLHttpRequest::send(Optional XMLHttpRequest::send(Optional XMLHttpRequest::send(Optional XMLHttpRequest::send(Optional page, Web::HTML::TransferDataEncoder mes // 1. If isTopLevel is false, fetch request with processResponseConsumeBody set to processCustomFetchResponse, and abort these steps. if (is_top_level == Web::HTML::TopLevelModule::No) { fetch_algorithms_input.process_response_consume_body = move(process_custom_fetch_response); - TRY(Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); return {}; } @@ -150,7 +150,7 @@ void WorkerHost::run(GC::Ref page, Web::HTML::TransferDataEncoder mes // 9. Run processCustomFetchResponse with response and bodyBytes. process_custom_fetch_response_function->function()(response, body_bytes); }; - TRY(Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input)))); + Web::Fetch::Fetching::fetch(realm, request, Web::Fetch::Infrastructure::FetchAlgorithms::create(vm, move(fetch_algorithms_input))); return {}; }; auto perform_fetch = Web::HTML::create_perform_the_fetch_hook(inside_settings->heap(), move(perform_fetch_function));