function PromiseThen(onResolve, onReject) {
onResolve =
- IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
+ IS_SPEC_FUNCTION(onResolve) ? onResolve : PromiseIdResolveHandler;
onReject =
- IS_NULL_OR_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject;
+ IS_SPEC_FUNCTION(onReject) ? onReject : PromiseIdRejectHandler;
var that = this;
var constructor = this.constructor;
return %_CallFunction(
(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
+ var p2 = p1.then(1, 2)
+ p2.then(
+ function(x) { assertAsync(x === 5, "then/resolve-non-function") },
+ assertUnreachable
+ )
+ deferred.resolve(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = p1.then(1, 2)
+ p2.then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5, "then/reject-non-function") }
+ )
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
var p3 = Promise.accept(p2)
p3.chain(