Back out b2316c5a1d69 (bug 915233) for Win b2g desktop build bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Tue, 05 Nov 2013 20:54:54 -0800
changeset 168269 f86c5c6d100db92ed540467f4a43ab06649b9710
parent 168268 bfda5a338c2ecb9fbfe0e1a11c16a305d7a775dc
child 168270 32317b78e332bd7c983be188fe6006e1421647da
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs915233
milestone28.0a1
backs outb2316c5a1d693eb21e35f32038f7775e93341bef
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
Back out b2316c5a1d69 (bug 915233) for Win b2g desktop build bustage
dom/promise/Promise.cpp
dom/promise/Promise.h
dom/promise/PromiseCallback.cpp
dom/promise/PromiseCallback.h
dom/promise/tests/test_promise.html
dom/workers/RegisterBindings.cpp
dom/workers/test/mochitest.ini
dom/workers/test/promise_worker.js
dom/workers/test/test_promise.html
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -5,31 +5,28 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/Promise.h"
 
 #include "jsfriendapi.h"
 #include "mozilla/dom/OwningNonNull.h"
 #include "mozilla/dom/PromiseBinding.h"
 #include "mozilla/Preferences.h"
-#include "mozilla/SyncRunnable.h"
 #include "PromiseCallback.h"
 #include "nsContentUtils.h"
 #include "nsPIDOMWindow.h"
 #include "WorkerPrivate.h"
 #include "nsJSPrincipals.h"
 #include "nsJSUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsJSEnvironment.h"
 
 namespace mozilla {
 namespace dom {
 
-using namespace workers;
-
 // PromiseTask
 
 // This class processes the promise's callbacks with promise's result.
 class PromiseTask MOZ_FINAL : public nsRunnable
 {
 public:
   PromiseTask(Promise* aPromise)
     : mPromise(aPromise)
@@ -49,143 +46,66 @@ public:
     mPromise->RunTask();
     return NS_OK;
   }
 
 private:
   nsRefPtr<Promise> mPromise;
 };
 
-class WorkerPromiseTask MOZ_FINAL : public WorkerRunnable
+// This class processes the promise's callbacks with promise's result.
+class PromiseResolverTask MOZ_FINAL : public nsRunnable
 {
 public:
-  WorkerPromiseTask(WorkerPrivate* aWorkerPrivate, Promise* aPromise)
-    : WorkerRunnable(aWorkerPrivate, WorkerThread,
-                     UnchangedBusyCount, SkipWhenClearing)
-    , mPromise(aPromise)
-  {
-    MOZ_ASSERT(aPromise);
-    MOZ_COUNT_CTOR(WorkerPromiseTask);
-  }
-
-  ~WorkerPromiseTask()
-  {
-    MOZ_COUNT_DTOR(WorkerPromiseTask);
-  }
-
-  bool
-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-  {
-    mPromise->mTaskPending = false;
-    mPromise->RunTask();
-    return true;
-  }
-
-private:
-  nsRefPtr<Promise> mPromise;
-};
-
-class PromiseResolverMixin
-{
-public:
-  PromiseResolverMixin(Promise* aPromise,
-                       JS::Handle<JS::Value> aValue,
-                       Promise::PromiseState aState)
+  PromiseResolverTask(Promise* aPromise,
+                      JS::Handle<JS::Value> aValue,
+                      Promise::PromiseState aState)
     : mPromise(aPromise)
     , mValue(aValue)
     , mState(aState)
   {
     MOZ_ASSERT(aPromise);
     MOZ_ASSERT(mState != Promise::Pending);
-    MOZ_COUNT_CTOR(PromiseResolverMixin);
+    MOZ_COUNT_CTOR(PromiseResolverTask);
 
-    JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
+    JSContext* cx = nsContentUtils::GetSafeJSContext();
 
     /* It's safe to use unsafeGet() here: the unsafeness comes from the
      * possibility of updating the value of mJSObject without triggering the
      * barriers.  However if the value will always be marked, post barriers
      * unnecessary. */
     JS_AddNamedValueRootRT(JS_GetRuntime(cx), mValue.unsafeGet(),
-                           "PromiseResolverMixin.mValue");
+                           "PromiseResolverTask.mValue");
   }
 
-  virtual ~PromiseResolverMixin()
+  ~PromiseResolverTask()
   {
-    NS_ASSERT_OWNINGTHREAD(PromiseResolverMixin);
-    MOZ_COUNT_DTOR(PromiseResolverMixin);
+    MOZ_COUNT_DTOR(PromiseResolverTask);
 
-    JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
+    JSContext* cx = nsContentUtils::GetSafeJSContext();
 
     /* It's safe to use unsafeGet() here: the unsafeness comes from the
      * possibility of updating the value of mJSObject without triggering the
      * barriers.  However if the value will always be marked, post barriers
      * unnecessary. */
     JS_RemoveValueRootRT(JS_GetRuntime(cx), mValue.unsafeGet());
   }
 
-protected:
-  void
-  RunInternal()
+  NS_IMETHOD Run()
   {
-    NS_ASSERT_OWNINGTHREAD(PromiseResolverMixin);
     mPromise->RunResolveTask(
       JS::Handle<JS::Value>::fromMarkedLocation(mValue.address()),
       mState, Promise::SyncTask);
+    return NS_OK;
   }
 
 private:
   nsRefPtr<Promise> mPromise;
   JS::Heap<JS::Value> mValue;
   Promise::PromiseState mState;
-  NS_DECL_OWNINGTHREAD;
-};
-
-// This class processes the promise's callbacks with promise's result.
-class PromiseResolverTask MOZ_FINAL : public nsRunnable,
-                                      public PromiseResolverMixin
-{
-public:
-  PromiseResolverTask(Promise* aPromise,
-                      JS::Handle<JS::Value> aValue,
-                      Promise::PromiseState aState)
-    : PromiseResolverMixin(aPromise, aValue, aState)
-  {}
-
-  ~PromiseResolverTask()
-  {}
-
-  NS_IMETHOD Run()
-  {
-    RunInternal();
-    return NS_OK;
-  }
-};
-
-class WorkerPromiseResolverTask MOZ_FINAL : public WorkerRunnable,
-                                            public PromiseResolverMixin
-{
-public:
-  WorkerPromiseResolverTask(WorkerPrivate* aWorkerPrivate,
-                            Promise* aPromise,
-                            JS::Handle<JS::Value> aValue,
-                            Promise::PromiseState aState)
-    : WorkerRunnable(aWorkerPrivate, WorkerThread,
-                     UnchangedBusyCount, SkipWhenClearing),
-      PromiseResolverMixin(aPromise, aValue, aState)
-  {}
-
-  ~WorkerPromiseResolverTask()
-  {}
-
-  bool
-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-  {
-    RunInternal();
-    return true;
-  }
 };
 
 // Promise
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Promise)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Promise)
   tmp->MaybeReportRejected();
