File tree 2 files changed +20
-2
lines changed
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 {
150
150
}
151
151
152
152
throwIfAborted ( ) {
153
- if ( this . aborted ) {
154
- throw this . reason ;
153
+ validateThisAbortSignal ( this ) ;
154
+ if ( this [ kAborted ] ) {
155
+ throw this [ kReason ] ;
155
156
}
156
157
}
157
158
Original file line number Diff line number Diff line change @@ -254,3 +254,20 @@ const { setTimeout: sleep } = require('timers/promises');
254
254
const ac = new AbortController ( ) ;
255
255
ac . signal . throwIfAborted ( ) ;
256
256
}
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