Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update timingInfo to follow new spec changes #1143

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {
requestCurrentURL,
setRequestReferrerPolicyOnRedirect,
tryUpgradeRequestToAPotentiallyTrustworthyURL,
makeTimingInfo,
createOpaqueTimingInfo,
appendFetchMetadata,
corsCheck,
crossOriginResourcePolicyCheck,
Expand Down Expand Up @@ -226,11 +226,9 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {

// 6. If response’s timing allow passed flag is not set, then:
if (!timingInfo.timingAllowPassed) {
// 1. Set timingInfo to a new fetch timing info whose start time and
// post-redirect start time are timingInfo’s start time.
timingInfo = makeTimingInfo({
startTime: timingInfo.startTime,
postRedirectStartTime: timingInfo.postRedirectStartTime
// 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo.
timingInfo = createOpaqueTimingInfo({
startTime: timingInfo.startTime
})

// 2. Set cacheState to the empty string.
Expand Down Expand Up @@ -339,9 +337,8 @@ function fetching ({
// post-redirect start time are the coarsened shared current time given
// crossOriginIsolatedCapability.
const currenTime = coarsenedSharedCurrentTime(crossOriginIsolatedCapability)
const timingInfo = makeTimingInfo({
startTime: currenTime,
postRedirectStartTime: currenTime
const timingInfo = createOpaqueTimingInfo({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this falls under the category of an opaque timing info but it follows the guidelines of having default values and having startTime = postRedirectStartTime

startTime: currenTime
})

// 6. Let fetchParams be a new fetch params whose
Expand Down
12 changes: 6 additions & 6 deletions lib/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,20 @@ function coarsenedSharedCurrentTime (crossOriginIsolatedCapability) {
return performance.now()
}

function makeTimingInfo (init) {
// https://fetch.spec.whatwg.org/#create-an-opaque-timing-info
function createOpaqueTimingInfo (timingInfo) {
return {
startTime: 0,
startTime: timingInfo.startTime ?? 0,
redirectStartTime: 0,
redirectEndTime: 0,
postRedirectStartTime: 0,
postRedirectStartTime: timingInfo.startTime ?? 0,
finalServiceWorkerStartTime: 0,
finalNetworkResponseStartTime: 0,
finalNetworkRequestStartTime: 0,
endTime: 0,
encodedBodySize: 0,
decodedBodySize: 0,
finalConnectionTimingInfo: null,
...init
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because the spec states to "return a new fetch timing info whose start time and post-redirect start time are timingInfo’s start time.". Since only startTime and postRedirectStartTime can be changed it seems more explicit to show that their values are the only ones being updated.

finalConnectionTimingInfo: null
}
}

Expand Down Expand Up @@ -318,7 +318,7 @@ module.exports = {
TAOCheck,
corsCheck,
crossOriginResourcePolicyCheck,
makeTimingInfo,
createOpaqueTimingInfo,
setRequestReferrerPolicyOnRedirect,
isValidHTTPToken,
requestBadPort,
Expand Down