From 4ed7f2e5fddbc2ff54433c1f93cbdd6c645fb90c Mon Sep 17 00:00:00 2001 From: Yutaka Hirano Date: Fri, 1 Jul 2022 01:52:49 +0000 Subject: [PATCH] Fix wpt/resource-timing/entries-for-network-errors.sub.https.html - Add a timing entry when resource loading is blocked. - cache: 'only-if-cached' must be used with the same-origin mode. Fix the test case. - `entry.duration` can be zero. Fix the test case. Bug: 1275564 Change-Id: I9fec4450cdc099202e6dbd138996387bdd3d765b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3702411 Commit-Queue: Yutaka Hirano Reviewed-by: Yoav Weiss Cr-Commit-Position: refs/heads/main@{#1019914} NOKEYCHECK=True GitOrigin-RevId: 4d89a41857c776be6a0b4295b84a62187753e8a6 --- .../platform/loader/fetch/resource_fetcher.cc | 11 +++++++++-- blink/web_tests/FlagExpectations/disable-layout-ng | 2 -- .../FlagExpectations/disable-site-isolation-trials | 1 - blink/web_tests/TestExpectations | 2 -- .../support/prefetch-helper.js | 11 ++++++++--- .../entries-for-network-errors.sub.https.html | 2 +- .../wpt/resource-timing/resources/entry-invariants.js | 5 ++++- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/blink/renderer/platform/loader/fetch/resource_fetcher.cc b/blink/renderer/platform/loader/fetch/resource_fetcher.cc index 0ee2db53efbc..86d2b99e096e 100644 --- a/blink/renderer/platform/loader/fetch/resource_fetcher.cc +++ b/blink/renderer/platform/loader/fetch/resource_fetcher.cc @@ -1064,8 +1064,15 @@ Resource* ResourceFetcher::RequestResource(FetchParameters& params, absl::optional blocked_reason = PrepareRequest(params, factory, pauser); if (blocked_reason) { - return ResourceForBlockedRequest(params, factory, blocked_reason.value(), - client); + auto* resource = ResourceForBlockedRequest(params, factory, + blocked_reason.value(), client); + StorePerformanceTimingInitiatorInformation(resource); + if (auto info = resource_timing_info_map_.Take(resource)) { + PopulateAndAddResourceTimingInfo(resource, info, + /*response_end=*/base::TimeTicks::Now()); + Context().AddResourceTiming(*info); + } + return resource; } Resource* resource = nullptr; diff --git a/blink/web_tests/FlagExpectations/disable-layout-ng b/blink/web_tests/FlagExpectations/disable-layout-ng index 582f87426c9a..d4c3a28706bb 100644 --- a/blink/web_tests/FlagExpectations/disable-layout-ng +++ b/blink/web_tests/FlagExpectations/disable-layout-ng @@ -61,8 +61,6 @@ crbug.com/626703 external/wpt/selection/textcontrols/onselectionchange-content-a crbug.com/626703 external/wpt/infrastructure/channels/test_call.html [ Timeout ] crbug.com/626703 external/wpt/infrastructure/channels/test_postMessage.html [ Timeout ] crbug.com/626703 external/wpt/infrastructure/channels/test_serialize.html [ Timeout ] -crbug.com/626703 external/wpt/resource-timing/entries-for-network-errors.sub.https.html [ Timeout ] -crbug.com/626703 virtual/plz-dedicated-worker/external/wpt/resource-timing/entries-for-network-errors.sub.https.html [ Timeout ] crbug.com/626703 external/wpt/css/css-flexbox/percentage-heights-019.html [ Failure ] crbug.com/626703 external/wpt/css/css-grid/grid-items/aspect-ratio-005.html [ Failure ] crbug.com/626703 external/wpt/mediacapture-fromelement/capture.html [ Crash ] diff --git a/blink/web_tests/FlagExpectations/disable-site-isolation-trials b/blink/web_tests/FlagExpectations/disable-site-isolation-trials index 8ca64b4e8bd1..7e45e80108a1 100644 --- a/blink/web_tests/FlagExpectations/disable-site-isolation-trials +++ b/blink/web_tests/FlagExpectations/disable-site-isolation-trials @@ -83,7 +83,6 @@ crbug.com/626703 external/wpt/selection/textcontrols/onselectionchange-content-a crbug.com/626703 external/wpt/infrastructure/channels/test_call.html [ Timeout ] crbug.com/626703 external/wpt/infrastructure/channels/test_postMessage.html [ Timeout ] crbug.com/626703 external/wpt/infrastructure/channels/test_serialize.html [ Timeout ] -crbug.com/626703 external/wpt/resource-timing/entries-for-network-errors.sub.https.html [ Timeout ] # crbug.com/1339051: some ref tests generate output with minor differences. crbug.com/1339051 external/wpt/css/css-transforms/perspective-split-by-zero-w.html [ Failure ] diff --git a/blink/web_tests/TestExpectations b/blink/web_tests/TestExpectations index dc802d19b486..9ddd517f0950 100644 --- a/blink/web_tests/TestExpectations +++ b/blink/web_tests/TestExpectations @@ -3506,8 +3506,6 @@ crbug.com/626703 external/wpt/infrastructure/channels/test_postMessage.html [ Ti crbug.com/626703 external/wpt/infrastructure/channels/test_serialize.html [ Timeout ] crbug.com/626703 [ Win10.20h2 ] external/wpt/mediacapture-streams/MediaDevices-enumerateDevices-per-origin-ids.sub.https.html [ Failure Timeout ] crbug.com/626703 [ Win10.20h2 ] virtual/feature-policy-permissions/external/wpt/mediacapture-streams/MediaDevices-enumerateDevices-per-origin-ids.sub.https.html [ Failure Timeout ] -crbug.com/626703 external/wpt/resource-timing/entries-for-network-errors.sub.https.html [ Timeout ] -crbug.com/626703 virtual/plz-dedicated-worker/external/wpt/resource-timing/entries-for-network-errors.sub.https.html [ Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/webrtc/RTCDataChannel-close.html [ Skip Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/webrtc/RTCPeerConnection-capture-video.https.html [ Skip Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https.html [ Skip Timeout ] diff --git a/blink/web_tests/external/wpt/content-security-policy/support/prefetch-helper.js b/blink/web_tests/external/wpt/content-security-policy/support/prefetch-helper.js index 4beae8885933..cb6fd4823f00 100644 --- a/blink/web_tests/external/wpt/content-security-policy/support/prefetch-helper.js +++ b/blink/web_tests/external/wpt/content-security-policy/support/prefetch-helper.js @@ -22,9 +22,14 @@ async function waitUntilResourceDownloaded(url) { }); } -async function assert_resource_not_downloaded(test, url) { - if (performance.getEntriesByName(url).length >= 1) { - (test.unreached_func(`'${url}' should not have downloaded.`))(); +function assert_resource_not_downloaded(test, url) { + // CSP failures generate resource timing entries, so let's make sure that + // download sizes are 0. + const entries = performance.getEntriesByName(url, 'resource'); + for (const entry of entries) { + assert_equals(entry.transferSize, 0, 'transferSize'); + assert_equals(entry.encodedBodySize, 0, 'encodedBodySize'); + assert_equals(entry.decodedBodySize, 0, 'decodedBodySize'); } } diff --git a/blink/web_tests/external/wpt/resource-timing/entries-for-network-errors.sub.https.html b/blink/web_tests/external/wpt/resource-timing/entries-for-network-errors.sub.https.html index a3c4791f68d9..95849d282621 100644 --- a/blink/web_tests/external/wpt/resource-timing/entries-for-network-errors.sub.https.html +++ b/blink/web_tests/external/wpt/resource-timing/entries-for-network-errors.sub.https.html @@ -24,7 +24,7 @@ network_error_entry_test('//{{hosts[][nonexistent]}}/common/dummy.xml', null, "DNS failure"); network_error_entry_test(`http://${ORIGINAL_HOST}:${HTTP_PORT}/commo/dummy.xml`, null, "Mixed content"); -network_error_entry_test('/common/dummy.xml', {cache: 'only-if-cached'}, +network_error_entry_test('/common/dummy.xml', {cache: 'only-if-cached', mode: 'same-origin'}, "only-if-cached resource that was not cached"); network_error_entry_test( diff --git a/blink/web_tests/external/wpt/resource-timing/resources/entry-invariants.js b/blink/web_tests/external/wpt/resource-timing/resources/entry-invariants.js index 0bb18c598334..4bef9496103c 100644 --- a/blink/web_tests/external/wpt/resource-timing/resources/entry-invariants.js +++ b/blink/web_tests/external/wpt/resource-timing/resources/entry-invariants.js @@ -423,6 +423,9 @@ const invariants = { assert_positive_(entry, [ "startTime", + ]); + + assert_not_negative_(entry, [ "duration", ]); @@ -501,4 +504,4 @@ const network_error_entry_test = (originalURL, args, label) => { assert_greater_than_equal(timeAfter, entry.responseEnd, 'endTime should be less than the time right after returning from the fetch'); invariants.assert_tao_failure_resource(entry); }, `A ResourceTiming entry should be created for network error of type ${label}`); -} \ No newline at end of file +}