@@ -1205,7 +1205,7 @@ exercise.forEach(function(exerciseMode) {
1205
1205
assert . deepEqual ( controller . signal , request . signal ) ;
1206
1206
} )
1207
1207
1208
- test ( 'initially aborted signal' , function ( ) {
1208
+ test ( 'initially aborted signal without reason ' , function ( ) {
1209
1209
var controller = new AbortController ( )
1210
1210
controller . abort ( )
1211
1211
@@ -1221,8 +1221,24 @@ exercise.forEach(function(exerciseMode) {
1221
1221
}
1222
1222
)
1223
1223
} )
1224
+
1225
+ test ( 'initially aborted signal with reason' , function ( ) {
1226
+ var controller = new AbortController ( )
1227
+ controller . abort ( 'Something bad happened' )
1224
1228
1225
- test ( 'initially aborted signal within Request' , function ( ) {
1229
+ return fetch ( '/request' , {
1230
+ signal : controller . signal
1231
+ } ) . then (
1232
+ function ( ) {
1233
+ assert . ok ( false )
1234
+ } ,
1235
+ function ( error ) {
1236
+ assert . equal ( error , 'Something bad happened' )
1237
+ }
1238
+ )
1239
+ } )
1240
+
1241
+ test ( 'initially aborted signal without reason within Request' , function ( ) {
1226
1242
var controller = new AbortController ( )
1227
1243
controller . abort ( )
1228
1244
@@ -1238,7 +1254,23 @@ exercise.forEach(function(exerciseMode) {
1238
1254
)
1239
1255
} )
1240
1256
1241
- test ( 'mid-request' , function ( ) {
1257
+ test ( 'initially aborted signal with reason within Request' , function ( ) {
1258
+ var controller = new AbortController ( )
1259
+ controller . abort ( 'Something bad happened' )
1260
+
1261
+ var request = new Request ( '/request' , { signal : controller . signal } )
1262
+
1263
+ return fetch ( request ) . then (
1264
+ function ( ) {
1265
+ assert . ok ( false )
1266
+ } ,
1267
+ function ( error ) {
1268
+ assert . equal ( error , 'Something bad happened' )
1269
+ }
1270
+ )
1271
+ } )
1272
+
1273
+ test ( 'mid-request without reason' , function ( ) {
1242
1274
var controller = new AbortController ( )
1243
1275
1244
1276
setTimeout ( function ( ) {
@@ -1256,8 +1288,27 @@ exercise.forEach(function(exerciseMode) {
1256
1288
}
1257
1289
)
1258
1290
} )
1291
+
1292
+ test ( 'mid-request with reason' , function ( ) {
1293
+ var controller = new AbortController ( )
1294
+
1295
+ setTimeout ( function ( ) {
1296
+ controller . abort ( 'Something bad happened' )
1297
+ } , 30 )
1298
+
1299
+ return fetch ( '/slow?_=' + new Date ( ) . getTime ( ) , {
1300
+ signal : controller . signal
1301
+ } ) . then (
1302
+ function ( ) {
1303
+ assert . ok ( false )
1304
+ } ,
1305
+ function ( error ) {
1306
+ assert . equal ( error , 'Something bad happened' )
1307
+ }
1308
+ )
1309
+ } )
1259
1310
1260
- test ( 'mid-request within Request' , function ( ) {
1311
+ test ( 'mid-request without reason within Request' , function ( ) {
1261
1312
var controller = new AbortController ( )
1262
1313
var request = new Request ( '/slow?_=' + new Date ( ) . getTime ( ) , { signal : controller . signal } )
1263
1314
@@ -1275,7 +1326,25 @@ exercise.forEach(function(exerciseMode) {
1275
1326
)
1276
1327
} )
1277
1328
1278
- test ( 'abort multiple with same signal' , function ( ) {
1329
+ test ( 'mid-request with reason within Request' , function ( ) {
1330
+ var controller = new AbortController ( )
1331
+ var request = new Request ( '/slow?_=' + new Date ( ) . getTime ( ) , { signal : controller . signal } )
1332
+
1333
+ setTimeout ( function ( ) {
1334
+ controller . abort ( 'Something bad happened' )
1335
+ } , 30 )
1336
+
1337
+ return fetch ( request ) . then (
1338
+ function ( ) {
1339
+ assert . ok ( false )
1340
+ } ,
1341
+ function ( error ) {
1342
+ assert . equal ( error , 'Something bad happened' )
1343
+ }
1344
+ )
1345
+ } )
1346
+
1347
+ test ( 'abort multiple without reason with same signal' , function ( ) {
1279
1348
var controller = new AbortController ( )
1280
1349
1281
1350
setTimeout ( function ( ) {
@@ -1305,6 +1374,37 @@ exercise.forEach(function(exerciseMode) {
1305
1374
)
1306
1375
] )
1307
1376
} )
1377
+
1378
+ test ( 'abort multiple with reason with same signal' , function ( ) {
1379
+ var controller = new AbortController ( )
1380
+
1381
+ setTimeout ( function ( ) {
1382
+ controller . abort ( 'Something bad happened' )
1383
+ } , 30 )
1384
+
1385
+ return Promise . all ( [
1386
+ fetch ( '/slow?_=' + new Date ( ) . getTime ( ) , {
1387
+ signal : controller . signal
1388
+ } ) . then (
1389
+ function ( ) {
1390
+ assert . ok ( false )
1391
+ } ,
1392
+ function ( error ) {
1393
+ assert . equal ( error , 'Something bad happened' )
1394
+ }
1395
+ ) ,
1396
+ fetch ( '/slow?_=' + new Date ( ) . getTime ( ) , {
1397
+ signal : controller . signal
1398
+ } ) . then (
1399
+ function ( ) {
1400
+ assert . ok ( false )
1401
+ } ,
1402
+ function ( error ) {
1403
+ assert . equal ( error , 'Something bad happened' )
1404
+ }
1405
+ )
1406
+ ] )
1407
+ } )
1308
1408
} )
1309
1409
1310
1410
suite ( 'response' , function ( ) {
0 commit comments