Chromium Code Reviews| Index: src/js/promise.js |
| diff --git a/src/js/promise.js b/src/js/promise.js |
| index 793d60fb0a7fa29f5f828da7dee849d5d42dabb1..44d748a54d235ddac84931b7c0386778322d724d 100644 |
| --- a/src/js/promise.js |
| +++ b/src/js/promise.js |
| @@ -169,9 +169,13 @@ function PromiseHandle(value, handler, deferred) { |
| try { |
| if (debug_is_active) %DebugPushPromise(deferred.promise); |
| var result = handler(value); |
| - deferred.resolve(result); |
| + if (deferred.resolve) { deferred.resolve(result); } |
|
adamk
2016/10/05 22:12:00
And an explicit IS_UNDEFINED() check for these, ju
gsathya
2016/10/05 22:47:40
Done.
|
| + else { ResolvePromise(deferred.promise, result); } |
|
adamk
2016/10/05 22:12:00
Please reformat this and the below into the usual
gsathya
2016/10/05 22:47:40
Done.
|
| } %catch (exception) { // Natives syntax to mark this catch block. |
| - try { deferred.reject(exception); } catch (e) { } |
| + try { |
| + if (deferred.reject) { deferred.reject(exception); } |
| + else { RejectPromise(deferred.promise, exception, false); } |
|
adamk
2016/10/05 22:12:00
This needs a comment for why false is the third ar
gsathya
2016/10/05 22:47:40
Done.
|
| + } catch (e) { } |
| } finally { |
| if (debug_is_active) %DebugPopPromise(); |
| } |
| @@ -452,9 +456,18 @@ function PromiseThen(onResolve, onReject) { |
| } |
| var constructor = SpeciesConstructor(this, GlobalPromise); |
| - // Pass false for debugEvent so .then chaining does not trigger |
| - // redundant ExceptionEvents. |
| - var resultCapability = NewPromiseCapability(constructor, false); |
| + var resultCapability; |
| + if (constructor === GlobalPromise) { |
| + resultCapability = { |
|
adamk
2016/10/05 22:12:00
Please add a comment here explaining this special
gsathya
2016/10/05 22:47:40
Done.
|
| + promise: PromiseCreate(), |
| + resolve: false, |
| + reject: false |
|
adamk
2016/10/05 22:12:00
How about UNDEFINED for these falses...
gsathya
2016/10/05 22:47:40
Done.
|
| + }; |
| + } else { |
| + // Pass false for debugEvent so .then chaining does not trigger |
| + // redundant ExceptionEvents. |
| + resultCapability = NewPromiseCapability(constructor, false); |
| + } |
| return PerformPromiseThen(this, onResolve, onReject, resultCapability); |
| } |