File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -835,6 +835,10 @@ webidl.converters.RequestInfo = function (V) {
835835 return webidl . converters . USVString ( V )
836836}
837837
838+ webidl . converters . AbortSignal = webidl . interfaceConverter (
839+ AbortSignal
840+ )
841+
838842// https://fetch.spec.whatwg.org/#requestinit
839843webidl . converters . RequestInit = webidl . dictionaryConverter ( [
840844 {
@@ -909,7 +913,12 @@ webidl.converters.RequestInit = webidl.dictionaryConverter([
909913 } ,
910914 {
911915 key : 'signal' ,
912- converter : webidl . converters . any
916+ converter : webidl . nullableConverter (
917+ ( signal ) => webidl . converters . AbortSignal (
918+ signal ,
919+ { strict : false }
920+ )
921+ )
913922 } ,
914923 {
915924 key : 'window' ,
Original file line number Diff line number Diff line change 55const { test } = require ( 'tap' )
66const {
77 Request,
8- Headers
8+ Headers,
9+ fetch
910} = require ( '../../' )
1011const { kState } = require ( '../../lib/fetch/symbols.js' )
1112const hasSignalReason = ! ! ~ process . version . localeCompare ( 'v16.14.0' , undefined , { numeric : true } )
@@ -421,3 +422,16 @@ test('invalid RequestInit values', (t) => {
421422
422423 t . end ( )
423424} )
425+
426+ test ( 'RequestInit.signal option' , async ( t ) => {
427+ t . throws ( ( ) => {
428+ // eslint-disable-next-line no-new
429+ new Request ( 'http://asd' , {
430+ signal : true
431+ } )
432+ } , TypeError )
433+
434+ await t . rejects ( fetch ( 'http://asd' , {
435+ signal : false
436+ } ) , TypeError )
437+ } )
You can’t perform that action at this time.
0 commit comments