@@ -36,7 +36,7 @@ function pushNewPromiseReaction(thenable, existingReactions, promiseOrCapability
36
36
@promiseOrCapability : promiseOrCapability ,
37
37
@onFulfilled : onFulfilled ,
38
38
@onRejected : onRejected ,
39
- @context : context ,
39
+ @context : @ getAsyncContextFrame ? @ getAsyncContextFrame ( context ) : context ,
40
40
// This is 4x the number of out of line reactions (promise, fulfill callback, reject callback, context).
41
41
@outOfLineReactionCounts : 0 ,
42
42
} ;
@@ -46,7 +46,7 @@ function pushNewPromiseReaction(thenable, existingReactions, promiseOrCapability
46
46
@putByValDirect ( existingReactions , outOfLineReactionCounts ++ , promiseOrCapability ) ;
47
47
@putByValDirect ( existingReactions , outOfLineReactionCounts ++ , onFulfilled ) ;
48
48
@putByValDirect ( existingReactions , outOfLineReactionCounts ++ , onRejected ) ;
49
- @putByValDirect ( existingReactions , outOfLineReactionCounts ++ , context ) ;
49
+ @putByValDirect ( existingReactions , outOfLineReactionCounts ++ , @ getAsyncContextFrame ? @ getAsyncContextFrame ( context ) : context ) ;
50
50
existingReactions . @outOfLineReactionCounts = outOfLineReactionCounts ;
51
51
}
52
52
}
@@ -318,6 +318,10 @@ function createResolvingFunctions(promise)
318
318
function promiseReactionJobWithoutPromise ( handler , argument , context )
319
319
{
320
320
"use strict" ;
321
+ var pushed ;
322
+ if ( @pushAsyncContextFrame ) {
323
+ pushed = @pushAsyncContextFrame ( context ) ;
324
+ }
321
325
322
326
try {
323
327
if ( context )
@@ -326,6 +330,10 @@ function promiseReactionJobWithoutPromise(handler, argument, context)
326
330
handler ( argument ) ;
327
331
} catch {
328
332
// This is user-uncatchable promise. We just ignore the error here.
333
+ } finally {
334
+ if ( @popAsyncContextFrame ) {
335
+ @popAsyncContextFrame ( pushed ) ;
336
+ }
329
337
}
330
338
}
331
339
@@ -457,6 +465,11 @@ function promiseReactionJob(promiseOrCapability, handler, argument, contextOrSta
457
465
return ;
458
466
}
459
467
468
+ var pushed ;
469
+ if ( @pushAsyncContextFrame ) {
470
+ pushed = @pushAsyncContextFrame ( contextOrState ) ;
471
+ }
472
+
460
473
// Case (1), or (2).
461
474
try {
462
475
var result = ( contextOrState ) ? handler ( argument , contextOrState ) : handler ( argument ) ;
@@ -466,14 +479,23 @@ function promiseReactionJob(promiseOrCapability, handler, argument, contextOrSta
466
479
return ;
467
480
}
468
481
promiseOrCapability . @reject . @call ( @undefined , error ) ;
482
+ if ( @popAsyncContextFrame ) {
483
+ @popAsyncContextFrame ( pushed ) ;
484
+ }
469
485
return ;
470
486
}
471
487
472
488
if ( @isPromise ( promiseOrCapability ) ) {
473
489
@resolvePromise ( promiseOrCapability , result ) ;
490
+ if ( @popAsyncContextFrame ) {
491
+ @popAsyncContextFrame ( pushed ) ;
492
+ }
474
493
return ;
475
494
}
476
495
promiseOrCapability . @resolve . @call ( @undefined , result ) ;
496
+ if ( @popAsyncContextFrame ) {
497
+ @popAsyncContextFrame ( pushed ) ;
498
+ }
477
499
}
478
500
479
501
@linkTimeConstant
0 commit comments