@@ -238,65 +158,35 @@ Promise::~Promise()
 }
 
 JSObject*
 Promise::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return PromiseBinding::Wrap(aCx, aScope, this);
 }
 
-class PrefEnabledRunnable : public nsRunnable
+/* static */ bool
+Promise::PrefEnabled()
 {
-public:
-  PrefEnabledRunnable() : mEnabled(false) {}
-
-  bool
-  Enabled()
-  {
-    return mEnabled;
-  }
-
-  nsresult
-  Run()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-    mEnabled = Preferences::GetBool("dom.promise.enabled", false);
-    return NS_OK;
-  }
-
-private:
-  bool mEnabled;
-};
+  return Preferences::GetBool("dom.promise.enabled", false);
+}
 
 /* static */ bool
 Promise::EnabledForScope(JSContext* aCx, JSObject* /* unused */)
 {
   // Enable if the pref is enabled or if we're chrome or if we're a
   // certified app.
-  nsCOMPtr<nsIThread> mainThread;
-  nsresult rv = NS_GetMainThread(getter_AddRefs(mainThread));
-  NS_ENSURE_SUCCESS(rv, false);
-
-  nsRefPtr<PrefEnabledRunnable> r = new PrefEnabledRunnable();
-
-  // When used from the main thread, SyncRunnable will internally directly call
-  // the function rather than dispatch a Runnable. So this is usable on any
-  // thread.
-  // Although this pause is expensive, it is performed only once per worker when
-  // the worker in initialized.
-  SyncRunnable::DispatchToThread(mainThread, r);
-  if (r->Enabled()) {
+  if (PrefEnabled()) {
     return true;
   }
 
-  // FIXME(nsm): Remove these checks once promises are enabled by default.
   // Note that we have no concept of a certified app in workers.
   // XXXbz well, why not?
   if (!NS_IsMainThread()) {
-    return GetWorkerPrivateFromContext(aCx)->IsChromeWorker();
+    return workers::GetWorkerPrivateFromContext(aCx)->IsChromeWorker();
   }
 
   nsIPrincipal* prin = nsContentUtils::GetSubjectPrincipal();
   return nsContentUtils::IsSystemPrincipal(prin) ||
     prin->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
 }
 
 void
@@ -385,25 +275,20 @@ Promise::CreateFunction(JSContext* aCx, 
   return obj;
 }
 
 /* static */ already_AddRefed<Promise>
 Promise::Constructor(const GlobalObject& aGlobal,
                      PromiseInit& aInit, ErrorResult& aRv)
 {
   JSContext* cx = aGlobal.GetContext();
-  nsCOMPtr<nsPIDOMWindow> window;
-
-  // On workers, let the window be null.
-  if (MOZ_LIKELY(NS_IsMainThread())) {
-    window = do_QueryInterface(aGlobal.GetAsSupports());
-    if (!window) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
+  if (!window) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+    return nullptr;
   }
 
   nsRefPtr<Promise> promise = new Promise(window);
 
   JS::Rooted<JSObject*> resolveFunc(cx,
                                     CreateFunction(cx, aGlobal.Get(), promise,
                                                    PromiseCallback::Resolve));
   if (!resolveFunc) {
@@ -434,43 +319,37 @@ Promise::Constructor(const GlobalObject&
 
   return promise.forget();
 }
 
 /* static */ already_AddRefed<Promise>
 Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
                  JS::Handle<JS::Value> aValue, ErrorResult& aRv)
 {
-  nsCOMPtr<nsPIDOMWindow> window;
-  if (MOZ_LIKELY(NS_IsMainThread())) {
-    window = do_QueryInterface(aGlobal.GetAsSupports());
-    if (!window) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
+  if (!window) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+    return nullptr;
   }
 
   nsRefPtr<Promise> promise = new Promise(window);
 
   Optional<JS::Handle<JS::Value> > value(aCx, aValue);
   promise->MaybeResolveInternal(aCx, value);
   return promise.forget();
 }
 
 /* static */ already_AddRefed<Promise>
 Promise::Reject(const GlobalObject& aGlobal, JSContext* aCx,
                 JS::Handle<JS::Value> aValue, ErrorResult& aRv)
 {
-  nsCOMPtr<nsPIDOMWindow> window;
-  if (MOZ_LIKELY(NS_IsMainThread())) {
-    window = do_QueryInterface(aGlobal.GetAsSupports());
-    if (!window) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
+  if (!window) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+    return nullptr;
   }
 
   nsRefPtr<Promise> promise = new Promise(window);
 
   Optional<JS::Handle<JS::Value> > value(aCx, aValue);
   promise->MaybeRejectInternal(aCx, value);
   return promise.forget();
 }
@@ -519,43 +398,35 @@ Promise::AppendCallbacks(PromiseCallback
     mHadRejectCallback = true;
     mRejectCallbacks.AppendElement(aRejectCallback);
   }
 
   // If promise's state is resolved, queue a task to process our resolve
   // callbacks with promise's result. If promise's state is rejected, queue a
   // task to process our reject callbacks with promise's result.
   if (mState != Pending && !mTaskPending) {
-    if (MOZ_LIKELY(NS_IsMainThread())) {
-      nsRefPtr<PromiseTask> task = new PromiseTask(this);
-      NS_DispatchToCurrentThread(task);
-    } else {
-      WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
-      MOZ_ASSERT(worker);
-      nsRefPtr<WorkerPromiseTask> task = new WorkerPromiseTask(worker, this);
-      worker->Dispatch(task);
-    }
+    nsRefPtr<PromiseTask> task = new PromiseTask(this);
+    NS_DispatchToCurrentThread(task);
     mTaskPending = true;
   }
 }
 
 void
 Promise::RunTask()
 {
   MOZ_ASSERT(mState != Pending);
 
   nsTArray<nsRefPtr<PromiseCallback> > callbacks;
   callbacks.SwapElements(mState == Resolved ? mResolveCallbacks
                                             : mRejectCallbacks);
   mResolveCallbacks.Clear();
   mRejectCallbacks.Clear();
 
-  JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
-  JSAutoRequest ar(cx);
-  Optional<JS::Handle<JS::Value> > value(cx, mResult);
+  JSAutoRequest ar(nsContentUtils::GetSafeJSContext());
+  Optional<JS::Handle<JS::Value> > value(nsContentUtils::GetSafeJSContext(), mResult);
 
   for (uint32_t i = 0; i < callbacks.Length(); ++i) {
     callbacks[i]->Call(value);
   }
 }
 
 void
 Promise::MaybeReportRejected()
@@ -566,37 +437,26 @@ Promise::MaybeReportRejected()
 
   JSErrorReport* report = js::ErrorFromException(mResult);
   if (!report) {
     return;
   }
 
   MOZ_ASSERT(mResult.isObject(), "How did we get a JSErrorReport?");
 
-  // Remains null in case of worker.
-  nsCOMPtr<nsPIDOMWindow> win;
-  bool isChromeError = false;
+  nsCOMPtr<nsPIDOMWindow> win =
+    do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(&mResult.toObject()));
 
