File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -150,8 +150,9 @@ class AbortSignal extends EventTarget {
150150 }
151151
152152 throwIfAborted ( ) {
153- if ( this . aborted ) {
154- throw this . reason ;
153+ validateThisAbortSignal ( this ) ;
154+ if ( this [ kAborted ] ) {
155+ throw this [ kReason ] ;
155156 }
156157 }
157158
Original file line number Diff line number Diff line change @@ -254,3 +254,20 @@ const { setTimeout: sleep } = require('timers/promises');
254254 const ac = new AbortController ( ) ;
255255 ac . signal . throwIfAborted ( ) ;
256256}
257+
258+ {
259+ const originalDesc = Reflect . getOwnPropertyDescriptor ( AbortSignal . prototype , 'aborted' ) ;
260+ const actualReason = new Error ( ) ;
261+ Reflect . defineProperty ( AbortSignal . prototype , 'aborted' , { value : false } ) ;
262+ throws ( ( ) => AbortSignal . abort ( actualReason ) . throwIfAborted ( ) , actualReason ) ;
263+ Reflect . defineProperty ( AbortSignal . prototype , 'aborted' , originalDesc ) ;
264+ }
265+
266+ {
267+ const originalDesc = Reflect . getOwnPropertyDescriptor ( AbortSignal . prototype , 'reason' ) ;
268+ const actualReason = new Error ( ) ;
269+ const fakeExcuse = new Error ( ) ;
270+ Reflect . defineProperty ( AbortSignal . prototype , 'reason' , { value : fakeExcuse } ) ;
271+ throws ( ( ) => AbortSignal . abort ( actualReason ) . throwIfAborted ( ) , actualReason ) ;
272+ Reflect . defineProperty ( AbortSignal . prototype , 'reason' , originalDesc ) ;
273+ }
You can’t perform that action at this time.
0 commit comments