Revision: 19754
Author: [email protected]
Date: Mon Mar 10 12:01:06 2014 UTC
Log: Promise.all and Promise.race should reject non-array parameter.
Promise.all and Promise.race should reject the returned Promise if an
invalid parameter is given.
Since they don't support iterable now, they should reject the Promise
if a non-array parameter is given.
BUG=347453
LOG=Y
[email protected]
Review URL: https://codereview.chromium.org/182613003
Patch from Yutaka Hirano <[email protected]>.
http://code.google.com/p/v8/source/detail?r=19754
Modified:
/branches/bleeding_edge/src/promise.js
/branches/bleeding_edge/test/mjsunit/harmony/promises.js
=======================================
--- /branches/bleeding_edge/src/promise.js Mon Mar 10 11:52:13 2014 UTC
+++ /branches/bleeding_edge/src/promise.js Mon Mar 10 12:01:06 2014 UTC
@@ -248,6 +248,10 @@
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 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]).then(
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/promises.js Thu Jan 9
13:00:56 2014 UTC
+++ /branches/bleeding_edge/test/mjsunit/harmony/promises.js Mon Mar 10
12:01:06 2014 UTC
@@ -559,9 +559,9 @@
})();
(function() {
- Promise.all({get length() { throw 666 }}).chain(
+ Promise.all({}).chain(
assertUnreachable,
- function(r) { assertAsync(r === 666, "all/no-array") }
+ function(r) { assertAsync(r instanceof TypeError, "all/no-array") }
)
assertAsyncRan()
})();
@@ -658,9 +658,9 @@
})();
(function() {
- Promise.race({get length() { throw 666 }}).chain(
+ Promise.race({}).chain(
assertUnreachable,
- function(r) { assertAsync(r === 666, "one/no-array") }
+ function(r) { assertAsync(r instanceof TypeError, "one/no-array") }
)
assertAsyncRan()
})();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.