Index: src/promise.js |
diff --git a/src/promise.js b/src/promise.js |
index 82aa99027a1305ac8bf6b95672cccd89504173cd..297bf1e720fcb9fdeb89be63e1376dc89d1b0d35 100644 |
--- a/src/promise.js |
+++ b/src/promise.js |
@@ -248,6 +248,10 @@ function PromiseCast(x) { |
function PromiseAll(values) { |
var deferred = %_CallFunction(this, PromiseDeferred); |
var resolutions = []; |
+ if (!%_IsArray(values)) { |
+ deferred.reject(MakeTypeError('invalid_argument')); |
+ return deferred.promise; |
+ } |
try { |
var count = values.length; |
if (count === 0) { |
@@ -271,6 +275,10 @@ function PromiseAll(values) { |
function PromiseOne(values) { |
var deferred = %_CallFunction(this, PromiseDeferred); |
+ if (!%_IsArray(values)) { |
+ deferred.reject(MakeTypeError('invalid_argument')); |
+ return deferred.promise; |
+ } |
try { |
for (var i = 0; i < values.length; ++i) { |
this.cast(values[i]).chain( |