@@ -1009,8 +1009,8 @@ namespace Js
10091009 JavascriptGenerator* gen = asyncSpawnExecutorFunction->GetGenerator ();
10101010 JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction* nextFunction = library->CreatePromiseAsyncSpawnStepArgumentExecutorFunction (EntryJavascriptPromiseAsyncSpawnStepNextExecutorFunction, gen, varCallArgs);
10111011
1012- Assert (JavascriptFunction::Is (resolve) && JavascriptFunction::Is (reject));
1013- AsyncSpawnStep (nextFunction, gen, JavascriptFunction::FromVar ( resolve), JavascriptFunction::FromVar ( reject) );
1012+ Assert (JavascriptConversion::IsCallable (resolve) && JavascriptConversion::IsCallable (reject));
1013+ AsyncSpawnStep (nextFunction, gen, resolve, reject);
10141014
10151015 return undefinedVar;
10161016 }
@@ -1054,8 +1054,8 @@ namespace Js
10541054 JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction* asyncSpawnStepExecutorFunction = JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction::FromVar (function);
10551055 JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction* functionArg;
10561056 JavascriptGenerator* gen = asyncSpawnStepExecutorFunction->GetGenerator ();
1057- JavascriptFunction* reject = asyncSpawnStepExecutorFunction->GetReject ();
1058- JavascriptFunction* resolve = asyncSpawnStepExecutorFunction->GetResolve ();
1057+ Var reject = asyncSpawnStepExecutorFunction->GetReject ();
1058+ Var resolve = asyncSpawnStepExecutorFunction->GetResolve ();
10591059
10601060 if (asyncSpawnStepExecutorFunction->GetIsReject ())
10611061 {
@@ -1071,9 +1071,9 @@ namespace Js
10711071 return undefinedVar;
10721072 }
10731073
1074- void JavascriptPromise::AsyncSpawnStep (JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction* nextFunction, JavascriptGenerator* gen, JavascriptFunction* resolve, JavascriptFunction* reject)
1074+ void JavascriptPromise::AsyncSpawnStep (JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction* nextFunction, JavascriptGenerator* gen, Var resolve, Var reject)
10751075 {
1076- ScriptContext* scriptContext = resolve ->GetScriptContext ();
1076+ ScriptContext* scriptContext = gen ->GetScriptContext ();
10771077 JavascriptLibrary* library = scriptContext->GetLibrary ();
10781078 Var undefinedVar = library->GetUndefined ();
10791079
@@ -1105,7 +1105,12 @@ namespace Js
11051105 {
11061106 // finished with success, resolve the promise
11071107 value = JavascriptOperators::GetProperty (next, PropertyIds::value, scriptContext);
1108- CALL_FUNCTION (scriptContext->GetThreadContext (), resolve, CallInfo (CallFlags_Value, 2 ), undefinedVar, value);
1108+ if (!JavascriptConversion::IsCallable (resolve))
1109+ {
1110+ JavascriptError::ThrowTypeError (scriptContext, JSERR_NeedFunction);
1111+ }
1112+ CALL_FUNCTION (scriptContext->GetThreadContext (), RecyclableObject::FromVar (resolve), CallInfo (CallFlags_Value, 2 ), undefinedVar, value);
1113+
11091114 return ;
11101115 }
11111116
@@ -1118,11 +1123,19 @@ namespace Js
11181123 Var promiseVar = CALL_FUNCTION (scriptContext->GetThreadContext (), promiseResolve, CallInfo (CallFlags_Value, 2 ), library->GetPromiseConstructor (), value);
11191124 JavascriptPromise* promise = FromVar (promiseVar);
11201125
1121- JavascriptFunction* promiseThen = JavascriptFunction::FromVar (JavascriptOperators::GetProperty (promise, PropertyIds::then, scriptContext));
1122- CALL_FUNCTION (scriptContext->GetThreadContext (), promiseThen, CallInfo (CallFlags_Value, 2 ), promise, successFunction);
1126+ Var promiseThen = JavascriptOperators::GetProperty (promise, PropertyIds::then, scriptContext);
1127+ if (!JavascriptConversion::IsCallable (promiseThen))
1128+ {
1129+ JavascriptError::ThrowTypeError (scriptContext, JSERR_NeedFunction);
1130+ }
1131+ CALL_FUNCTION (scriptContext->GetThreadContext (), RecyclableObject::FromVar (promiseThen), CallInfo (CallFlags_Value, 2 ), promise, successFunction);
11231132
1124- JavascriptFunction* promiseCatch = JavascriptFunction::FromVar (JavascriptOperators::GetProperty (promise, PropertyIds::catch_, scriptContext));
1125- CALL_FUNCTION (scriptContext->GetThreadContext (), promiseCatch, CallInfo (CallFlags_Value, 2 ), promise, failFunction);
1133+ Var promiseCatch = JavascriptOperators::GetProperty (promise, PropertyIds::catch_, scriptContext);
1134+ if (!JavascriptConversion::IsCallable (promiseCatch))
1135+ {
1136+ JavascriptError::ThrowTypeError (scriptContext, JSERR_NeedFunction);
1137+ }
1138+ CALL_FUNCTION (scriptContext->GetThreadContext (), RecyclableObject::FromVar (promiseCatch), CallInfo (CallFlags_Value, 2 ), promise, failFunction);
11261139 }
11271140
11281141#if ENABLE_TTD
@@ -1435,7 +1448,7 @@ namespace Js
14351448 }
14361449#endif
14371450
1438- JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction::JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction (DynamicType* type, FunctionInfo* functionInfo, JavascriptGenerator* generator, Var argument, JavascriptFunction* resolve, JavascriptFunction* reject, bool isReject)
1451+ JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction::JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction (DynamicType* type, FunctionInfo* functionInfo, JavascriptGenerator* generator, Var argument, Var resolve, Var reject, bool isReject)
14391452 : RuntimeFunction(type, functionInfo), generator(generator), argument(argument), resolve(resolve), reject(reject), isReject(isReject)
14401453 { }
14411454
@@ -1464,12 +1477,12 @@ namespace Js
14641477 return this ->generator ;
14651478 }
14661479
1467- JavascriptFunction* JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction::GetResolve ()
1480+ Var JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction::GetResolve ()
14681481 {
14691482 return this ->resolve ;
14701483 }
14711484
1472- JavascriptFunction* JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction::GetReject ()
1485+ Var JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction::GetReject ()
14731486 {
14741487 return this ->reject ;
14751488 }
0 commit comments