Skip to content

Commit eb24cc8

Browse files
authored
fix: fetch resource timing performance entry names should be strings (#2188)
* fix: fetch resource timing performance entry names should be strings * change .toString() to .href
1 parent e22448d commit eb24cc8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/fetch/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
320320
// https://w3c.github.io/resource-timing/#dfn-mark-resource-timing
321321
function markResourceTiming (timingInfo, originalURL, initiatorType, globalThis, cacheState) {
322322
if (nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 2)) {
323-
performance.markResourceTiming(timingInfo, originalURL, initiatorType, globalThis, cacheState)
323+
performance.markResourceTiming(timingInfo, originalURL.href, initiatorType, globalThis, cacheState)
324324
}
325325
}
326326

test/fetch/resource-timing.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,24 @@ const {
1313
const skip = nodeMajor < 18 || (nodeMajor === 18 && nodeMinor < 2)
1414

1515
test('should create a PerformanceResourceTiming after each fetch request', { skip }, (t) => {
16-
t.plan(6)
16+
t.plan(8)
1717

1818
const obs = new PerformanceObserver(list => {
19+
const expectedResourceEntryName = `http://localhost:${server.address().port}/`
20+
1921
const entries = list.getEntries()
2022
t.equal(entries.length, 1)
2123
const [entry] = entries
22-
t.same(entry.name, {
23-
href: `http://localhost:${server.address().port}/`,
24-
origin: `http://localhost:${server.address().port}`,
25-
protocol: 'http'
26-
})
24+
t.same(entry.name, expectedResourceEntryName)
2725
t.strictSame(entry.entryType, 'resource')
2826

2927
t.ok(entry.duration >= 0)
3028
t.ok(entry.startTime >= 0)
3129

30+
const entriesByName = list.getEntriesByName(expectedResourceEntryName)
31+
t.equal(entriesByName.length, 1)
32+
t.strictSame(entriesByName[0], entry)
33+
3234
obs.disconnect()
3335
performance.clearResourceTimings()
3436
})

0 commit comments

Comments
 (0)