@@ -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
0 commit comments