Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Unified Diff: src/promise.js

Issue 182613003: Promise.all and Promise.race reject non-array parameter. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/promises.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « no previous file | test/mjsunit/harmony/promises.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698