Index: src/promise.js |
diff --git a/src/promise.js b/src/promise.js |
index d38cdaa482487e84aaf65f1b021bb457bf48a319..c096296b0eb2b48696dc2490e70c2f7243cad653 100644 |
--- a/src/promise.js |
+++ b/src/promise.js |
@@ -67,6 +67,13 @@ var lastMicrotaskId = 0; |
return promise; |
} |
+ function PromiseCreateAndSet(status, value) { |
+ var promise = new $Promise(promiseRaw); |
+ // If debug is active, notify about the newly created promise first. |
+ if (DEBUG_IS_ACTIVE) PromiseSet(promise, 0, UNDEFINED); |
+ return PromiseSet(promise, status, value); |
+ } |
+ |
function PromiseInit(promise) { |
return PromiseSet( |
promise, 0, UNDEFINED, new InternalArray, new InternalArray) |
@@ -197,7 +204,7 @@ var lastMicrotaskId = 0; |
function PromiseResolved(x) { |
if (this === $Promise) { |
// Optimized case, avoid extra closure. |
- return PromiseSet(new $Promise(promiseRaw), +1, x); |
+ return PromiseCreateAndSet(+1, x); |
} else { |
return new this(function(resolve, reject) { resolve(x) }); |
} |
@@ -207,7 +214,7 @@ var lastMicrotaskId = 0; |
var promise; |
if (this === $Promise) { |
// Optimized case, avoid extra closure. |
- promise = PromiseSet(new $Promise(promiseRaw), -1, r); |
+ promise = PromiseCreateAndSet(-1, r); |
// The debug event for this would always be an uncaught promise reject, |
// which is usually simply noise. Do not trigger that debug event. |
%PromiseRejectEvent(promise, r, false); |