Changeset 238391 in webkit for trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
- Timestamp:
- Nov 19, 2018, 11:09:53 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r237714 r238391 784 784 { 785 785 VM& vm = exec->vm(); 786 auto throwScope = DECLARE_THROW_SCOPE(vm); 787 788 auto* globalObject = exec->lexicalGlobalObject(); 789 790 auto* promise = JSPromiseDeferred::create(exec, globalObject); 791 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 792 786 793 auto catchScope = DECLARE_CATCH_SCOPE(vm); 787 788 auto* globalObject = exec->lexicalGlobalObject(); 789 790 auto* promise = JSPromiseDeferred::create(exec, globalObject); 791 CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue()); 794 auto reject = [&] (JSValue rejectionReason) { 795 catchScope.clearException(); 796 promise->reject(exec, rejectionReason); 797 catchScope.clearException(); 798 return JSValue::encode(promise->promise()); 799 }; 792 800 793 801 auto sourceOrigin = exec->callerSourceOrigin(); 794 802 RELEASE_ASSERT(exec->argumentCount() == 1); 795 803 auto* specifier = exec->uncheckedArgument(0).toString(exec); 796 if (Exception* exception = catchScope.exception()) { 797 catchScope.clearException(); 798 promise->reject(exec, exception->value()); 799 CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue()); 800 return JSValue::encode(promise->promise()); 801 } 804 if (Exception* exception = catchScope.exception()) 805 return reject(exception->value()); 802 806 803 807 // We always specify parameters as undefined. Once dynamic import() starts accepting fetching parameters, … … 805 809 JSValue parameters = jsUndefined(); 806 810 auto* internalPromise = globalObject->moduleLoader()->importModule(exec, specifier, parameters, sourceOrigin); 807 if (Exception* exception = catchScope.exception()) { 808 catchScope.clearException(); 809 promise->reject(exec, exception->value()); 810 CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue()); 811 return JSValue::encode(promise->promise()); 812 } 811 if (Exception* exception = catchScope.exception()) 812 return reject(exception->value()); 813 813 promise->resolve(exec, internalPromise); 814 CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue()); 815 814 815 catchScope.clearException(); 816 816 return JSValue::encode(promise->promise()); 817 817 }
Note:
See TracChangeset
for help on using the changeset viewer.