Bug 973988 - DOM Promise constructor should call the executor with "undefined" as thisArg. r=bz
authorWilliam Chen <wchen@mozilla.com>
Wed, 19 Feb 2014 10:59:23 -0800
changeset 169582 5c6b2dcd79eba94bab375aa5071671fded2e62e6
parent 169581 c14a3f379d5ea52068921a85c3885c3c4830cf2f
child 169583 71f4051ae6b392b59e005b77bf84bcb1f754a420
push id26258
push usercbook@mozilla.com
push dateThu, 20 Feb 2014 11:53:37 +0000
treeherdermozilla-central@df6148983ef9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs973988
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 973988 - DOM Promise constructor should call the executor with "undefined" as thisArg. r=bz
dom/promise/Promise.cpp
dom/promise/tests/test_promise.html
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -477,18 +477,17 @@ Promise::Constructor(const GlobalObject&
   JS::Rooted<JSObject*> rejectFunc(cx,
                                    CreateFunction(cx, aGlobal.Get(), promise,
                                                   PromiseCallback::Reject));
   if (!rejectFunc) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
-  aInit.Call(promise, resolveFunc, rejectFunc, aRv,
-             CallbackObject::eRethrowExceptions);
+  aInit.Call(resolveFunc, rejectFunc, aRv, CallbackObject::eRethrowExceptions);
   aRv.WouldReportJSException();
 
   if (aRv.IsJSException()) {
     JS::Rooted<JS::Value> value(cx);
     aRv.StealJSException(cx, &value);
 
     Maybe<JSAutoCompartment> ac;
     EnterCompartment(ac, cx, value);
--- a/dom/promise/tests/test_promise.html
+++ b/dom/promise/tests/test_promise.html
@@ -568,16 +568,24 @@ function promiseStrictHandlers() {
   var promise = Promise.resolve(5);
   promise.then(function() {
     "use strict";
     ok(this === undefined, "Strict mode callback should have this === undefined.");
     runTest();
   });
 }
 
+function promiseStrictExecutorThisArg() {
+  var promise = new Promise(function(resolve, reject) {
+    "use strict";
+    ok(this === undefined, "thisArg should be undefined.");
+    runTest();
+  });
+}
+
 function promiseResolveArray() {
   var p = Promise.resolve([1,2,3]);
   ok(p instanceof Promise, "Should return a Promise.");
   p.then(function(v) {
     ok(Array.isArray(v), "Resolved value should be an Array");
     is(v.length, 3, "Length should match");
     is(v[0], 1, "Resolved value should match original");
     is(v[1], 2, "Resolved value should match original");
@@ -631,16 +639,17 @@ var tests = [ promiseResolve, promiseRej
               promiseRejectNoHandler,
               promiseSimpleThenableResolve,
               promiseSimpleThenableReject,
               promiseThenableThrowsBeforeCallback,
               promiseThenableThrowsAfterCallback,
               promiseThenableRejectThenResolve,
               promiseWithThenReplaced,
               promiseStrictHandlers,
+              promiseStrictExecutorThisArg,
               promiseResolveArray,
               promiseResolveThenable,
               promiseResolvePromise,
             ];
 
 function runTest() {
   if (!tests.length) {
     SimpleTest.finish();