-  if (MOZ_LIKELY(NS_IsMainThread())) {
-    win =
-      do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(&mResult.toObject()));
-    nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(&mResult.toObject());
-    isChromeError = nsContentUtils::IsSystemPrincipal(principal);
-  } else {
-    WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
-    MOZ_ASSERT(worker);
-    isChromeError = worker->IsChromeWorker();
-  }
-
+  nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(&mResult.toObject());
   // Now post an event to do the real reporting async
-  NS_DispatchToMainThread(
+  NS_DispatchToCurrentThread(
     new AsyncErrorReporter(JS_GetObjectRuntime(&mResult.toObject()),
                            report,
                            nullptr,
-                           isChromeError,
+                           nsContentUtils::IsSystemPrincipal(principal),
                            win));
 }
 
 void
 Promise::MaybeResolveInternal(JSContext* aCx,
                               const Optional<JS::Handle<JS::Value> >& aValue,
                               PromiseTaskSync aAsynchronous)
 {
@@ -665,27 +525,19 @@ Promise::RejectInternal(JSContext* aCx,
 void
 Promise::RunResolveTask(JS::Handle<JS::Value> aValue,
                         PromiseState aState,
                         PromiseTaskSync aAsynchronous)
 {
   // If the synchronous flag is unset, queue a task to process our
   // accept callbacks with value.
   if (aAsynchronous == AsyncTask) {
-    if (MOZ_LIKELY(NS_IsMainThread())) {
-      nsRefPtr<PromiseResolverTask> task =
-        new PromiseResolverTask(this, aValue, aState);
-      NS_DispatchToCurrentThread(task);
-    } else {
-      WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
-      MOZ_ASSERT(worker);
-      nsRefPtr<WorkerPromiseResolverTask> task =
-        new WorkerPromiseResolverTask(worker, this, aValue, aState);
-      worker->Dispatch(task);
-    }
+    nsRefPtr<PromiseResolverTask> task =
+      new PromiseResolverTask(this, aValue, aState);
+    NS_DispatchToCurrentThread(task);
     return;
   }
 
   SetResult(aValue);
   SetState(aState);
   RunTask();
 }
 
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -22,32 +22,30 @@ namespace dom {
 
 class PromiseInit;
 class PromiseCallback;
 class AnyCallback;
 
 class Promise MOZ_FINAL : public nsISupports,
                           public nsWrapperCache
 {
-  friend class PromiseResolverMixin;
+  friend class PromiseTask;
   friend class PromiseResolverTask;
-  friend class PromiseTask;
+  friend class ResolvePromiseCallback;
   friend class RejectPromiseCallback;
-  friend class ResolvePromiseCallback;
-  friend class WorkerPromiseResolverTask;
-  friend class WorkerPromiseTask;
   friend class WrapperPromiseCallback;
 
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Promise)
 
   Promise(nsPIDOMWindow* aWindow);
   ~Promise();
 
+  static bool PrefEnabled();
   static bool EnabledForScope(JSContext* aCx, JSObject* /* unused */);
 
   void MaybeResolve(JSContext* aCx,
                     const Optional<JS::Handle<JS::Value> >& aValue);
   void MaybeReject(JSContext* aCx,
                    const Optional<JS::Handle<JS::Value> >& aValue);
 
   // WebIDL
--- a/dom/promise/PromiseCallback.cpp
+++ b/dom/promise/PromiseCallback.cpp
@@ -69,23 +69,17 @@ ResolvePromiseCallback::~ResolvePromiseC
 {
   MOZ_COUNT_DTOR(ResolvePromiseCallback);
 }
 
 void
 ResolvePromiseCallback::Call(const Optional<JS::Handle<JS::Value> >& aValue)
 {
   // Run resolver's algorithm with value and the synchronous flag set.
-  JSContext *cx = nsContentUtils::GetDefaultJSContextForThread();
-
-  Maybe<AutoCxPusher> pusher;
-  if (NS_IsMainThread()) {
-    pusher.construct(cx);
-  }
-
+  AutoJSContext cx;
   Maybe<JSAutoCompartment> ac;
   EnterCompartment(ac, cx, aValue);
 
   mPromise->ResolveInternal(cx, aValue, Promise::SyncTask);
 }
 
 // RejectPromiseCallback
 
@@ -110,23 +104,17 @@ RejectPromiseCallback::~RejectPromiseCal
 {
   MOZ_COUNT_DTOR(RejectPromiseCallback);
 }
 
 void
 RejectPromiseCallback::Call(const Optional<JS::Handle<JS::Value> >& aValue)
 {
   // Run resolver's algorithm with value and the synchronous flag set.
-  JSContext *cx = nsContentUtils::GetDefaultJSContextForThread();
-
-  Maybe<AutoCxPusher> pusher;
-  if (NS_IsMainThread()) {
-    pusher.construct(cx);
-  }
-
+  AutoJSContext cx;
   Maybe<JSAutoCompartment> ac;
   EnterCompartment(ac, cx, aValue);
 
   mPromise->RejectInternal(cx, aValue, Promise::SyncTask);
 }
 
 // WrapperPromiseCallback
 
@@ -152,27 +140,17 @@ WrapperPromiseCallback::WrapperPromiseCa
 WrapperPromiseCallback::~WrapperPromiseCallback()
 {
   MOZ_COUNT_DTOR(WrapperPromiseCallback);
 }
 
 void
 WrapperPromiseCallback::Call(const Optional<JS::Handle<JS::Value> >& aValue)
 {
-  // AutoCxPusher and co. interact with xpconnect, which crashes on
-  // workers. On workers we'll get the right context from
-  // GetDefaultJSContextForThread(), and since there is only one context, we
-  // don't need to push or pop it from the stack. Is that correct?
-  JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
-
-  Maybe<AutoCxPusher> pusher;
-  if (NS_IsMainThread()) {
-    pusher.construct(cx);
-  }
-
+  AutoJSContext cx;
   Maybe<JSAutoCompartment> ac;
   EnterCompartment(ac, cx, aValue);
 
   ErrorResult rv;
 
   // If invoking callback threw an exception, run resolver's reject with the
   // thrown exception as argument and the synchronous flag set.
   Optional<JS::Handle<JS::Value> > value(cx,
--- a/dom/promise/PromiseCallback.h
+++ b/dom/promise/PromiseCallback.h
@@ -32,17 +32,17 @@ public:
   };
 
   // This factory returns a PromiseCallback object with refcount of 0.
   static PromiseCallback*
   Factory(Promise* aNextPromise, AnyCallback* aCallback, Task aTask);
 };
 
 // WrapperPromiseCallback execs a JS Callback with a value, and then the return
-// value is sent to the aNextPromise->ResolveFunction() or to
+// value is sent to the aNextPromise->resolveFunction() or to
 // aNextPromise->RejectFunction() if the JS Callback throws.
 class WrapperPromiseCallback MOZ_FINAL : public PromiseCallback
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(WrapperPromiseCallback,
                                            PromiseCallback)
 
--- a/dom/promise/tests/test_promise.html
+++ b/dom/promise/tests/test_promise.html
@@ -363,38 +363,28 @@ function promiseResolveNestedPromise() {
   })).then(function(what) {
     is(what, 42, "Value == 42");
     runTest();
   }, function() {
     ok(false, "This should not be called");
   });
 }
 
