forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
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 negative duration case
Bug: 1157818 Change-Id: Ie5e75ccb239735f3500f8763e4d9255eba2056e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592792 Commit-Queue: Yoav Weiss <yoavweiss@chromium.org> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#841159}
- Loading branch information
1 parent
188bf17
commit d9a933a
Showing
7 changed files
with
137 additions
and
2 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Access-Control-Allow-Origin: * | ||
Cache-Control: max-age=3600 | ||
Timing-Allow-Origin: * |
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
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Test cross-origin fetch redirects have the right values.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script> | ||
const run_test = async (t, url, cross_origin) => { | ||
// Set up PerformanceObserver | ||
const href = new URL(url).href; | ||
const setPerformanceObserver = new Promise(resolve => { | ||
const po = new PerformanceObserver(resolve); | ||
po.observe({type: "resource"}); | ||
}); | ||
|
||
// Fetch the resource | ||
await fetch(href, {mode: "no-cors", credentials: "include" }); | ||
|
||
// Wait for an entry | ||
const timeout = new Promise(resolve => t.step_timeout(resolve, 1000)); | ||
const list = await Promise.race([setPerformanceObserver, timeout]); | ||
assert_equals(typeof(list), "object", "No iframe entry was fired"); | ||
const entries = list.getEntriesByName(url); | ||
assert_equals(entries.length, 1); | ||
|
||
// Test entry values | ||
const entry = entries[0]; | ||
if (cross_origin) { | ||
assert_equals(entry.redirectStart, 0, "redirectStart should be 0 in cross-origin redirect."); | ||
assert_equals(entry.redirectEnd, 0, "redirectEnd should be 0 in cross-origin redirect."); | ||
assert_equals(entry.domainLookupStart, 0, "domainLookupStart should be 0 in cross-origin redirect."); | ||
assert_equals(entry.domainLookupEnd, 0, "domainLookupEnd should be 0 in cross-origin redirect."); | ||
assert_equals(entry.connectStart, 0, "connectStart should be 0 in cross-origin redirect."); | ||
assert_equals(entry.connectEnd, 0, "connectEnd should be 0 in cross-origin redirect."); | ||
assert_equals(entry.requestStart, 0, "requestStart should be 0 in cross-origin redirect."); | ||
assert_equals(entry.responseStart, 0, "responseStart should be 0 in cross-origin redirect."); | ||
assert_equals(entry.secureConnectionStart, 0, "secureConnectionStart should be 0 in cross-origin redirect."); | ||
} else { | ||
assert_greater_than(entry.redirectStart, 0, "redirectStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.redirectEnd, 0, "redirectEnd should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.domainLookupStart, 0, "domainLookupStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.domainLookupEnd, 0, "domainLookupEnd should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.connectStart, 0, "connectStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.connectEnd, 0, "connectEnd should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.requestStart, 0, "requestStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.responseStart, 0, "responseStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than(entry.secureConnectionStart, 0, "secureConnectionStart should be more than 0 in same-origin redirect."); | ||
} | ||
assert_greater_than(entry.fetchStart, 0, "fetchStart should be greater than 0 in redirects."); | ||
assert_greater_than(entry.responseEnd, 0, "responseEnd should be greater than 0 in redirects."); | ||
assert_greater_than(entry.duration, 0, "duration should be greater than 0 in redirects."); | ||
assert_greater_than(entry.responseEnd, entry.fetchStart, "responseEnd should be greater than fetchStart in redirects."); | ||
} | ||
|
||
const {REMOTE_ORIGIN, ORIGIN} = get_host_info(); | ||
const redirect = "/common/redirect.py?location=" + "/resource-timing/resources/blank_page_green.htm"; | ||
const cross_origin_redirect = REMOTE_ORIGIN + redirect; | ||
const same_origin_redirect = ORIGIN + redirect; | ||
promise_test(t => { | ||
return run_test(t, cross_origin_redirect, true); | ||
}, "Test fetch for a cross-origin redirect URL"); | ||
promise_test(t => { | ||
return run_test(t, same_origin_redirect, false); | ||
}, "Test fetch for a same-origin redirect URL"); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Test cross-origin fetch redirects have the right values.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<body> | ||
<script> | ||
const load_font = url => { | ||
document.body.innerHTML = ` | ||
<style> | ||
@font-face { | ||
font-family: ahem; | ||
src: url('${url}'); | ||
} | ||
</style> | ||
<div style="font-family: ahem;">This fetches ahem font.</div> | ||
`; | ||
return document.fonts.ready; | ||
}; | ||
|
||
const run_test = async (t, url) => { | ||
// Set up PerformanceObserver | ||
const href = new URL(url).href; | ||
const setPerformanceObserver = new Promise(resolve => { | ||
const po = new PerformanceObserver(resolve); | ||
po.observe({type: "resource"}); | ||
}); | ||
|
||
// Load the font resource and wait for it to be fetched. | ||
await load_font(href); | ||
|
||
// Wait for an entry | ||
const timeout = new Promise(resolve => t.step_timeout(resolve, 3000)); | ||
const list = await Promise.race([setPerformanceObserver, timeout]); | ||
assert_equals(typeof(list), "object", "No iframe entry was fired"); | ||
const entries = list.getEntriesByName(url); | ||
assert_equals(entries.length, 1); | ||
|
||
// Test entry values | ||
const entry = entries[0]; | ||
assert_greater_than(entry.fetchStart, 0, "fetchStart should be greater than 0 in redirects."); | ||
assert_greater_than_equal(entry.domainLookupStart, entry.fetchStart, "domainLookupStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than_equal(entry.domainLookupEnd, entry.domainLookupStart, "domainLookupEnd should be more than 0 in same-origin redirect."); | ||
assert_greater_than_equal(entry.connectStart, entry.domainLookupEnd, "connectStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than_equal(entry.secureConnectionStart, entry.connectStart, "secureConnectionStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than_equal(entry.connectEnd, entry.secureConnectionStart, "connectEnd should be more than 0 in same-origin redirect."); | ||
assert_greater_than_equal(entry.requestStart, entry.connectEnd, "requestStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than_equal(entry.responseStart, entry.requestStart, "responseStart should be more than 0 in same-origin redirect."); | ||
assert_greater_than_equal(entry.responseEnd, entry.responseStart, "responseEnd should be greater than 0 in redirects."); | ||
assert_greater_than_equal(entry.duration, 0, "duration should be greater than 0 in redirects."); | ||
} | ||
|
||
const {HTTPS_REMOTE_ORIGIN} = get_host_info(); | ||
promise_test(t => { | ||
return run_test(t, HTTPS_REMOTE_ORIGIN + "/fonts/Ahem.ttf"); | ||
}, "Test a font's timestamps"); | ||
|
||
promise_test(t => { | ||
return run_test(t, HTTPS_REMOTE_ORIGIN + "/resource-timing/resources/cors-ahem.py?pipe=trickle(d1)"); | ||
}, "Test a font's timestamps with delays"); | ||
</script> |
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
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
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