Skip to content

Commit 19c69a0

Browse files
ToshBKhafraDev
andauthoredNov 29, 2023
fix: check response for timinginfo allow flag (#2477)
* fix: check response for timinginfo allow flag * Update test/fetch/resource-timing.js --------- Co-authored-by: Khafra <maitken033380023@gmail.com>
1 parent c5d73ca commit 19c69a0

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
 

‎lib/fetch/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
286286
}
287287

288288
// 8. If response’s timing allow passed flag is not set, then:
289-
if (!timingInfo.timingAllowPassed) {
289+
if (!response.timingAllowPassed) {
290290
// 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo.
291291
timingInfo = createOpaqueTimingInfo({
292292
startTime: timingInfo.startTime

‎test/fetch/resource-timing.js

+24
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,27 @@ test('should create a PerformanceResourceTiming after each fetch request', { ski
4646

4747
t.teardown(server.close.bind(server))
4848
})
49+
50+
test('should include encodedBodySize in performance entry', { skip }, (t) => {
51+
t.plan(4)
52+
const obs = new PerformanceObserver(list => {
53+
const [entry] = list.getEntries()
54+
t.equal(entry.encodedBodySize, 2)
55+
t.equal(entry.decodedBodySize, 2)
56+
t.equal(entry.transferSize, 2 + 300)
57+
58+
obs.disconnect()
59+
performance.clearResourceTimings()
60+
})
61+
62+
obs.observe({ entryTypes: ['resource'] })
63+
64+
const server = createServer((req, res) => {
65+
res.end('ok')
66+
}).listen(0, async () => {
67+
const body = await fetch(`http://localhost:${server.address().port}`)
68+
t.strictSame('ok', await body.text())
69+
})
70+
71+
t.teardown(server.close.bind(server))
72+
})

0 commit comments

Comments
 (0)
Please sign in to comment.