Truly independent web browser
LibWeb: Run main fetch's in-parallel steps on the agent's fetch executor
Luke Wildebdeb16cb3fde
diff --git a/Libraries/LibWeb/Fetch/Engine/StartFetchInput.h b/Libraries/LibWeb/Fetch/Engine/StartFetchInput.hindex 20032354b02..d19c18ebb89 100644--- a/Libraries/LibWeb/Fetch/Engine/StartFetchInput.h+++ b/Libraries/LibWeb/Fetch/Engine/StartFetchInput.h@@ -6,14 +6,28 @@#pragma once+#include <AK/Badge.h>#include <AK/Optional.h>#include <LibWeb/Fetch/Engine/BodyIntent.h>#include <LibWeb/Fetch/Engine/Ids.h>#include <LibWebCommon/FileAPI/SerializedBlobURLEntry.h>+namespace Web::Fetch::Infrastructure {++class FetchParams;++}+namespace Web::Fetch::Engine {struct StartFetchInput {+ StartFetchInput(Badge<Infrastructure::FetchParams>, FetchId fetch_id, BodyIntent body_intent, Optional<FileAPI::SerializedBlobURLEntry> blob_url_entry)+ : fetch_id(fetch_id)+ , body_intent(body_intent)+ , blob_url_entry(move(blob_url_entry))+ {+ }+FetchId fetch_id;BodyIntent body_intent;diff --git a/Libraries/LibWeb/Fetch/Fetching/FetchEngine.cpp b/Libraries/LibWeb/Fetch/Fetching/FetchEngine.cppindex 782de109798..0b6c8d3cd3f 100644--- a/Libraries/LibWeb/Fetch/Fetching/FetchEngine.cpp+++ b/Libraries/LibWeb/Fetch/Fetching/FetchEngine.cpp@@ -7,12 +7,23 @@#include <LibCore/EventLoop.h>#include <LibWeb/Fetch/Engine/InlineFetchExecutor.h>#include <LibWeb/Fetch/Fetching/FetchEngine.h>+#include <LibWeb/Fetch/Fetching/Fetching.h>namespace Web::Fetch::Fetching {-void FetchEngine::handle_command(Engine::EngineCommand)+void FetchEngine::handle_command(Engine::EngineCommand command){- VERIFY_NOT_REACHED();+ command.visit(+ [](Engine::Command::StartFetch const& start_fetch) {+ run_deferred_main_fetch_steps(start_fetch.input.fetch_id);+ },+ [](Engine::Command::Abort const&) { VERIFY_NOT_REACHED(); },+ [](Engine::Command::Terminate const&) { VERIFY_NOT_REACHED(); },+ [](Engine::Command::Stop const&) { VERIFY_NOT_REACHED(); },+ [](Engine::Command::ResolveRedirect const&) { VERIFY_NOT_REACHED(); },+ [](Engine::Command::PreloadResponseResolved const&) { VERIFY_NOT_REACHED(); },+ [](Engine::Command::TransportControl const&) { VERIFY_NOT_REACHED(); },+ [](Engine::Command::AdoptNetworkTransport const&) { VERIFY_NOT_REACHED(); });}NonnullRefPtr<Engine::FetchExecutor> create_inline_fetch_executor()diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cppindex d1297dcdb37..1fef5807345 100644--- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp+++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp@@ -28,6 +28,7 @@#include <LibWeb/Fetch/BodyInit.h>#include <LibWeb/Fetch/Engine/FetchBodyDeliveryGate.h>#include <LibWeb/Fetch/Engine/FetchByteChannel.h>+#include <LibWeb/Fetch/Engine/FetchExecutor.h>#include <LibWeb/Fetch/Engine/NetworkTransportHandle.h>#include <LibWeb/Fetch/Engine/WholeBodyTransport.h>#include <LibWeb/Fetch/Fetching/BodyStreamPullSource.h>@@ -72,7 +73,6 @@#include <LibWeb/MixedContent/AbstractOperations.h>#include <LibWeb/Page/Page.h>#include <LibWeb/Page/RenderingStats.h>-#include <LibWeb/Platform/EventLoopPlugin.h>#include <LibWeb/ReferrerPolicy/AbstractOperations.h>#include <LibWeb/ResourceTiming/PerformanceResourceTiming.h>#include <LibWeb/SRI/IntegrityPolicy.h>@@ -354,8 +354,9 @@ GC::Ref<Infrastructure::FetchController> fetch(JS::Realm& realm, Infrastructure:// process early hints response is processEarlyHintsResponse, process response is processResponse, process// response consume body is processResponseConsumeBody, process response end-of-body is processResponseEndOfBody,// task destination is taskDestination, and cross-origin isolated capability is crossOriginIsolatedCapability.- auto& controller_registry = HTML::relevant_agent(realm.global_object()).fetch_controller_registry;- auto controller = Infrastructure::FetchController::create(controller_registry);+ auto& agent = HTML::relevant_agent(realm.global_object());+ VERIFY(agent.fetch_executor);+ auto controller = Infrastructure::FetchController::create(agent.fetch_controller_registry);auto fetch_params = Infrastructure::FetchParams::create(controller, request, algorithms, timing_info, current_loader_config());controller->set_task_destination(task_destination);controller->set_keepalive(request.keepalive());@@ -808,7 +809,7 @@ GC::Ptr<PendingResponse> main_fetch(JS::Realm& realm, Infrastructure::FetchParam}// 11. If recursive is false, then run the remaining steps in parallel.- Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function<void()>(GC::Heap::the(), GC::captures(realm, NonnullRefPtr { fetch_params }, fetch_params.controller(), request, response, get_response), [](auto& realm, NonnullRefPtr<Infrastructure::FetchParams const>& fetch_params, GC::Ref<Infrastructure::FetchController>& controller, NonnullRefPtr<Infrastructure::Request>& request, RefPtr<Infrastructure::Response>& response, GC::Ref<GC::Function<GC::Ref<PendingResponse>()>>& get_response) {+ auto in_parallel_steps = GC::create_function<void()>(GC::Heap::the(), GC::captures(realm, NonnullRefPtr { fetch_params }, fetch_params.controller(), request, response, get_response), [](auto& realm, NonnullRefPtr<Infrastructure::FetchParams const>& fetch_params, GC::Ref<Infrastructure::FetchController>& controller, NonnullRefPtr<Infrastructure::Request>& request, RefPtr<Infrastructure::Response>& response, GC::Ref<GC::Function<GC::Ref<PendingResponse>()>>& get_response) {// 12. If response is null, then set response to the result of running the steps corresponding to the first// matching statement:auto pending_response = PendingResponse::create(controller, Infrastructure::Response::create());@@ -970,11 +971,22 @@ GC::Ptr<PendingResponse> main_fetch(JS::Realm& realm, Infrastructure::FetchParamfetch_response_handover(realm, *fetch_params, controller, *response);}}));- }));+ });+ auto& agent = HTML::relevant_agent(realm.global_object());+ auto fetch_id = agent.fetch_controller_registry.defer_main_fetch_steps(in_parallel_steps);+ auto start_fetch_input = fetch_params.start_fetch_input(fetch_id);+ agent.fetch_executor->post(Engine::Command::StartFetch { move(start_fetch_input) });return GC::Ptr<PendingResponse> {};}+void run_deferred_main_fetch_steps(Engine::FetchId fetch_id)+{+ // An agent's fetch engine runs on the agent's thread.+ auto steps = HTML::surrounding_agent().fetch_controller_registry.take_deferred_main_fetch_steps(fetch_id);+ steps->function()();+}+using RequestEnvironment = Variant<Empty, NonnullRefPtr<Infrastructure::ReservedClientContextSnapshot const>, NonnullRefPtr<Infrastructure::ClientContextSnapshot const>>;// https://fetch.spec.whatwg.org/#request-determine-the-environmentdiff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.h b/Libraries/LibWeb/Fetch/Fetching/Fetching.hindex 689a1511f83..4c483d5c1e5 100644--- a/Libraries/LibWeb/Fetch/Fetching/Fetching.h+++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.h@@ -18,6 +18,7 @@#include <LibRequests/RequestTransferLease.h>#include <LibURL/Forward.h>#include <LibWeb/Export.h>+#include <LibWeb/Fetch/Engine/Ids.h>#include <LibWeb/Fetch/Infrastructure/NetworkPartitionKey.h>#include <LibWeb/Forward.h>#include <LibWeb/HTML/Scripting/FetchClient.h>@@ -50,6 +51,8 @@ ENUMERATE_BOOL_PARAMSWEB_API GC::Ref<Infrastructure::FetchController> fetch(JS::Realm&, Infrastructure::Request&, Infrastructure::FetchAlgorithms const&, UseParallelQueue use_parallel_queue = UseParallelQueue::No, CreateResponseBodyTransferLease = CreateResponseBodyTransferLease::No);GC::Ptr<PendingResponse> main_fetch(JS::Realm&, Infrastructure::FetchParams const&, Recursive recursive = Recursive::No);+// Runs the in-parallel steps that main fetch deferred under the id.+void run_deferred_main_fetch_steps(Engine::FetchId);void populate_request_from_client(Infrastructure::Request&, Optional<HTML::FetchClient> const& client);void fetch_response_handover(JS::Realm&, Infrastructure::FetchParams const&, GC::Ref<Infrastructure::FetchController>, Infrastructure::Response&);GC::Ref<PendingResponse> scheme_fetch(JS::Realm&, Infrastructure::FetchParams const&);diff --git a/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.cpp b/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.cppindex 895b08f8d8c..8446b74002f 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.cpp+++ b/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.cpp@@ -12,6 +12,7 @@ namespace Web::Fetch::Infrastructure {static Atomic<u64> s_next_registry_id { 1 };static Atomic<u64> s_next_serial { 1 };+static Atomic<u64> s_next_fetch_id { 1 };FetchControllerRegistry::FetchControllerRegistry(): m_id(s_next_registry_id.fetch_add(1))@@ -46,4 +47,16 @@ Vector<GC::Root<FetchController>> FetchControllerRegistry::controllers() constreturn controllers;}+Engine::FetchId FetchControllerRegistry::defer_main_fetch_steps(GC::Ref<GC::Function<void()>> steps)+{+ Engine::FetchId fetch_id { s_next_fetch_id.fetch_add(1) };+ m_deferred_main_fetch_steps.set(fetch_id, GC::make_root(steps));+ return fetch_id;+}++GC::Root<GC::Function<void()>> FetchControllerRegistry::take_deferred_main_fetch_steps(Engine::FetchId fetch_id)+{+ return m_deferred_main_fetch_steps.take(fetch_id).release_value();+}+}diff --git a/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.h b/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.hindex 84a566a3a65..f72bdff5b45 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/FetchControllerRegistry.h@@ -11,15 +11,17 @@#include <AK/Noncopyable.h>#include <AK/Vector.h>#include <AK/Weakable.h>+#include <LibGC/Function.h>#include <LibGC/Ptr.h>#include <LibGC/Root.h>#include <LibWeb/Export.h>+#include <LibWeb/Fetch/Engine/Ids.h>#include <LibWeb/Fetch/Infrastructure/FetchControllerToken.h>#include <LibWeb/Forward.h>namespace Web::Fetch::Infrastructure {-// The fetch controllers of one agent, by token. It keeps none of them alive.+// The fetch controllers of one agent, by token. Nothing in it keeps them alive but the main fetch steps it defers.class WEB_API FetchControllerRegistry : public Weakable<FetchControllerRegistry> {AK_MAKE_NONCOPYABLE(FetchControllerRegistry);AK_MAKE_NONMOVABLE(FetchControllerRegistry);@@ -34,9 +36,14 @@ public:[[nodiscard]] Vector<GC::Root<FetchController>> controllers() const;+ // Keeps main fetch's in-parallel steps alive while they wait to be taken.+ [[nodiscard]] Engine::FetchId defer_main_fetch_steps(GC::Ref<GC::Function<void()>> steps);+ [[nodiscard]] GC::Root<GC::Function<void()>> take_deferred_main_fetch_steps(Engine::FetchId);+private:u64 m_id { 0 };HashMap<u64, GC::RawPtr<FetchController>> m_controllers;+ HashMap<Engine::FetchId, GC::Root<GC::Function<void()>>> m_deferred_main_fetch_steps;};}diff --git a/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp b/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cppindex 716e6d020f9..6ceb40f4ef8 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp+++ b/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.cpp@@ -46,6 +46,11 @@ NonnullRefPtr<FetchParams> FetchParams::copy(FetchParams const& params)return adopt_ref(*new FetchParams(params));}+Engine::StartFetchInput FetchParams::start_fetch_input(Engine::FetchId fetch_id) const+{+ return Engine::StartFetchInput { {}, fetch_id, m_control_block->body_intent(), m_blob_url_entry };+}+GC::Ref<FetchController> FetchParams::controller() const{VERIFY(m_controller_registry);diff --git a/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h b/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.hindex 975b3982422..11d27a28193 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h@@ -12,6 +12,7 @@#include <AK/Weakable.h>#include <LibGC/Ptr.h>#include <LibWeb/Export.h>+#include <LibWeb/Fetch/Engine/StartFetchInput.h>#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>#include <LibWeb/Fetch/Infrastructure/FetchController.h>#include <LibWeb/Fetch/Infrastructure/FetchTimingInfo.h>@@ -62,6 +63,8 @@ public:[[nodiscard]] Optional<FileAPI::SerializedBlobURLEntry> const& blob_url_entry() const { return m_blob_url_entry; }void set_blob_url_entry(Optional<FileAPI::SerializedBlobURLEntry> blob_url_entry) { m_blob_url_entry = move(blob_url_entry); }+ [[nodiscard]] Engine::StartFetchInput start_fetch_input(Engine::FetchId) const;+private:FetchParams(NonnullRefPtr<Request>, GC::Ref<FetchAlgorithms const>, FetchController&, NonnullRefPtr<FetchTimingInfo>, NonnullRefPtr<LoaderConfigSnapshot const>);FetchParams(FetchParams const&);diff --git a/Tests/LibWeb/TestAgentThreads.cpp b/Tests/LibWeb/TestAgentThreads.cppindex 9d036f414c5..59339376a6e 100644--- a/Tests/LibWeb/TestAgentThreads.cpp+++ b/Tests/LibWeb/TestAgentThreads.cpp@@ -22,6 +22,9 @@#include <LibWeb/Bindings/PlatformObject.h>#include <LibWeb/CSS/PropertyID.h>#include <LibWeb/Fetch/Fetching/FetchEngine.h>+#include <LibWeb/Fetch/Fetching/Fetching.h>+#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>+#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>#include <LibWeb/FileAPI/BlobURLStore.h>#include <LibWeb/HTML/DedicatedWorkerGlobalScope.h>#include <LibWeb/HTML/EventLoop/EventLoop.h>@@ -29,6 +32,7 @@#include <LibWeb/HTML/Scripting/Agent.h>#include <LibWeb/HTML/Scripting/ClassicScript.h>#include <LibWeb/HTML/Scripting/Environments.h>+#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>#include <LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h>#include <LibWeb/HTML/WorkerLocation.h>#include <LibWeb/HighResolutionTime/TimeOrigin.h>@@ -102,6 +106,17 @@ static constexpr auto AGENT_SCRIPT = R"~~~(// NB: The others stay for the agent's shutdown to remove.}+ async function fetches() {+ const response = await fetch("data:text/plain,hello");+ check("data fetch", (await response.text()) === "hello");++ const url = URL.createObjectURL(new Blob(["from a blob"], { type: "text/plain" }));+ const blobResponse = await fetch(url);+ check("blob fetch type", blobResponse.headers.get("Content-Type") === "text/plain");+ check("blob fetch", (await blobResponse.text()) === "from a blob");+ URL.revokeObjectURL(url);+ }+function urls() {const url = new URL("https://[email protected]:8080/a/../b?x=1&y=2#z");check("href", url.href === "https://[email protected]:8080/b?x=1&y=2#z");@@ -295,6 +310,7 @@ static constexpr auto AGENT_SCRIPT = R"~~~(async function runPass(pass) {await timers();await blobs();+ await fetches();urls();await messaging();await cryptography();@@ -447,7 +463,31 @@ public:{as<Web::HTML::DedicatedWorkerGlobalScope>(*m_global_scope).close();Core::EventLoop::current().exec();+ shut_down();+ }+ // Starts a fetch of the URL in a task that then closes the worker, and runs the worker's event loop until it is+ // destroyed. Returns the fetch's request.+ NonnullRefPtr<Web::Fetch::Infrastructure::Request> fetch_and_close(StringView url, Web::Fetch::Infrastructure::FetchAlgorithms::Input input)+ {+ auto request = Web::Fetch::Infrastructure::Request::create();+ request->set_url_list({ *URL::Parser::basic_parse(url) });+ request->set_client(m_settings->address());+ auto algorithms = Web::Fetch::Infrastructure::FetchAlgorithms::create(move(input));++ auto steps = GC::create_function(GC::Heap::the(), GC::captures(*m_settings, *m_global_scope, request, algorithms), [](auto& settings, auto& global_scope, auto& request, auto& algorithms) {+ Web::HTML::TemporaryExecutionContext execution_context { settings.realm(), Web::HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };+ (void)Web::Fetch::Fetching::fetch(settings.realm(), request, algorithms);+ as<Web::HTML::DedicatedWorkerGlobalScope>(global_scope).close();+ });+ Web::HTML::queue_global_task(Web::HTML::Task::Source::Unspecified, m_settings->realm().global_object(), steps);+ Core::EventLoop::current().exec();+ return request;+ }++ // What the host of a worker does once the worker's event loop is destroyed.+ void shut_down()+ {m_global_scope->clear_map_of_active_timers();Web::HTML::MessagePort::disentangle_ports_of_realm(Web::HTML::relevant_realm(*m_global_scope));m_global_scope->owner_set().clear();@@ -516,6 +556,12 @@ static void set_up_process()Web::Platform::FontPlugin::install(*new Web::Platform::FontPlugin(false));}+// Each command an executor posts holds the executor until the command has run or been dropped.+static bool has_queued_commands(Web::Fetch::Engine::FetchExecutor const& executor)+{+ return executor.ref_count() > 1;+}+TEST_CASE(an_agent_runs_on_a_thread_of_its_own){set_up_process();@@ -586,6 +632,25 @@ TEST_CASE(a_thread_hosts_one_agent_after_the_other)EXPECT_EQ(s_failures.load(), 0u);}+TEST_CASE(a_fetch_started_just_before_close_never_runs_its_in_parallel_steps)+{+ set_up_process();+ run_on_agent_threads(1, [](size_t) {+ Core::EventLoop event_loop;+ TestAgent agent;++ auto request = agent.fetch_and_close("about:blank"sv, Web::Fetch::Infrastructure::FetchAlgorithms::Input { Web::Fetch::Engine::BodyIntent::DrainAndDiscard });++ // The worker's event loop has stopped with the command that runs the fetch's in-parallel steps still queued.+ EXPECT(has_queued_commands(*Web::HTML::surrounding_agent().fetch_executor));++ agent.shut_down();++ // Main fetch's in-parallel steps would make the response tainting of this no-cors request opaque.+ EXPECT_EQ(request->response_tainting(), Web::Fetch::Infrastructure::Request::ResponseTainting::Basic);+ });+}+TEST_CASE(navigator_compatibility_reaches_every_agent){set_up_process();diff --git a/Tests/LibWeb/TestFaviconDecoding.cpp b/Tests/LibWeb/TestFaviconDecoding.cppindex e0c73935c99..e7d73d739a2 100644--- a/Tests/LibWeb/TestFaviconDecoding.cpp+++ b/Tests/LibWeb/TestFaviconDecoding.cpp@@ -10,9 +10,11 @@#include <LibWeb/Bindings/MainThreadVM.h>#include <LibWeb/Bindings/PrincipalHostDefined.h>#include <LibWeb/DOM/Document.h>+#include <LibWeb/Fetch/Fetching/FetchEngine.h>#include <LibWeb/HTML/HTMLHeadElement.h>#include <LibWeb/HTML/HTMLLinkElement.h>#include <LibWeb/HTML/LocalTraversableNavigable.h>+#include <LibWeb/HTML/Scripting/Agent.h>#include <LibWeb/Platform/FontPlugin.h>#include <LibWeb/Platform/ImageCodecPlugin.h>@@ -52,6 +54,7 @@ TEST_CASE(each_favicon_is_decoded_once)Web::Platform::ImageCodecPlugin::install(image_codec);auto realm = Web::Bindings::create_a_principal_javascript_realm();+ Web::HTML::surrounding_agent().fetch_executor = Web::Fetch::Fetching::create_inline_fetch_executor();auto& page = Web::Bindings::principal_host_defined_page(*realm);auto traversable = Web::HTML::LocalTraversableNavigable::create_a_new_top_level_traversable(page, nullptr, {});page.set_top_level_traversable(traversable);diff --git a/Tests/LibWeb/TestFetchAlgorithms.cpp b/Tests/LibWeb/TestFetchAlgorithms.cppindex 46adea9f40f..23203e00177 100644--- a/Tests/LibWeb/TestFetchAlgorithms.cpp+++ b/Tests/LibWeb/TestFetchAlgorithms.cpp@@ -13,12 +13,14 @@#include <LibGC/Testing.h>#include <LibTest/TestCase.h>#include <LibURL/Parser.h>+#include <LibWeb/Fetch/Fetching/FetchEngine.h>#include <LibWeb/Fetch/Fetching/Fetching.h>#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>#include <LibWeb/Fetch/Infrastructure/FetchController.h>#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>#include <LibWeb/Fetch/Infrastructure/HTTP/ResponseView.h>#include <LibWeb/HTML/EventLoop/EventLoop.h>+#include <LibWeb/HTML/Scripting/Agent.h>#include <LibWeb/HTML/Scripting/Environments.h>#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>@@ -44,6 +46,8 @@ struct FetchHarness {: document(create_test_document()), realm(document->relevant_settings_object().realm()){+ // Each case has an event loop of its own, which the window agent's fetches have to run on.+ Web::HTML::surrounding_agent().fetch_executor = Web::Fetch::Fetching::create_inline_fetch_executor();}// An unknown scheme: scheme fetch returns a network error, which has no body.diff --git a/Tests/LibWeb/TestFetchEngineMessages.cpp b/Tests/LibWeb/TestFetchEngineMessages.cppindex c08812dd9e0..f2e19652f5d 100644--- a/Tests/LibWeb/TestFetchEngineMessages.cpp+++ b/Tests/LibWeb/TestFetchEngineMessages.cpp@@ -20,10 +20,12 @@ static_assert(IsMoveConstructible<EngineCommand>);static_assert(!IsConstructible<Command::CompletedPreloadResponse::Completed, NullBody>);static_assert(!IsConstructible<Delivered<NonNullLocalBodyHandle>, NullBody>);+// Only fetch params build the input that starts a fetch.+static_assert(!IsConstructible<StartFetchInput, FetchId, BodyIntent, Optional<Web::FileAPI::SerializedBlobURLEntry>>);+TEST_CASE(commands_round_trip_their_payloads){Vector<EngineCommand> commands;- commands.append(Command::StartFetch { .input = { .fetch_id = FetchId(1), .body_intent = BodyIntent::DrainAndDiscard, .blob_url_entry = {} } });commands.append(Command::Abort { .fetch_id = FetchId(2) });commands.append(Command::Terminate { .fetch_id = FetchId(3) });commands.append(Command::Stop { .fetch_id = FetchId(4) });@@ -37,11 +39,7 @@ TEST_CASE(commands_round_trip_their_payloads)Vector<u64> seen_ids;for (auto& command : commands) {command.visit(- [&](Command::StartFetch const& start) {- EXPECT_EQ(start.input.body_intent, BodyIntent::DrainAndDiscard);- EXPECT(!start.input.blob_url_entry.has_value());- seen_ids.append(start.input.fetch_id.value());- },+ [&](Command::StartFetch const&) { FAIL("no fetch was started"); },[&](Command::Abort const& abort) { seen_ids.append(abort.fetch_id.value()); },[&](Command::Terminate const& terminate) { seen_ids.append(terminate.fetch_id.value()); },[&](Command::Stop const& stop) { seen_ids.append(stop.fetch_id.value()); },@@ -62,7 +60,7 @@ TEST_CASE(commands_round_trip_their_payloads)},[&](Command::AdoptNetworkTransport const&) { FAIL("no transport was posted"); });}- EXPECT_EQ(seen_ids, (Vector<u64> { 1, 2, 3, 4, 5, 7, 8 }));+ EXPECT_EQ(seen_ids, (Vector<u64> { 2, 3, 4, 5, 7, 8 }));}static bool peer_has_hung_up(IPC::Transport& transport)