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

fix: correctly calculate resource timing duration #1988

Merged
merged 1 commit into from
Mar 4, 2023
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
2 changes: 1 addition & 1 deletion lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
// capability.
// TODO: given global’s relevant settings object’s cross-origin isolated
// capability?
response.timingInfo.endTime = coarsenedSharedCurrentTime()
timingInfo.endTime = coarsenedSharedCurrentTime()

// 10. Set response’s timing info to timingInfo.
response.timingInfo = timingInfo
Expand Down
5 changes: 4 additions & 1 deletion test/fetch/resource-timing.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
const skip = nodeMajor < 18 || (nodeMajor === 18 && nodeMinor < 2)

test('should create a PerformanceResourceTiming after each fetch request', { skip }, (t) => {
t.plan(4)
t.plan(6)
const obs = new PerformanceObserver(list => {
const entries = list.getEntries()
t.equal(entries.length, 1)
Expand All @@ -25,6 +25,9 @@ test('should create a PerformanceResourceTiming after each fetch request', { ski
})
t.strictSame(entry.entryType, 'resource')

t.ok(entry.duration >= 0)
t.ok(entry.startTime >= 0)

obs.disconnect()
performance.clearResourceTimings()
})
Expand Down