@@ -205,27 +205,38 @@ async function fetch (...args) {
205
205
return p . promise
206
206
}
207
207
208
+ // https://fetch.spec.whatwg.org/#finalize-and-report-timing
208
209
function finalizeAndReportTiming ( response , initiatorType = 'other' ) {
209
- // 1. If response’s URL list is null or empty, then return.
210
+ // 1. If response is an aborted network error, then return.
211
+ if ( response . type === 'error' && response . aborted ) {
212
+ return
213
+ }
214
+
215
+ // 2. If response’s URL list is null or empty, then return.
210
216
if ( ! response . urlList ?. length ) {
211
217
return
212
218
}
213
219
214
- // 2 . Let originalURL be response’s URL list[0].
220
+ // 3 . Let originalURL be response’s URL list[0].
215
221
const originalURL = response . urlList [ 0 ]
216
222
217
- // 3 . Let timingInfo be response’s timing info.
223
+ // 4 . Let timingInfo be response’s timing info.
218
224
let timingInfo = response . timingInfo
219
225
220
- // 4 . Let cacheState be response’s cache state.
226
+ // 5 . Let cacheState be response’s cache state.
221
227
let cacheState = response . cacheState
222
228
223
- // 5. If timingInfo is null, then return.
229
+ // 6. If originalURL’s scheme is not an HTTP(S) scheme, then return.
230
+ if ( ! / ^ h t t p s ? : / . test ( originalURL . protocol ) ) {
231
+ return
232
+ }
233
+
234
+ // 7. If timingInfo is null, then return.
224
235
if ( timingInfo === null ) {
225
236
return
226
237
}
227
238
228
- // 6 . If response’s timing allow passed flag is not set, then:
239
+ // 8 . If response’s timing allow passed flag is not set, then:
229
240
if ( ! timingInfo . timingAllowPassed ) {
230
241
// 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo.
231
242
timingInfo = createOpaqueTimingInfo ( {
@@ -236,23 +247,23 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
236
247
cacheState = ''
237
248
}
238
249
239
- // 7 . Set timingInfo’s end time to the coarsened shared current time
250
+ // 9 . Set timingInfo’s end time to the coarsened shared current time
240
251
// given global’s relevant settings object’s cross-origin isolated
241
252
// capability.
242
253
// TODO: given global’s relevant settings object’s cross-origin isolated
243
254
// capability?
244
255
response . timingInfo . endTime = coarsenedSharedCurrentTime ( )
245
256
246
- // 8 . Set response’s timing info to timingInfo.
257
+ // 10 . Set response’s timing info to timingInfo.
247
258
response . timingInfo = timingInfo
248
259
249
- // 9 . Mark resource timing for timingInfo, originalURL, initiatorType,
260
+ // 11 . Mark resource timing for timingInfo, originalURL, initiatorType,
250
261
// global, and cacheState.
251
262
markResourceTiming (
252
263
timingInfo ,
253
264
originalURL ,
254
265
initiatorType ,
255
- global ,
266
+ globalThis ,
256
267
cacheState
257
268
)
258
269
}
0 commit comments