Truly independent web browser
LibWeb: Collect navigation server timing for the destination context
Andreas Klingafc3ba471f96
diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cppindex 2a6145f0897..e61d2560a6f 100644--- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp+++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp@@ -894,7 +894,9 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const// The user agent may decide to expose `Server-Timing` headers to non-secure contexts requests as well.// NOTE: Using response’s internal response is safe as exposing `Server-Timing` header data is guarded through the// `Timing-Allow-Origin` header.- auto client = fetch_params.request()->client();+ // INTEROP: A navigation's reserved client describes its destination context. Use it so entry-point navigations+ // collect timing headers even without an initiating client.+ auto client = determine_the_environment(fetch_params.request());if (!response.is_network_error() && client != nullptr && HTML::is_secure_context(*client)) {if (auto server_timing_headers = response.unsafe_response()->header_list()->get_decode_and_split("Server-Timing"sv); server_timing_headers.has_value())timing_info->set_server_timing_headers(server_timing_headers.release_value());diff --git a/Tests/LibWeb/Text/expected/wpt-import/server-timing/test_server_timing.https.txt b/Tests/LibWeb/Text/expected/wpt-import/server-timing/test_server_timing.https.txtindex 399f9dc4388..cd576326424 100644--- a/Tests/LibWeb/Text/expected/wpt-import/server-timing/test_server_timing.https.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/server-timing/test_server_timing.https.txt@@ -2,11 +2,10 @@ Harness status: OKFound 7 tests-4 Pass-3 Fail-Fail test_server_timing-Fail Entry {"duration":1.1,"name":"metric1","description":"document"} could not be found.-Fail Entry {"duration":1.2,"name":"metric1","description":"document"} could not be found.+7 Pass+Pass test_server_timing+Pass Entry {"duration":1.1,"name":"metric1","description":"document"} could not be found.+Pass Entry {"duration":1.2,"name":"metric1","description":"document"} could not be found.Pass test_server_timing 1Pass Entry {"duration":2.1,"name":"metric2","description":"blue.png"} could not be found.Pass test_server_timing 2