undici 6.14.1 → 6.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index-fetch.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ const { getGlobalDispatcher, setGlobalDispatcher } = require('./lib/global')
4
+ const EnvHttpProxyAgent = require('./lib/dispatcher/env-http-proxy-agent')
3
5
  const fetchImpl = require('./lib/web/fetch').fetch
4
6
 
5
7
  module.exports.fetch = function fetch (resource, init = undefined) {
@@ -15,7 +17,16 @@ module.exports.Headers = require('./lib/web/fetch/headers').Headers
15
17
  module.exports.Response = require('./lib/web/fetch/response').Response
16
18
  module.exports.Request = require('./lib/web/fetch/request').Request
17
19
 
20
+ const { CloseEvent, ErrorEvent, MessageEvent, createFastMessageEvent } = require('./lib/web/websocket/events')
18
21
  module.exports.WebSocket = require('./lib/web/websocket/websocket').WebSocket
19
- module.exports.MessageEvent = require('./lib/web/websocket/events').MessageEvent
22
+ module.exports.CloseEvent = CloseEvent
23
+ module.exports.ErrorEvent = ErrorEvent
24
+ module.exports.MessageEvent = MessageEvent
25
+ module.exports.createFastMessageEvent = createFastMessageEvent
20
26
 
21
27
  module.exports.EventSource = require('./lib/web/eventsource/eventsource').EventSource
28
+
29
+ // Expose the fetch implementation to be enabled in Node.js core via a flag
30
+ module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent
31
+ module.exports.getGlobalDispatcher = getGlobalDispatcher
32
+ module.exports.setGlobalDispatcher = setGlobalDispatcher
@@ -7,9 +7,7 @@ const { isDisturbed, parseHeaders, parseRangeHeader } = require('../core/util')
7
7
 
8
8
  function calculateRetryAfterHeader (retryAfter) {
9
9
  const current = Date.now()
10
- const diff = new Date(retryAfter).getTime() - current
11
-
12
- return diff
10
+ return new Date(retryAfter).getTime() - current
13
11
  }
14
12
 
15
13
  class RetryHandler {
@@ -116,11 +114,7 @@ class RetryHandler {
116
114
  const { counter } = state
117
115
 
118
116
  // Any code that is not a Undici's originated and allowed to retry
119
- if (
120
- code &&
121
- code !== 'UND_ERR_REQ_RETRY' &&
122
- !errorCodes.includes(code)
123
- ) {
117
+ if (code && code !== 'UND_ERR_REQ_RETRY' && !errorCodes.includes(code)) {
124
118
  cb(err)
125
119
  return
126
120
  }
@@ -246,10 +240,7 @@ class RetryHandler {
246
240
  start != null && Number.isFinite(start),
247
241
  'content-range mismatch'
248
242
  )
249
- assert(
250
- end != null && Number.isFinite(end),
251
- 'invalid content-length'
252
- )
243
+ assert(end != null && Number.isFinite(end), 'invalid content-length')
253
244
 
254
245
  this.start = start
255
246
  this.end = end
@@ -270,6 +261,13 @@ class RetryHandler {
270
261
  this.resume = resume
271
262
  this.etag = headers.etag != null ? headers.etag : null
272
263
 
264
+ // Weak etags are not useful for comparison nor cache
265
+ // for instance not safe to assume if the response is byte-per-byte
266
+ // equal
267
+ if (this.etag != null && this.etag.startsWith('W/')) {
268
+ this.etag = null
269
+ }
270
+
273
271
  return this.handler.onHeaders(
274
272
  statusCode,
275
273
  rawHeaders,
@@ -308,7 +306,9 @@ class RetryHandler {
308
306
  // and server error response
309
307
  if (this.retryCount - this.retryCountCheckpoint > 0) {
310
308
  // We count the difference between the last checkpoint and the current retry count
311
- this.retryCount = this.retryCountCheckpoint + (this.retryCount - this.retryCountCheckpoint)
309
+ this.retryCount =
310
+ this.retryCountCheckpoint +
311
+ (this.retryCount - this.retryCountCheckpoint)
312
312
  } else {
313
313
  this.retryCount += 1
314
314
  }
@@ -328,11 +328,18 @@ class RetryHandler {
328
328
  }
329
329
 
330
330
  if (this.start !== 0) {
331
+ const headers = { range: `bytes=${this.start}-${this.end ?? ''}` }
332
+
333
+ // Weak etag check - weak etags will make comparison algorithms never match
334
+ if (this.etag != null) {
335
+ headers['if-match'] = this.etag
336
+ }
337
+
331
338
  this.opts = {
332
339
  ...this.opts,
333
340
  headers: {
334
341
  ...this.opts.headers,
335
- range: `bytes=${this.start}-${this.end ?? ''}`
342
+ ...headers
336
343
  }
337
344
  }
338
345
  }
@@ -42,10 +42,12 @@ class Cache {
42
42
 
43
43
  async match (request, options = {}) {
44
44
  webidl.brandCheck(this, Cache)
45
- webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.match' })
46
45
 
47
- request = webidl.converters.RequestInfo(request)
48
- options = webidl.converters.CacheQueryOptions(options)
46
+ const prefix = 'Cache.match'
47
+ webidl.argumentLengthCheck(arguments, 1, prefix)
48
+
49
+ request = webidl.converters.RequestInfo(request, prefix, 'request')
50
+ options = webidl.converters.CacheQueryOptions(options, prefix, 'options')
49
51
 
50
52
  const p = this.#internalMatchAll(request, options, 1)
51
53
 
@@ -59,17 +61,20 @@ class Cache {
59
61
  async matchAll (request = undefined, options = {}) {
60
62
  webidl.brandCheck(this, Cache)
61
63
 
62
- if (request !== undefined) request = webidl.converters.RequestInfo(request)
63
- options = webidl.converters.CacheQueryOptions(options)
64
+ const prefix = 'Cache.matchAll'
65
+ if (request !== undefined) request = webidl.converters.RequestInfo(request, prefix, 'request')
66
+ options = webidl.converters.CacheQueryOptions(options, prefix, 'options')
64
67
 
65
68
  return this.#internalMatchAll(request, options)
66
69
  }
67
70
 
68
71
  async add (request) {
69
72
  webidl.brandCheck(this, Cache)
70
- webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.add' })
71
73
 
72
- request = webidl.converters.RequestInfo(request)
74
+ const prefix = 'Cache.add'
75
+ webidl.argumentLengthCheck(arguments, 1, prefix)
76
+
77
+ request = webidl.converters.RequestInfo(request, prefix, 'request')
73
78
 
74
79
  // 1.
75
80
  const requests = [request]
@@ -83,7 +88,9 @@ class Cache {
83
88
 
84
89
  async addAll (requests) {
85
90
  webidl.brandCheck(this, Cache)
86
- webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.addAll' })
91
+
92
+ const prefix = 'Cache.addAll'
93
+ webidl.argumentLengthCheck(arguments, 1, prefix)
87
94
 
88
95
  // 1.
89
96
  const responsePromises = []
@@ -95,7 +102,7 @@ class Cache {
95
102
  for (let request of requests) {
96
103
  if (request === undefined) {
97
104
  throw webidl.errors.conversionFailed({
98
- prefix: 'Cache.addAll',
105
+ prefix,
99
106
  argument: 'Argument 1',
100
107
  types: ['undefined is not allowed']
101
108
  })
@@ -113,7 +120,7 @@ class Cache {
113
120
  // 3.2
114
121
  if (!urlIsHttpHttpsScheme(r.url) || r.method !== 'GET') {
115
122
  throw webidl.errors.exception({
116
- header: 'Cache.addAll',
123
+ header: prefix,
117
124
  message: 'Expected http/s scheme when method is not GET.'
118
125
  })
119
126
  }
@@ -131,7 +138,7 @@ class Cache {
131
138
  // 5.2
132
139
  if (!urlIsHttpHttpsScheme(r.url)) {
133
140
  throw webidl.errors.exception({
134
- header: 'Cache.addAll',
141
+ header: prefix,
135
142
  message: 'Expected http/s scheme.'
136
143
  })
137
144
  }
@@ -251,10 +258,12 @@ class Cache {
251
258
 
252
259
  async put (request, response) {
253
260
  webidl.brandCheck(this, Cache)
254
- webidl.argumentLengthCheck(arguments, 2, { header: 'Cache.put' })
255
261
 
256
- request = webidl.converters.RequestInfo(request)
257
- response = webidl.converters.Response(response)
262
+ const prefix = 'Cache.put'
263
+ webidl.argumentLengthCheck(arguments, 2, prefix)
264
+
265
+ request = webidl.converters.RequestInfo(request, prefix, 'request')
266
+ response = webidl.converters.Response(response, prefix, 'response')
258
267
 
259
268
  // 1.
260
269
  let innerRequest = null
@@ -269,7 +278,7 @@ class Cache {
269
278
  // 4.
270
279
  if (!urlIsHttpHttpsScheme(innerRequest.url) || innerRequest.method !== 'GET') {
271
280
  throw webidl.errors.exception({
272
- header: 'Cache.put',
281
+ header: prefix,
273
282
  message: 'Expected an http/s scheme when method is not GET'
274
283
  })
275
284
  }
@@ -280,7 +289,7 @@ class Cache {
280
289
  // 6.
281
290
  if (innerResponse.status === 206) {
282
291
  throw webidl.errors.exception({
283
- header: 'Cache.put',
292
+ header: prefix,
284
293
  message: 'Got 206 status'
285
294
  })
286
295
  }
@@ -295,7 +304,7 @@ class Cache {
295
304
  // 7.2.1
296
305
  if (fieldValue === '*') {
297
306
  throw webidl.errors.exception({
298
- header: 'Cache.put',
307
+ header: prefix,
299
308
  message: 'Got * vary field value'
300
309
  })
301
310
  }
@@ -305,7 +314,7 @@ class Cache {
305
314
  // 8.
306
315
  if (innerResponse.body && (isDisturbed(innerResponse.body.stream) || innerResponse.body.stream.locked)) {
307
316
  throw webidl.errors.exception({
308
- header: 'Cache.put',
317
+ header: prefix,
309
318
  message: 'Response body is locked or disturbed'
310
319
  })
311
320
  }
@@ -380,10 +389,12 @@ class Cache {
380
389
 
381
390
  async delete (request, options = {}) {
382
391
  webidl.brandCheck(this, Cache)
383
- webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.delete' })
384
392
 
385
- request = webidl.converters.RequestInfo(request)
386
- options = webidl.converters.CacheQueryOptions(options)
393
+ const prefix = 'Cache.delete'
394
+ webidl.argumentLengthCheck(arguments, 1, prefix)
395
+
396
+ request = webidl.converters.RequestInfo(request, prefix, 'request')
397
+ options = webidl.converters.CacheQueryOptions(options, prefix, 'options')
387
398
 
388
399
  /**
389
400
  * @type {Request}
@@ -445,8 +456,10 @@ class Cache {
445
456
  async keys (request = undefined, options = {}) {
446
457
  webidl.brandCheck(this, Cache)
447
458
 
448
- if (request !== undefined) request = webidl.converters.RequestInfo(request)
449
- options = webidl.converters.CacheQueryOptions(options)
459
+ const prefix = 'Cache.keys'
460
+
461
+ if (request !== undefined) request = webidl.converters.RequestInfo(request, prefix, 'request')
462
+ options = webidl.converters.CacheQueryOptions(options, prefix, 'options')
450
463
 
451
464
  // 1.
452
465
  let r = null
@@ -810,17 +823,17 @@ const cacheQueryOptionConverters = [
810
823
  {
811
824
  key: 'ignoreSearch',
812
825
  converter: webidl.converters.boolean,
813
- defaultValue: false
826
+ defaultValue: () => false
814
827
  },
815
828
  {
816
829
  key: 'ignoreMethod',
817
830
  converter: webidl.converters.boolean,
818
- defaultValue: false
831
+ defaultValue: () => false
819
832
  },
820
833
  {
821
834
  key: 'ignoreVary',
822
835
  converter: webidl.converters.boolean,
823
- defaultValue: false
836
+ defaultValue: () => false
824
837
  }
825
838
  ]
826
839
 
@@ -20,7 +20,7 @@ class CacheStorage {
20
20
 
21
21
  async match (request, options = {}) {
22
22
  webidl.brandCheck(this, CacheStorage)
23
- webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.match' })
23
+ webidl.argumentLengthCheck(arguments, 1, 'CacheStorage.match')
24
24
 
25
25
  request = webidl.converters.RequestInfo(request)
26
26
  options = webidl.converters.MultiCacheQueryOptions(options)
@@ -57,9 +57,11 @@ class CacheStorage {
57
57
  */
58
58
  async has (cacheName) {
59
59
  webidl.brandCheck(this, CacheStorage)
60
- webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.has' })
61
60
 
62
- cacheName = webidl.converters.DOMString(cacheName)
61
+ const prefix = 'CacheStorage.has'
62
+ webidl.argumentLengthCheck(arguments, 1, prefix)
63
+
64
+ cacheName = webidl.converters.DOMString(cacheName, prefix, 'cacheName')
63
65
 
64
66
  // 2.1.1
65
67
  // 2.2
@@ -73,9 +75,11 @@ class CacheStorage {
73
75
  */
74
76
  async open (cacheName) {
75
77
  webidl.brandCheck(this, CacheStorage)
76
- webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.open' })
77
78
 
78
- cacheName = webidl.converters.DOMString(cacheName)
79
+ const prefix = 'CacheStorage.open'
80
+ webidl.argumentLengthCheck(arguments, 1, prefix)
81
+
82
+ cacheName = webidl.converters.DOMString(cacheName, prefix, 'cacheName')
79
83
 
80
84
  // 2.1
81
85
  if (this.#caches.has(cacheName)) {
@@ -105,9 +109,11 @@ class CacheStorage {
105
109
  */
106
110
  async delete (cacheName) {
107
111
  webidl.brandCheck(this, CacheStorage)
108
- webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.delete' })
109
112
 
110
- cacheName = webidl.converters.DOMString(cacheName)
113
+ const prefix = 'CacheStorage.delete'
114
+ webidl.argumentLengthCheck(arguments, 1, prefix)
115
+
116
+ cacheName = webidl.converters.DOMString(cacheName, prefix, 'cacheName')
111
117
 
112
118
  return this.#caches.delete(cacheName)
113
119
  }
@@ -24,7 +24,7 @@ const { Headers } = require('../fetch/headers')
24
24
  * @returns {Record<string, string>}
25
25
  */
26
26
  function getCookies (headers) {
27
- webidl.argumentLengthCheck(arguments, 1, { header: 'getCookies' })
27
+ webidl.argumentLengthCheck(arguments, 1, 'getCookies')
28
28
 
29
29
  webidl.brandCheck(headers, Headers, { strict: false })
30
30
 
@@ -51,11 +51,12 @@ function getCookies (headers) {
51
51
  * @returns {void}
52
52
  */
53
53
  function deleteCookie (headers, name, attributes) {
54
- webidl.argumentLengthCheck(arguments, 2, { header: 'deleteCookie' })
55
-
56
54
  webidl.brandCheck(headers, Headers, { strict: false })
57
55
 
58
- name = webidl.converters.DOMString(name)
56
+ const prefix = 'deleteCookie'
57
+ webidl.argumentLengthCheck(arguments, 2, prefix)
58
+
59
+ name = webidl.converters.DOMString(name, prefix, 'name')
59
60
  attributes = webidl.converters.DeleteCookieAttributes(attributes)
60
61
 
61
62
  // Matches behavior of
@@ -73,7 +74,7 @@ function deleteCookie (headers, name, attributes) {
73
74
  * @returns {Cookie[]}
74
75
  */
75
76
  function getSetCookies (headers) {
76
- webidl.argumentLengthCheck(arguments, 1, { header: 'getSetCookies' })
77
+ webidl.argumentLengthCheck(arguments, 1, 'getSetCookies')
77
78
 
78
79
  webidl.brandCheck(headers, Headers, { strict: false })
79
80
 
@@ -93,7 +94,7 @@ function getSetCookies (headers) {
93
94
  * @returns {void}
94
95
  */
95
96
  function setCookie (headers, cookie) {
96
- webidl.argumentLengthCheck(arguments, 2, { header: 'setCookie' })
97
+ webidl.argumentLengthCheck(arguments, 2, 'setCookie')
97
98
 
98
99
  webidl.brandCheck(headers, Headers, { strict: false })
99
100
 
@@ -110,12 +111,12 @@ webidl.converters.DeleteCookieAttributes = webidl.dictionaryConverter([
110
111
  {
111
112
  converter: webidl.nullableConverter(webidl.converters.DOMString),
112
113
  key: 'path',
113
- defaultValue: null
114
+ defaultValue: () => null
114
115
  },
115
116
  {
116
117
  converter: webidl.nullableConverter(webidl.converters.DOMString),
117
118
  key: 'domain',
118
- defaultValue: null
119
+ defaultValue: () => null
119
120
  }
120
121
  ])
121
122
 
@@ -137,32 +138,32 @@ webidl.converters.Cookie = webidl.dictionaryConverter([
137
138
  return new Date(value)
138
139
  }),
139
140
  key: 'expires',
140
- defaultValue: null
141
+ defaultValue: () => null
141
142
  },
142
143
  {
143
144
  converter: webidl.nullableConverter(webidl.converters['long long']),
144
145
  key: 'maxAge',
145
- defaultValue: null
146
+ defaultValue: () => null
146
147
  },
147
148
  {
148
149
  converter: webidl.nullableConverter(webidl.converters.DOMString),
149
150
  key: 'domain',
150
- defaultValue: null
151
+ defaultValue: () => null
151
152
  },
152
153
  {
153
154
  converter: webidl.nullableConverter(webidl.converters.DOMString),
154
155
  key: 'path',
155
- defaultValue: null
156
+ defaultValue: () => null
156
157
  },
157
158
  {
158
159
  converter: webidl.nullableConverter(webidl.converters.boolean),
159
160
  key: 'secure',
160
- defaultValue: null
161
+ defaultValue: () => null
161
162
  },
162
163
  {
163
164
  converter: webidl.nullableConverter(webidl.converters.boolean),
164
165
  key: 'httpOnly',
165
- defaultValue: null
166
+ defaultValue: () => null
166
167
  },
167
168
  {
168
169
  converter: webidl.converters.USVString,
@@ -172,7 +173,7 @@ webidl.converters.Cookie = webidl.dictionaryConverter([
172
173
  {
173
174
  converter: webidl.sequenceConverter(webidl.converters.DOMString),
174
175
  key: 'unparsed',
175
- defaultValue: []
176
+ defaultValue: () => new Array(0)
176
177
  }
177
178
  ])
178
179
 
@@ -6,7 +6,7 @@ const { makeRequest } = require('../fetch/request')
6
6
  const { webidl } = require('../fetch/webidl')
7
7
  const { EventSourceStream } = require('./eventsource-stream')
8
8
  const { parseMIMEType } = require('../fetch/data-url')
9
- const { MessageEvent } = require('../websocket/events')
9
+ const { createFastMessageEvent } = require('../websocket/events')
10
10
  const { isNetworkError } = require('../fetch/response')
11
11
  const { delay } = require('./util')
12
12
  const { kEnumerableProperty } = require('../../core/util')
@@ -105,7 +105,8 @@ class EventSource extends EventTarget {
105
105
  // 1. Let ev be a new EventSource object.
106
106
  super()
107
107
 
108
- webidl.argumentLengthCheck(arguments, 1, { header: 'EventSource constructor' })
108
+ const prefix = 'EventSource constructor'
109
+ webidl.argumentLengthCheck(arguments, 1, prefix)
109
110
 
110
111
  if (!experimentalWarned) {
111
112
  experimentalWarned = true
@@ -114,8 +115,8 @@ class EventSource extends EventTarget {
114
115
  })
115
116
  }
116
117
 
117
- url = webidl.converters.USVString(url)
118
- eventSourceInitDict = webidl.converters.EventSourceInitDict(eventSourceInitDict)
118
+ url = webidl.converters.USVString(url, prefix, 'url')
119
+ eventSourceInitDict = webidl.converters.EventSourceInitDict(eventSourceInitDict, prefix, 'eventSourceInitDict')
119
120
 
120
121
  this.#dispatcher = eventSourceInitDict.dispatcher
121
122
  this.#state = {
@@ -290,7 +291,7 @@ class EventSource extends EventTarget {
290
291
  const eventSourceStream = new EventSourceStream({
291
292
  eventSourceSettings: this.#state,
292
293
  push: (event) => {
293
- this.dispatchEvent(new MessageEvent(
294
+ this.dispatchEvent(createFastMessageEvent(
294
295
  event.type,
295
296
  event.options
296
297
  ))
@@ -463,7 +464,7 @@ webidl.converters.EventSourceInitDict = webidl.dictionaryConverter([
463
464
  {
464
465
  key: 'withCredentials',
465
466
  converter: webidl.converters.boolean,
466
- defaultValue: false
467
+ defaultValue: () => false
467
468
  },
468
469
  {
469
470
  key: 'dispatcher', // undici only
@@ -33,9 +33,10 @@ class CompatFinalizer {
33
33
  }
34
34
 
35
35
  module.exports = function () {
36
- // FIXME: remove workaround when the Node bug is fixed
36
+ // FIXME: remove workaround when the Node bug is backported to v18
37
37
  // https://github.com/nodejs/node/issues/49344#issuecomment-1741776308
38
- if (process.env.NODE_V8_COVERAGE) {
38
+ if (process.env.NODE_V8_COVERAGE && process.version.startsWith('v18')) {
39
+ process._rawDebug('Using compatibility WeakRef and FinalizationRegistry')
39
40
  return {
40
41
  WeakRef: CompatWeakRef,
41
42
  FinalizationRegistry: CompatFinalizer
@@ -28,7 +28,8 @@ class FormData {
28
28
  append (name, value, filename = undefined) {
29
29
  webidl.brandCheck(this, FormData)
30
30
 
31
- webidl.argumentLengthCheck(arguments, 2, { header: 'FormData.append' })
31
+ const prefix = 'FormData.append'
32
+ webidl.argumentLengthCheck(arguments, 2, prefix)
32
33
 
33
34
  if (arguments.length === 3 && !isBlobLike(value)) {
34
35
  throw new TypeError(
@@ -38,12 +39,12 @@ class FormData {
38
39
 
39
40
  // 1. Let value be value if given; otherwise blobValue.
40
41
 
41
- name = webidl.converters.USVString(name)
42
+ name = webidl.converters.USVString(name, prefix, 'name')
42
43
  value = isBlobLike(value)
43
- ? webidl.converters.Blob(value, { strict: false })
44
- : webidl.converters.USVString(value)
44
+ ? webidl.converters.Blob(value, prefix, 'value', { strict: false })
45
+ : webidl.converters.USVString(value, prefix, 'value')
45
46
  filename = arguments.length === 3
46
- ? webidl.converters.USVString(filename)
47
+ ? webidl.converters.USVString(filename, prefix, 'filename')
47
48
  : undefined
48
49
 
49
50
  // 2. Let entry be the result of creating an entry with
@@ -57,9 +58,10 @@ class FormData {
57
58
  delete (name) {
58
59
  webidl.brandCheck(this, FormData)
59
60
 
60
- webidl.argumentLengthCheck(arguments, 1, { header: 'FormData.delete' })
61
+ const prefix = 'FormData.delete'
62
+ webidl.argumentLengthCheck(arguments, 1, prefix)
61
63
 
62
- name = webidl.converters.USVString(name)
64
+ name = webidl.converters.USVString(name, prefix, 'name')
63
65
 
64
66
  // The delete(name) method steps are to remove all entries whose name
65
67
  // is name from this’s entry list.
@@ -69,9 +71,10 @@ class FormData {
69
71
  get (name) {
70
72
  webidl.brandCheck(this, FormData)
71
73
 
72
- webidl.argumentLengthCheck(arguments, 1, { header: 'FormData.get' })
74
+ const prefix = 'FormData.get'
75
+ webidl.argumentLengthCheck(arguments, 1, prefix)
73
76
 
74
- name = webidl.converters.USVString(name)
77
+ name = webidl.converters.USVString(name, prefix, 'name')
75
78
 
76
79
  // 1. If there is no entry whose name is name in this’s entry list,
77
80
  // then return null.
@@ -88,9 +91,10 @@ class FormData {
88
91
  getAll (name) {
89
92
  webidl.brandCheck(this, FormData)
90
93
 
91
- webidl.argumentLengthCheck(arguments, 1, { header: 'FormData.getAll' })
94
+ const prefix = 'FormData.getAll'
95
+ webidl.argumentLengthCheck(arguments, 1, prefix)
92
96
 
93
- name = webidl.converters.USVString(name)
97
+ name = webidl.converters.USVString(name, prefix, 'name')
94
98
 
95
99
  // 1. If there is no entry whose name is name in this’s entry list,
96
100
  // then return the empty list.
@@ -104,9 +108,10 @@ class FormData {
104
108
  has (name) {
105
109
  webidl.brandCheck(this, FormData)
106
110
 
107
- webidl.argumentLengthCheck(arguments, 1, { header: 'FormData.has' })
111
+ const prefix = 'FormData.has'
112
+ webidl.argumentLengthCheck(arguments, 1, prefix)
108
113
 
109
- name = webidl.converters.USVString(name)
114
+ name = webidl.converters.USVString(name, prefix, 'name')
110
115
 
111
116
  // The has(name) method steps are to return true if there is an entry
112
117
  // whose name is name in this’s entry list; otherwise false.
@@ -116,7 +121,8 @@ class FormData {
116
121
  set (name, value, filename = undefined) {
117
122
  webidl.brandCheck(this, FormData)
118
123
 
119
- webidl.argumentLengthCheck(arguments, 2, { header: 'FormData.set' })
124
+ const prefix = 'FormData.set'
125
+ webidl.argumentLengthCheck(arguments, 2, prefix)
120
126
 
121
127
  if (arguments.length === 3 && !isBlobLike(value)) {
122
128
  throw new TypeError(
@@ -129,12 +135,12 @@ class FormData {
129
135
 
130
136
  // 1. Let value be value if given; otherwise blobValue.
131
137
 
132
- name = webidl.converters.USVString(name)
138
+ name = webidl.converters.USVString(name, prefix, 'name')
133
139
  value = isBlobLike(value)
134
- ? webidl.converters.Blob(value, { strict: false })
135
- : webidl.converters.USVString(value)
140
+ ? webidl.converters.Blob(value, prefix, 'name', { strict: false })
141
+ : webidl.converters.USVString(value, prefix, 'name')
136
142
  filename = arguments.length === 3
137
- ? webidl.converters.USVString(filename)
143
+ ? webidl.converters.USVString(filename, prefix, 'name')
138
144
  : undefined
139
145
 
140
146
  // 2. Let entry be the result of creating an entry with name, value, and