Skip to content

Commit

Permalink
Fix wpt/resource-timing/entries-for-network-errors.sub.https.html
Browse files Browse the repository at this point in the history
 - 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 <yhirano@chromium.org>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1019914}
NOKEYCHECK=True
GitOrigin-RevId: 4d89a41857c776be6a0b4295b84a62187753e8a6
  • Loading branch information
yutakahirano authored and Copybara-Service committed Jul 1, 2022
1 parent 2f0cfbb commit 4ed7f2e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
11 changes: 9 additions & 2 deletions blink/renderer/platform/loader/fetch/resource_fetcher.cc
Expand Up @@ -1064,8 +1064,15 @@ Resource* ResourceFetcher::RequestResource(FetchParameters& params,
absl::optional<ResourceRequestBlockedReason> 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;
Expand Down
2 changes: 0 additions & 2 deletions blink/web_tests/FlagExpectations/disable-layout-ng
Expand Up @@ -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 ]
Expand Down
Expand Up @@ -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 ]
Expand Down
2 changes: 0 additions & 2 deletions blink/web_tests/TestExpectations
Expand Up @@ -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 ]
Expand Down
Expand Up @@ -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');
}
}

Expand Down
Expand Up @@ -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(
Expand Down
Expand Up @@ -423,6 +423,9 @@ const invariants = {

assert_positive_(entry, [
"startTime",
]);

assert_not_negative_(entry, [
"duration",
]);

Expand Down Expand Up @@ -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}`);
}
}

0 comments on commit 4ed7f2e

Please sign in to comment.