-function promiseRejectNoHandler() {
-  // This test only checks that the code that reports unhandled errors in the
-  // Promises implementation does not crash or leak.
-  var promise = new Promise(function(res, rej) {
-    noSuchMethod();
-  });
-  runTest();
-}
-
 var tests = [ promiseResolve, promiseReject,
               promiseException, promiseGC, promiseAsync,
               promiseDoubleThen, promiseThenException,
               promiseThenCatchThen, promiseRejectThenCatchThen,
               promiseRejectThenCatchThen2,
               promiseRejectThenCatchExceptionThen,
               promiseThenCatchOrderingResolve,
               promiseThenCatchOrderingReject,
               promiseNestedPromise, promiseNestedNestedPromise,
               promiseWrongNestedPromise, promiseLoop,
               promiseStaticReject, promiseStaticResolve,
               promiseResolveNestedPromise,
-              promiseRejectNoHandler,
             ];
 
 function runTest() {
   if (!tests.length) {
     SimpleTest.finish();
     return;
   }
 
--- a/dom/workers/RegisterBindings.cpp
+++ b/dom/workers/RegisterBindings.cpp
@@ -14,17 +14,16 @@
 #include "mozilla/dom/EventBinding.h"
 #include "mozilla/dom/EventHandlerBinding.h"
 #include "mozilla/dom/EventTargetBinding.h"
 #include "mozilla/dom/FileReaderSyncBinding.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/ImageDataBinding.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePortBinding.h"
-#include "mozilla/dom/PromiseBinding.h"
 #include "mozilla/dom/TextDecoderBinding.h"
 #include "mozilla/dom/TextEncoderBinding.h"
 #include "mozilla/dom/XMLHttpRequestBinding.h"
 #include "mozilla/dom/XMLHttpRequestUploadBinding.h"
 #include "mozilla/dom/URLBinding.h"
 #include "mozilla/dom/WorkerBinding.h"
 #include "mozilla/dom/WorkerLocationBinding.h"
 #include "mozilla/dom/WorkerNavigatorBinding.h"
@@ -57,27 +56,25 @@ WorkerPrivate::RegisterBindings(JSContex
 
   // Init other paris-bindings.
   if (!DOMExceptionBinding::GetConstructorObject(aCx, aGlobal) ||
       !EventBinding::GetConstructorObject(aCx, aGlobal) ||
       !FileReaderSyncBinding_workers::GetConstructorObject(aCx, aGlobal) ||
       !ImageDataBinding::GetConstructorObject(aCx, aGlobal) ||
       !MessageEventBinding::GetConstructorObject(aCx, aGlobal) ||
       !MessagePortBinding::GetConstructorObject(aCx, aGlobal) ||
-      (PromiseBinding::ConstructorEnabled(aCx, aGlobal) &&
-       !PromiseBinding::GetConstructorObject(aCx, aGlobal)) ||
       !TextDecoderBinding::GetConstructorObject(aCx, aGlobal) ||
       !TextEncoderBinding::GetConstructorObject(aCx, aGlobal) ||
       !XMLHttpRequestBinding_workers::GetConstructorObject(aCx, aGlobal) ||
       !XMLHttpRequestUploadBinding_workers::GetConstructorObject(aCx, aGlobal) ||
       !URLBinding_workers::GetConstructorObject(aCx, aGlobal) ||
       !WorkerBinding::GetConstructorObject(aCx, aGlobal) ||
       !WorkerLocationBinding_workers::GetConstructorObject(aCx, aGlobal) ||
       !WorkerNavigatorBinding_workers::GetConstructorObject(aCx, aGlobal)) {
     return false;
   }
 
   if (!JS_DefineProfilingFunctions(aCx, aGlobal)) {
     return false;
   }
 
   return true;
-}
+}
\ No newline at end of file
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -22,17 +22,16 @@ support-files =
   json_worker.js
   loadEncoding_worker.js
   location_worker.js
   longThread_worker.js
   multi_sharedWorker_frame.html
   multi_sharedWorker_sharedWorker.js
   navigator_worker.js
   newError_worker.js
