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: check response for timinginfo allow flag #2477

Merged
merged 2 commits into from
Nov 29, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fetch/index.js
Expand Up @@ -286,7 +286,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
}

// 8. If response’s timing allow passed flag is not set, then:
if (!timingInfo.timingAllowPassed) {
if (!response.timingAllowPassed) {
// 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo.
timingInfo = createOpaqueTimingInfo({
startTime: timingInfo.startTime
Expand Down
24 changes: 24 additions & 0 deletions test/fetch/resource-timing.js
Expand Up @@ -46,3 +46,27 @@ test('should create a PerformanceResourceTiming after each fetch request', { ski

t.teardown(server.close.bind(server))
})

test('should include encodedBodySize in performance entry', { skip }, (t) => {
t.plan(4)
const obs = new PerformanceObserver(list => {
const [entry] = list.getEntries()
t.equal(entry.encodedBodySize, 2)
t.equal(entry.decodedBodySize, 2)
t.equal(entry.transferSize, 2 + 300)

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

obs.observe({ entryTypes: ['resource'] })

const server = createServer((req, res) => {
res.end('ok')
}).listen(0, async () => {
const body = await fetch(`http://localhost:${server.address().port}`)
t.strictSame('ok', await body.text())
})

t.teardown(server.close.bind(server))
})