Commit 5e556dd8 authored by Yoav Weiss's avatar Yoav Weiss Committed by Commit Bot

[resource-timing] Report performance entries with failing status codes

Currently we don't report performance entries with failing status codes.
From the spec's perspective, reporting aborts is a MAY, but failing
status code responses should not be considered aborts. [1]
Chromium is the only engine which doesn't report those entries.
This CL fixes that to report them similarly to successful status codes.

Bug: 883400, 990849
Change-Id: Ic5e99e3df77f3869aa0dd70f0141d88016fdb972

[1] https://github.com/w3c/resource-timing/issues/165#issuecomment-441413636

Change-Id: Ic5e99e3df77f3869aa0dd70f0141d88016fdb972
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1796544
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695596}
parent 17a3f584
......@@ -1793,8 +1793,7 @@ void ResourceFetcher::HandleLoaderFinish(Resource* resource,
if (scoped_refptr<ResourceTimingInfo> info =
resource_timing_info_map_.Take(resource)) {
if (resource->GetResponse().IsHTTP() &&
resource->GetResponse().HttpStatusCode() < 400) {
if (resource->GetResponse().IsHTTP()) {
info->SetInitialURL(resource->GetResourceRequest()
.GetInitialUrlForResourceTiming()
.IsNull()
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing ignores failed resources</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>
<script>
let iframe;
function setup_iframe() {
const iframe_content = '<img src="resources/non-existing-file.png"></img>';
iframe = document.getElementById('frameContext');
iframe.contentWindow.document.write(iframe_content);
}
function onload_test() {
const context = new PerformanceContext(iframe.contentWindow.performance);
const entries = context.getEntriesByType('resource');
test_true(entries.length == 0, "entries.length == 0");
}
window.setup_iframe = setup_iframe;
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that failed resources aren't present in the Resource Timing buffer.</p>
<div id="log"></div>
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
</body>
</html>
def main(request, response):
status = request.GET.first('status')
response.status = (status, "");
<!doctype html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<img src="resources/status-code.py?status=200">
<img src="resources/status-code.py?status=307">
<img src="resources/status-code.py?status=404">
<img src="resources/status-code.py?status=502">
<script>
async_test(t => {
window.addEventListener("load", t.step_func(() => {
const images = document.getElementsByTagName("img");
for (let img of images) {
assert_equals(performance.getEntriesByName(img.src).length, 1, img.src);
}
t.done();
}));
}, "Make sure all status codes are reported");
</script>
......@@ -98,14 +98,12 @@ promise_test(function(t) {
resource: 'resources/missing.jpg',
mode: 'same-origin',
description: 'Network fallback load failure',
should_no_performance_entry: true,
});
verify({
performance: performance,
resource: 'resources/missing.jpg',
mode: 'cross-origin',
description: 'Network fallback cross-origin load failure',
should_no_performance_entry: true,
});
// Tests for respondWith(fetch()).
verify({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment