Skip to content

Commit

Permalink
update create opaque timing info (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored Dec 14, 2021
1 parent 7ff1dbc commit bc21562
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
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({
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
finalConnectionTimingInfo: null
}
}

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

0 comments on commit bc21562

Please sign in to comment.