@@ -390,26 +390,29 @@ promise_test(async testCase => {
390
390
} , 'cookieStore.set with whitespace only name and value' ) ;
391
391
392
392
promise_test ( async testCase => {
393
- testCase . add_cleanup ( async ( ) => {
394
- await cookieStore . delete ( 'a b' ) ;
395
- } ) ;
396
- await cookieStore . set ( 'a b' , 'x y' ) ;
397
- const cookie = await cookieStore . get ( 'a b' ) ;
398
- assert_equals ( cookie . value , "x y" ) ;
399
-
400
- await promise_rejects_js ( testCase , TypeError , cookieStore . set (
401
- { name : 'a ' ,
402
- value : 'x' } ) ) ;
403
-
404
- await promise_rejects_js ( testCase , TypeError , cookieStore . set (
405
- { name : ' a' ,
406
- value : 'x' } ) ) ;
407
-
408
- await promise_rejects_js ( testCase , TypeError , cookieStore . set (
409
- { name : 'a' ,
410
- value : 'x ' } ) ) ;
393
+ const tests = [
394
+ { set : [ 'a b' , 'x y' ] , get : [ 'a b' , 'x y' ] } ,
395
+ { set : [ 'a ' , 'x' ] , get : [ 'a' , 'x' ] } ,
396
+ { set : [ 'a\t' , 'x' ] , get : [ 'a' , 'x' ] } ,
397
+ { set : [ ' a' , 'x' ] , get : [ 'a' , 'x' ] } ,
398
+ { set : [ ' \t a' , 'x' ] , get : [ 'a' , 'x' ] } ,
399
+ { set : [ ' \t a \t\t' , 'x' ] , get : [ 'a' , 'x' ] } ,
400
+ { set : [ 'a' , 'x ' ] , get : [ 'a' , 'x' ] } ,
401
+ { set : [ 'a' , 'x\t' ] , get : [ 'a' , 'x' ] } ,
402
+ { set : [ 'a' , ' x' ] , get : [ 'a' , 'x' ] } ,
403
+ { set : [ 'a' , ' \t x' ] , get : [ 'a' , 'x' ] } ,
404
+ { set : [ 'a' , ' \t x \t\t' ] , get : [ 'a' , 'x' ] } ,
405
+ ] ;
406
+
407
+ for ( const t of tests ) {
408
+ await cookieStore . set ( t . set [ 0 ] , t . set [ 1 ] ) ;
409
+ let cookie = await cookieStore . get ( t . get [ 0 ] ) ;
410
+ assert_equals ( cookie . value , t . get [ 1 ] ) ;
411
+
412
+ await cookieStore . delete ( t . get [ 0 ] ) ;
413
+
414
+ cookie = await cookieStore . get ( t . get [ 0 ] ) ;
415
+ assert_equals ( cookie , null ) ;
416
+ }
411
417
412
- await promise_rejects_js ( testCase , TypeError , cookieStore . set (
413
- { name : 'a' ,
414
- value : 'x ' } ) ) ;
415
418
} , 'cookieStore.set with whitespace at begining or end' ) ;
0 commit comments