-  promise_worker.js
   recursion_worker.js
   recursiveOnerror_worker.js
   relativeLoad_import.js
   relativeLoad_worker.js
   relativeLoad_worker2.js
   rvals_worker.js
   sharedWorker_sharedWorker.js
   simpleThread_worker.js
@@ -79,17 +78,16 @@ support-files =
 [test_loadEncoding.html]
 [test_loadError.html]
 [test_location.html]
 [test_longThread.html]
 [test_multi_sharedWorker.html]
 [test_multi_sharedWorker_lifetimes.html]
 [test_navigator.html]
 [test_newError.html]
-[test_promise.html]
 [test_recursion.html]
 [test_recursiveOnerror.html]
 [test_relativeLoad.html]
 [test_resolveWorker-assignment.html]
 [test_resolveWorker.html]
 [test_rvals.html]
 [test_sharedWorker.html]
 [test_simpleThread.html]
deleted file mode 100644
--- a/dom/workers/test/promise_worker.js
+++ /dev/null
@@ -1,395 +0,0 @@
-function ok(a, msg) {
-  dump("OK: " + !!a + "  =>  " + a + " " + msg + "\n");
-  postMessage({type: 'status', status: !!a, msg: a + ": " + msg });
-}
-
-function is(a, b, msg) {
-  dump("IS: " + (a===b) + "  =>  " + a + " | " + b + " " + msg + "\n");
-  postMessage({type: 'status', status: a === b, msg: a + " === " + b + ": " + msg });
-}
-
-function isnot(a, b, msg) {
-  dump("ISNOT: " + (a!==b) + "  =>  " + a + " | " + b + " " + msg + "\n");
-  postMessage({type: 'status', status: a !== b, msg: a + " !== " + b + ": " + msg });
-}
-
-function promiseResolve() {
-  ok(Promise, "Promise object should exist");
-
-  var promise = new Promise(function(resolve, reject) {
-    ok(resolve, "Promise.resolve exists");
-    ok(reject, "Promise.reject exists");
-
-    resolve(42);
-  }).then(function(what) {
-    ok(true, "Then - resolveCb has been called");
-    is(what, 42, "ResolveCb received 42");
-    runTest();
-  }, function() {
-    ok(false, "Then - rejectCb has been called");
-    runTest();
-  });
-}
-
-
-function promiseReject() {
-  var promise = new Promise(function(resolve, reject) {
-    reject(42);
-  }).then(function(what) {
-    ok(false, "Then - resolveCb has been called");
-    runTest();
-  }, function(what) {
-    ok(true, "Then - rejectCb has been called");
-    is(what, 42, "RejectCb received 42");
-    runTest();
-  });
-}
-
-function promiseException() {
-  var promise = new Promise(function(resolve, reject) {
-    throw 42;
-  }).then(function(what) {
-    ok(false, "Then - resolveCb has been called");
-    runTest();
-  }, function(what) {
-    ok(true, "Then - rejectCb has been called");
-    is(what, 42, "RejectCb received 42");
-    runTest();
-  });
-}
-
-function promiseAsync() {
-  var global = "foo";
-  var f = new Promise(function(r1, r2) {
-    is(global, "foo", "Global should be foo");
-    r1(42);
-    is(global, "foo", "Global should still be foo");
-    setTimeout(function() {
-      is(global, "bar", "Global should still be bar!");
-      runTest();
-    }, 0);
-  }).then(function() {
-    global = "bar";
-  });
-  is(global, "foo", "Global should still be foo (2)");
-}
-
-function promiseDoubleThen() {
-  var steps = 0;
-  var promise = new Promise(function(r1, r2) {
-    r1(42);
-  });
-
-  promise.then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 42, "Value == 42");
-    steps++;
-  }, function(what) {
-    ok(false, "Then.reject has been called");
-  });
-
-  promise.then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(steps, 1, "Then.resolve - step == 1");
-    is(what, 42, "Value == 42");
-    runTest();
-  }, function(what) {
-    ok(false, "Then.reject has been called");
-  });
-}
-
-function promiseThenException() {
-  var promise = new Promise(function(resolve, reject) {
-    resolve(42);
-  });
-
-  promise.then(function(what) {
-    ok(true, "Then.resolve has been called");
-    throw "booh";
-  }).catch(function(e) {
-    ok(true, "Catch has been called!");
-    runTest();
-  });
-}
-
-function promiseThenCatchThen() {
-  var promise = new Promise(function(resolve, reject) {
-    resolve(42);
-  });
-
-  var promise2 = promise.then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 42, "Value == 42");
-    return what + 1;
-  }, function(what) {
-    ok(false, "Then.reject has been called");
-  });
-
-  isnot(promise, promise2, "These 2 promise objs are different");
-
-  promise2.then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 43, "Value == 43");
-    return what + 1;
-  }, function(what) {
-    ok(false, "Then.reject has been called");
-  }).catch(function() {
-    ok(false, "Catch has been called");
-  }).then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 44, "Value == 44");
-    runTest();
-  }, function(what) {
-    ok(false, "Then.reject has been called");
-  });
-}
-
-function promiseRejectThenCatchThen() {
-  var promise = new Promise(function(resolve, reject) {
-    reject(42);
-  });
-
-  var promise2 = promise.then(function(what) {
-    ok(false, "Then.resolve has been called");
-  }, function(what) {
-    ok(true, "Then.reject has been called");
-    is(what, 42, "Value == 42");
-    return what + 1;
-  });
-
-  isnot(promise, promise2, "These 2 promise objs are different");
-
-  promise2.then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 43, "Value == 43");
-    return what+1;
-  }).catch(function(what) {
-    ok(false, "Catch has been called");
-  }).then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 44, "Value == 44");
-    runTest();
-  });
-}
-
-function promiseRejectThenCatchThen2() {
-  var promise = new Promise(function(resolve, reject) {
-    reject(42);
-  });
-
-  promise.then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 42, "Value == 42");
-    return what+1;
-  }).catch(function(what) {
-    is(what, 42, "Value == 42");
-    ok(true, "Catch has been called");
-    return what+1;
-  }).then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 43, "Value == 43");
-    runTest();
-  });
-}
-
-function promiseRejectThenCatchExceptionThen() {
-  var promise = new Promise(function(resolve, reject) {
-    reject(42);
-  });
-
-  promise.then(function(what) {
-    ok(false, "Then.resolve has been called");
-  }, function(what) {
-    ok(true, "Then.reject has been called");
-    is(what, 42, "Value == 42");
-    throw(what + 1);
-  }).catch(function(what) {
-    ok(true, "Catch has been called");
-    is(what, 43, "Value == 43");
-    return what + 1;
-  }).then(function(what) {
-    ok(true, "Then.resolve has been called");
-    is(what, 44, "Value == 44");
-    runTest();
-  });
-}
-
-function promiseThenCatchOrderingResolve() {
-  var global = 0;
-  var f = new Promise(function(r1, r2) {
-    r1(42);
-  });
-
-  f.then(function() {
-    f.then(function() {
-      global++;
-    });
-    f.catch(function() {
-      global++;
-    });
-    f.then(function() {
-      global++;
-    });
-    setTimeout(function() {
-      is(global, 2, "Many steps... should return 2");
-      runTest();
-    }, 0);
-  });
-}
-
-function promiseThenCatchOrderingReject() {
-  var global = 0;
-  var f = new Promise(function(r1, r2) {
-    r2(42);
-  })
-
-  f.then(function() {}, function() {
-    f.then(function() {
-      global++;
-    });
-    f.catch(function() {
-      global++;
-    });
-    f.then(function() {}, function() {
-      global++;
-    });
-    setTimeout(function() {
-      is(global, 2, "Many steps... should return 2");
-      runTest();
-    }, 0);
-  });
-}
-
-function promiseNestedPromise() {
-  new Promise(function(resolve, reject) {
-    resolve(new Promise(function(resolve, reject) {
-      ok(true, "Nested promise is executed");
-      resolve(42);
-    }));
-  }).then(function(value) {
-    is(value, 42, "Nested promise is executed and then == 42");
-    runTest();
-  });
-}
-
-function promiseNestedNestedPromise() {
-  new Promise(function(resolve, reject) {
-    resolve(new Promise(function(resolve, reject) {
-      ok(true, "Nested promise is executed");
-      resolve(42);
-    }).then(function(what) { return what+1; }));
-  }).then(function(value) {
-    is(value, 43, "Nested promise is executed and then == 43");
-    runTest();
-  });
-}
-
-function promiseWrongNestedPromise() {
-  new Promise(function(resolve, reject) {
-    resolve(new Promise(function(r, r2) {
-      ok(true, "Nested promise is executed");
-      r(42);
-    }));
-    reject(42);
-  }).then(function(value) {
-    is(value, 42, "Nested promise is executed and then == 42");
-    runTest();
-  }, function(value) {
-     ok(false, "This is wrong");
-  });
-}
-
-function promiseLoop() {
-  new Promise(function(resolve, reject) {
-    resolve(new Promise(function(r1, r2) {
-      ok(true, "Nested promise is executed");
-      r1(new Promise(function(r1, r2) {
-        ok(true, "Nested nested promise is executed");
-        r1(42);
-      }));
-    }));
-  }).then(function(value) {
-    is(value, 42, "Nested nested promise is executed and then == 42");
-    runTest();
-  }, function(value) {
-     ok(false, "This is wrong");
-  });
-}
-
-function promiseStaticReject() {
-  var promise = Promise.reject(42).then(function(what) {
-    ok(false, "This should not be called");
-  }, function(what) {
-    is(what, 42, "Value == 42");
-    runTest();
-  });
-}
-
-function promiseStaticResolve() {
-  var promise = Promise.resolve(42).then(function(what) {
-    is(what, 42, "Value == 42");
-    runTest();
-  }, function() {
-    ok(false, "This should not be called");
-  });
-}
-
-function promiseResolveNestedPromise() {
-  var promise = Promise.resolve(new Promise(function(r, r2) {
-    ok(true, "Nested promise is executed");
-    r(42);
-  }, function() {
-    ok(false, "This should not be called");
-  })).then(function(what) {
-    is(what, 42, "Value == 42");
-    runTest();
-  }, function() {
-    ok(false, "This should not be called");
-  });
-}
-
-function promiseRejectNoHandler() {
-  // This test only checks that the code that reports unhandled errors in the
-  // Promises implementation does not crash or leak.
-  var promise = new Promise(function(res, rej) {
-    noSuchMethod();
-  });
-  runTest();
-}
-
-var tests = [
-    promiseResolve,
-    promiseReject,
-    promiseException,
-    promiseAsync,
-    promiseDoubleThen,
-    promiseThenException,
-    promiseThenCatchThen,
-    promiseRejectThenCatchThen,
-    promiseRejectThenCatchThen2,
-    promiseRejectThenCatchExceptionThen,
-    promiseThenCatchOrderingResolve,
-    promiseThenCatchOrderingReject,
-    promiseNestedPromise,
-    promiseNestedNestedPromise,
-    promiseWrongNestedPromise,
-    promiseLoop,
-    promiseStaticReject,
-    promiseStaticResolve,
-    promiseResolveNestedPromise,
-    promiseRejectNoHandler,
-];
-
-function runTest() {
-  if (!tests.length) {
-    postMessage({ type: 'finish' });
-    return;
-  }
-
-  var test = tests.shift();
-  test();
-}
-
-onmessage = function() {
-  runTest();
-}
deleted file mode 100644
--- a/dom/workers/test/test_promise.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Promise object in workers</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test"></pre>
-<script class="testbody" type="text/javascript">
-
-  function runTest() {
-    var worker = new Worker("promise_worker.js");
-
-    worker.onmessage = function(event) {
-
-      if (event.data.type == 'finish') {
-        SimpleTest.finish();
-      } else if (event.data.type == 'status') {
-        ok(event.data.status, event.data.msg);
-      }
-    }
-
-    worker.onerror = function(event) {
-      ok(false, "Worker had an error: " + event.data);
-      SimpleTest.finish();
-    };
-
-    worker.postMessage(true);
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPrefEnv({"set": [["dom.promise.enabled", true]]}, runTest);
-</script>
-</pre>
-</body>
-</html>
-