-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[resource-timing] Fix failing WPT test
Bug: 1192641, 1290150 Change-Id: I70f5c662dbc7edfb52d2f9c9f2c36cc382b8210f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3448777 Reviewed-by: Nicolás Peña <[email protected]> Reviewed-by: Alexander Timin <[email protected]> Commit-Queue: Yoav Weiss <[email protected]> Cr-Commit-Position: refs/heads/main@{#969926}
- Loading branch information
1 parent
64ec12d
commit 9092429
Showing
1 changed file
with
23 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,45 +2,34 @@ | |
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>This test validates resource timing information for a cross-origin redirect chain.</title> | ||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/> | ||
<title>This test validates the values in resource timing for cross-origin | ||
redirects.</title> | ||
<link rel="author" title="Noam Rosenthal" href="[email protected]"> | ||
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-performanceresourcetiming"/> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src=/common/get-host-info.sub.js></script> | ||
<script src="resources/webperftestharness.js"></script> | ||
<script src="resources/webperftestharnessextension.js"></script> | ||
|
||
<script> | ||
setup({explicit_done: true}); | ||
test_namespace('getEntriesByName'); | ||
|
||
function onload_test() | ||
{ | ||
const context = new PerformanceContext(performance); | ||
const entries = context.getEntriesByName(document.querySelector('object').data, 'resource'); | ||
test_equals(entries.length, 1, 'There should be one entry.'); | ||
const entry = entries[0]; | ||
|
||
test_equals(entry.redirectStart, 0, 'redirectStart == 0 in cross-origin redirect.'); | ||
test_equals(entry.redirectEnd, 0, 'redirectEnd == 0 in cross-origin redirect.'); | ||
test_greater_than(entry.fetchStart, 0, 'fetchStart > 0 in cross-origin redirect.'); | ||
test_equals(entry.startTime, entry.fetchStart, 'startTime == fetchStart in cross-origin redirect.'); | ||
done(); | ||
} | ||
</script> | ||
|
||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="resources/resource-loaders.js"></script> | ||
<script src="resources/entry-invariants.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
let destUrl = get_host_info().HTTP_REMOTE_ORIGIN + '/resource-timing/resources/multi_redirect.py?'; | ||
destUrl += 'page_origin=' + 'http://' + document.location.host; | ||
destUrl += '&cross_origin=' + get_host_info().HTTP_REMOTE_ORIGIN; | ||
destUrl += '&final_resource=' + encodeURIComponent("/resource-timing/resources/status-code.py?status=404"); | ||
const objElement = document.createElement('object'); | ||
objElement.style = 'width: 0px; height: 0px;'; | ||
objElement.data = destUrl; | ||
objElement.onerror = onload_test; | ||
document.body.appendChild(objElement); | ||
const {REMOTE_ORIGIN} = get_host_info(); | ||
const delay = 2 | ||
const not_found_page = encodeURIComponent("/resource-timing/resources/status-code.py?status=404"); | ||
const load_null_object = async path => { | ||
return load.object(path, null); | ||
} | ||
const destUrl = `/common/slow-redirect.py?delay=${delay}&location=${REMOTE_ORIGIN}/${not_found_page}`; | ||
|
||
const timeBefore = performance.now() | ||
attribute_test(load_null_object, destUrl, entry => { | ||
assert_equals(entry.startTime, entry.fetchStart, 'startTime and fetchStart should be equal'); | ||
assert_greater_than(entry.startTime, timeBefore, 'startTime and fetchStart should be greater than the time before fetching'); | ||
// See https://github.com/w3c/resource-timing/issues/264 | ||
assert_less_than(Math.round(entry.startTime - timeBefore), delay * 1000, 'startTime should not expose redirect delays'); | ||
}, "Verify that cross-origin object resources don't implicitly expose their redirect timings") | ||
|
||
</script> | ||
</body> | ||
</html> |