From c8a69f963f2f370b777396273b1b2fc4c62059f7 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Thu, 3 Dec 2015 16:25:04 -0500 Subject: [PATCH] Add missing checks to Promise.resolve and Promise.reject. These checks were overlooked when @@species was resolved from these methods. Discovered by running the ES2015 test262 test suite against es6-shim. --- es6-shim.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/es6-shim.js b/es6-shim.js index 9109898a..ad82a093 100644 --- a/es6-shim.js +++ b/es6-shim.js @@ -2316,6 +2316,9 @@ reject: function reject(reason) { var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad promise constructor'); + } var capability = new PromiseCapability(C); var rejectFunc = capability.reject; rejectFunc(reason); // call with this===undefined @@ -2325,6 +2328,9 @@ resolve: function resolve(v) { // See https://esdiscuss.org/topic/fixing-promise-resolve for spec var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad promise constructor'); + } if (ES.IsPromise(v)) { var constructor = v.constructor; if (constructor === C) { return v; }