Bug 1252091. Add/RemoveFeature don't need a JSContext argument. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 29 Feb 2016 14:52:42 -0500
changeset 286100 954c9e9408fdebff893dc430a733981e43499b63
parent 286099 fc5cc380ddb34a2939d2a5bc2a6121b879b5fa95
child 286101 15c8b57820177d9b0c3d603eaae8ef5a7f3ceb93
push id72645
push userbzbarsky@mozilla.com
push dateMon, 29 Feb 2016 19:52:56 +0000
treeherdermozilla-inbound@42f4ce691c60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1252091
milestone47.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 1252091. Add/RemoveFeature don't need a JSContext argument. r=khuey
dom/base/Console.cpp
dom/base/FileReader.cpp
dom/base/WebSocket.cpp
dom/broadcastchannel/BroadcastChannel.cpp
dom/cache/Feature.cpp
dom/canvas/WebGLContextLossHandler.cpp
dom/fetch/Fetch.cpp
dom/indexedDB/ActorsChild.cpp
dom/indexedDB/IDBRequest.cpp
dom/indexedDB/IDBTransaction.cpp
dom/messagechannel/MessagePort.cpp
dom/notification/Notification.cpp
dom/promise/Promise.cpp
dom/workers/DataStore.cpp
dom/workers/ScriptLoader.cpp
dom/workers/ServiceWorkerPrivate.cpp
dom/workers/ServiceWorkerRegistration.cpp
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
dom/workers/XMLHttpRequest.cpp
--- a/dom/base/Console.cpp
+++ b/dom/base/Console.cpp
@@ -293,17 +293,17 @@ public:
     mWorkerPrivate->AssertIsOnWorkerThread();
 
     JSContext* cx = mWorkerPrivate->GetJSContext();
 
     if (!PreDispatch(cx, aGlobal)) {
       return false;
     }
 
-    if (NS_WARN_IF(!mWorkerPrivate->AddFeature(cx, this))) {
+    if (NS_WARN_IF(!mWorkerPrivate->AddFeature(this))) {
       return false;
     }
 
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(this)));
     return true;
   }
 
   virtual bool Notify(JSContext* aCx, workers::Status aStatus) override
@@ -355,17 +355,17 @@ private:
       WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) override
       {
         MOZ_ASSERT(aWorkerPrivate);
         aWorkerPrivate->AssertIsOnWorkerThread();
 
         mRunnable->ReleaseData();
         mRunnable->mConsole = nullptr;
 
-        aWorkerPrivate->RemoveFeature(aCx, mRunnable);
+        aWorkerPrivate->RemoveFeature(mRunnable);
         return true;
       }
 
     private:
       ~ConsoleReleaseRunnable()
       {}
     };
 
--- a/dom/base/FileReader.cpp
+++ b/dom/base/FileReader.cpp
@@ -696,29 +696,29 @@ FileReader::Abort(ErrorResult& aRv)
   DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
   DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
 }
 
 nsresult
 FileReader::IncreaseBusyCounter()
 {
   if (mWorkerPrivate && mBusyCount++ == 0 &&
-      !mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), this)) {
+      !mWorkerPrivate->AddFeature(this)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 void
 FileReader::DecreaseBusyCounter()
 {
   MOZ_ASSERT_IF(mWorkerPrivate, mBusyCount);
   if (mWorkerPrivate && --mBusyCount == 0) {
-    mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
+    mWorkerPrivate->RemoveFeature(this);
   }
 }
 
 bool
 FileReader::Notify(JSContext* aCx, Status aStatus)
 {
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -2125,18 +2125,17 @@ WebSocketImpl::ReleaseObject()
 
 bool
 WebSocketImpl::RegisterFeature()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(!mWorkerFeature);
   mWorkerFeature = new WebSocketWorkerFeature(this);
 
-  JSContext* cx = GetCurrentThreadJSContext();
-  if (!mWorkerPrivate->AddFeature(cx, mWorkerFeature)) {
+  if (!mWorkerPrivate->AddFeature(mWorkerFeature)) {
     NS_WARNING("Failed to register a feature.");
     mWorkerFeature = nullptr;
     return false;
   }
 
 #ifdef DEBUG
   SetHasFeatureRegistered(true);
 #endif
@@ -2147,18 +2146,17 @@ WebSocketImpl::RegisterFeature()
 void
 WebSocketImpl::UnregisterFeature()
 {
   MOZ_ASSERT(mDisconnectingOrDisconnected);
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(mWorkerFeature);
 
-  JSContext* cx = GetCurrentThreadJSContext();
-  mWorkerPrivate->RemoveFeature(cx, mWorkerFeature);
+  mWorkerPrivate->RemoveFeature(mWorkerFeature);
   mWorkerFeature = nullptr;
   mWorkerPrivate = nullptr;
 
 #ifdef DEBUG
   SetHasFeatureRegistered(false);
 #endif
 }
 
--- a/dom/broadcastchannel/BroadcastChannel.cpp
+++ b/dom/broadcastchannel/BroadcastChannel.cpp
@@ -416,18 +416,17 @@ BroadcastChannel::Constructor(const Glob
 
     // Register as observer for inner-window-destroyed.
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
       obs->AddObserver(bc, "inner-window-destroyed", false);
     }
   } else {
     bc->mWorkerFeature = new BroadcastChannelFeature(bc);
-    JSContext* cx = workerPrivate->GetJSContext();
-    if (NS_WARN_IF(!workerPrivate->AddFeature(cx, bc->mWorkerFeature))) {
+    if (NS_WARN_IF(!workerPrivate->AddFeature(bc->mWorkerFeature))) {
       NS_WARNING("Failed to register the BroadcastChannel worker feature.");
       bc->mWorkerFeature = nullptr;
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
   }
 
   return bc.forget();
@@ -541,17 +540,17 @@ BroadcastChannel::ActorCreated(PBackgrou
 
 void
 BroadcastChannel::Shutdown()
 {
   mState = StateClosed;
 
   if (mWorkerFeature) {
     WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
-    workerPrivate->RemoveFeature(workerPrivate->GetJSContext(), mWorkerFeature);
+    workerPrivate->RemoveFeature(mWorkerFeature);
     mWorkerFeature = nullptr;
   }
 
   if (mActor) {
     mActor->SetParent(nullptr);
 
     RefPtr<TeardownRunnable> runnable = new TeardownRunnable(mActor);
     NS_DispatchToCurrentThread(runnable);
--- a/dom/cache/Feature.cpp
+++ b/dom/cache/Feature.cpp
@@ -20,17 +20,17 @@ using mozilla::dom::workers::WorkerPriva
 // static
 already_AddRefed<Feature>
 Feature::Create(WorkerPrivate* aWorkerPrivate)
 {
   MOZ_ASSERT(aWorkerPrivate);
 
   RefPtr<Feature> feature = new Feature(aWorkerPrivate);
 
-  if (!aWorkerPrivate->AddFeature(aWorkerPrivate->GetJSContext(), feature)) {
+  if (!aWorkerPrivate->AddFeature(feature)) {
     return nullptr;
   }
 
   return feature.forget();
 }
 
 void
 Feature::AddActor(ActorChild* aActor)
@@ -97,14 +97,14 @@ Feature::Feature(WorkerPrivate* aWorkerP
   MOZ_ASSERT(mWorkerPrivate);
 }
 
 Feature::~Feature()
 {
   NS_ASSERT_OWNINGTHREAD(Feature);
   MOZ_ASSERT(mActorList.IsEmpty());
 
-  mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
+  mWorkerPrivate->RemoveFeature(this);
 }
 
 } // namespace cache
 } // namespace dom
 } // namespace mozilla
--- a/dom/canvas/WebGLContextLossHandler.cpp
+++ b/dom/canvas/WebGLContextLossHandler.cpp
@@ -179,17 +179,17 @@ WebGLContextLossHandler::RunTimer()
     }
 
     if (!NS_IsMainThread()) {
         dom::workers::WorkerPrivate* workerPrivate =
             dom::workers::GetCurrentThreadWorkerPrivate();
         nsCOMPtr<nsIEventTarget> target = workerPrivate->GetEventTarget();
         mTimer->SetTarget(new ContextLossWorkerEventTarget(target));
         if (!mFeatureAdded) {
-            workerPrivate->AddFeature(workerPrivate->GetJSContext(), this);
+            workerPrivate->AddFeature(this);
             mFeatureAdded = true;
         }
     }
 
     StartTimer(1000);
 
     mIsTimerRunning = true;
     mShouldRunTimerAgain = false;
@@ -202,17 +202,17 @@ WebGLContextLossHandler::DisableTimer()
         return;
 
     mIsDisabled = true;
 
     if (mFeatureAdded) {
         dom::workers::WorkerPrivate* workerPrivate =
             dom::workers::GetCurrentThreadWorkerPrivate();
         MOZ_RELEASE_ASSERT(workerPrivate);
-        workerPrivate->RemoveFeature(workerPrivate->GetJSContext(), this);
+        workerPrivate->RemoveFeature(this);
         mFeatureAdded = false;
     }
 
     // We can't just Cancel() the timer, as sometimes we end up
     // receiving a callback after calling Cancel(). This could cause us
     // to receive the callback after object destruction.
 
     // Instead, we let the timer finish, but ignore it.
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -813,34 +813,34 @@ template <class Derived>
 bool
 FetchBody<Derived>::RegisterFeature()
 {
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(!mFeature);
   mFeature = new FetchBodyFeature<Derived>(this);
 
-  if (!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), mFeature)) {
+  if (!mWorkerPrivate->AddFeature(mFeature)) {
     NS_WARNING("Failed to add feature");
     mFeature = nullptr;
     return false;
   }
 
   return true;
 }
 
 template <class Derived>
 void
 FetchBody<Derived>::UnregisterFeature()
 {
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(mFeature);
 
-  mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), mFeature);
+  mWorkerPrivate->RemoveFeature(mFeature);
   mFeature = nullptr;
 }
 
 template <class Derived>
 void
 FetchBody<Derived>::CancelPump()
 {
   AssertIsOnMainThread();
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -954,18 +954,17 @@ public:
 
     RefPtr<IDBFactory> factory;
     mFactory.swap(factory);
 
     mActor->SendPermissionRetry();
     mActor = nullptr;
 
     mWorkerPrivate->AssertIsOnWorkerThread();
-    JSContext* cx = mWorkerPrivate->GetJSContext();
-    mWorkerPrivate->RemoveFeature(cx, this);
+    mWorkerPrivate->RemoveFeature(this);
   }
 
 private:
   bool
   RunInternal()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
@@ -1407,20 +1406,17 @@ BackgroundFactoryRequestChild::RecvPermi
     WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(workerPrivate);
     workerPrivate->AssertIsOnWorkerThread();
 
     RefPtr<WorkerPermissionChallenge> challenge =
       new WorkerPermissionChallenge(workerPrivate, this, mFactory,
                                     aPrincipalInfo);
 
-    JSContext* cx = workerPrivate->GetJSContext();
-    MOZ_ASSERT(cx);
-
-    if (NS_WARN_IF(!workerPrivate->AddFeature(cx, challenge))) {
+    if (NS_WARN_IF(!workerPrivate->AddFeature(challenge))) {
       return false;
     }
 
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(challenge)));
     return true;
   }
 
   nsresult rv;
--- a/dom/indexedDB/IDBRequest.cpp
+++ b/dom/indexedDB/IDBRequest.cpp
@@ -486,17 +486,17 @@ public:
   {
 #ifdef DEBUG
     mWorkerPrivateDEBUG->AssertIsOnWorkerThread();
 #endif
 
     MOZ_COUNT_DTOR(IDBOpenDBRequest::WorkerFeature);
 
     if (mWorkerPrivate) {
-      mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
+      mWorkerPrivate->RemoveFeature(this);
     }
   }
 
   void
   NoteAddFeatureFailed()
   {
     MOZ_ASSERT(mWorkerPrivate);
     mWorkerPrivate->AssertIsOnWorkerThread();
@@ -567,21 +567,18 @@ IDBOpenDBRequest::CreateForJS(IDBFactory
   request->SetScriptOwner(aScriptOwner);
 
   if (!NS_IsMainThread()) {
     WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(workerPrivate);
 
     workerPrivate->AssertIsOnWorkerThread();
 
-    JSContext* cx = workerPrivate->GetJSContext();
-    MOZ_ASSERT(cx);
-
     nsAutoPtr<WorkerFeature> feature(new WorkerFeature(workerPrivate));
-    if (NS_WARN_IF(!workerPrivate->AddFeature(cx, feature))) {
+    if (NS_WARN_IF(!workerPrivate->AddFeature(feature))) {
       feature->NoteAddFeatureFailed();
       return nullptr;
     }
 
     request->mWorkerFeature = Move(feature);
   }
 
   return request.forget();
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -57,17 +57,17 @@ public:
   }
 
   ~WorkerFeature()
   {
     mWorkerPrivate->AssertIsOnWorkerThread();
 
     MOZ_COUNT_DTOR(IDBTransaction::WorkerFeature);
 
-    mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
+    mWorkerPrivate->RemoveFeature(this);
   }
 
 private:
   virtual bool
   Notify(JSContext* aCx, Status aStatus) override;
 };
 
 IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
@@ -234,21 +234,18 @@ IDBTransaction::Create(IDBDatabase* aDat
   transaction->mRegistered = true;
 
   if (!NS_IsMainThread()) {
     WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(workerPrivate);
 
     workerPrivate->AssertIsOnWorkerThread();
 
-    JSContext* cx = workerPrivate->GetJSContext();
-    MOZ_ASSERT(cx);
-
     transaction->mWorkerFeature = new WorkerFeature(workerPrivate, transaction);
-    MOZ_ALWAYS_TRUE(workerPrivate->AddFeature(cx, transaction->mWorkerFeature));
+    MOZ_ALWAYS_TRUE(workerPrivate->AddFeature(transaction->mWorkerFeature));
   }
 
   return transaction.forget();
 }
 
 // static
 IDBTransaction*
 IDBTransaction::GetCurrent()
--- a/dom/messagechannel/MessagePort.cpp
+++ b/dom/messagechannel/MessagePort.cpp
@@ -342,18 +342,17 @@ MessagePort::Initialize(const nsID& aUUI
   UpdateMustKeepAlive();
 
   if (!NS_IsMainThread()) {
     WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(workerPrivate);
     MOZ_ASSERT(!mWorkerFeature);
 
     nsAutoPtr<WorkerFeature> feature(new MessagePortFeature(this));
-    JSContext* cx = workerPrivate->GetJSContext();
-    if (NS_WARN_IF(!workerPrivate->AddFeature(cx, feature))) {
+    if (NS_WARN_IF(!workerPrivate->AddFeature(feature))) {
       aRv.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     mWorkerFeature = Move(feature);
   } else if (GetOwner()) {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(GetOwner()->IsInnerWindow());
@@ -879,18 +878,17 @@ MessagePort::UpdateMustKeepAlive()
       mMessages.IsEmpty() &&
       mIsKeptAlive) {
     mIsKeptAlive = false;
 
     if (mWorkerFeature) {
       WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
       MOZ_ASSERT(workerPrivate);
 
-      workerPrivate->RemoveFeature(workerPrivate->GetJSContext(),
-                                   mWorkerFeature);
+      workerPrivate->RemoveFeature(mWorkerFeature);
       mWorkerFeature = nullptr;
     }
 
     if (NS_IsMainThread()) {
       nsCOMPtr<nsIObserverService> obs =
         do_GetService("@mozilla.org/observer-service;1");
       if (obs) {
         obs->RemoveObserver(this, "inner-window-destroyed");
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -2505,33 +2505,31 @@ NotificationFeature::Notify(JSContext* a
 
 bool
 Notification::RegisterFeature()
 {
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(!mFeature);
   mFeature = MakeUnique<NotificationFeature>(this);
-  bool added = mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(),
-                                          mFeature.get());
+  bool added = mWorkerPrivate->AddFeature(mFeature.get());
   if (!added) {
     mFeature = nullptr;
   }
 
   return added;
 }
 
 void
 Notification::UnregisterFeature()
 {
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(mFeature);
-  mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(),
-                                mFeature.get());
+  mWorkerPrivate->RemoveFeature(mFeature.get());
   mFeature = nullptr;
 }
 
 /*
  * Checks:
  * 1) Is aWorker allowed to show a notification for scope?
  * 2) Is aWorker an active worker?
  *
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -2602,17 +2602,17 @@ Promise::Settle(JS::Handle<JS::Value> aV
   if (aState == PromiseState::Rejected &&
       !mHadRejectCallback &&
       !NS_IsMainThread()) {
     workers::WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(worker);
     worker->AssertIsOnWorkerThread();
 
     mFeature = new PromiseReportRejectFeature(this);
-    if (NS_WARN_IF(!worker->AddFeature(worker->GetJSContext(), mFeature))) {
+    if (NS_WARN_IF(!worker->AddFeature(mFeature))) {
       // To avoid a false RemoveFeature().
       mFeature = nullptr;
       // Worker is shutting down, report rejection immediately since it is
       // unlikely that reject callbacks will be added after this point.
       MaybeReportRejectedOnce();
     }
   }
 #endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
@@ -2652,17 +2652,17 @@ Promise::TriggerPromiseReactions()
 
 #if defined(DOM_PROMISE_DEPRECATED_REPORTING)
 void
 Promise::RemoveFeature()
 {
   if (mFeature) {
     workers::WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(worker);
-    worker->RemoveFeature(worker->GetJSContext(), mFeature);
+    worker->RemoveFeature(mFeature);
     mFeature = nullptr;
   }
 }
 
 bool
 PromiseReportRejectFeature::Notify(JSContext* aCx, workers::Status aStatus)
 {
   MOZ_ASSERT(aStatus > workers::Running);
@@ -2828,18 +2828,17 @@ PromiseWorkerProxy::CleanProperties()
 }
 
 bool
 PromiseWorkerProxy::AddRefObject()
 {
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(!mFeatureAdded);
-  if (!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(),
-                                  this)) {
+  if (!mWorkerPrivate->AddFeature(this)) {
     return false;
   }
 
   mFeatureAdded = true;
   // Maintain a reference so that we have a valid object to clean up when
   // removing the feature.
   AddRef();
   return true;
@@ -2948,17 +2947,17 @@ PromiseWorkerProxy::CleanUp(JSContext* a
     MOZ_ASSERT(mWorkerPrivate);
     mWorkerPrivate->AssertIsOnWorkerThread();
     MOZ_ASSERT(mWorkerPrivate->GetJSContext() == aCx);
 
     // Release the Promise and remove the PromiseWorkerProxy from the features of
     // the worker thread since the Promise has been resolved/rejected or the
     // worker thread has been cancelled.
     MOZ_ASSERT(mFeatureAdded);
-    mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
+    mWorkerPrivate->RemoveFeature(this);
     mFeatureAdded = false;
     CleanProperties();
   }
   Release();
 }
 
 JSObject*
 PromiseWorkerProxy::CustomReadHandler(JSContext* aCx,
--- a/dom/workers/DataStore.cpp
+++ b/dom/workers/DataStore.cpp
@@ -906,17 +906,17 @@ DataStoreChangeEventProxy::DataStoreChan
   MOZ_ASSERT(mWorkerStore);
 
   // Let the WorkerDataStore keep the DataStoreChangeEventProxy alive to catch
   // the coming events until the WorkerDataStore is released.
   mWorkerStore->SetDataStoreChangeEventProxy(this);
 
   // We do this to make sure the worker thread won't shut down before the event
   // is dispatched to the WorkerStore on the worker thread.
-  if (!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), this)) {
+  if (!mWorkerPrivate->AddFeature(this)) {
     MOZ_ASSERT(false, "cannot add the worker feature!");
     return;
   }
 }
 
 WorkerPrivate*
 DataStoreChangeEventProxy::GetWorkerPrivate() const
 {
@@ -975,16 +975,16 @@ DataStoreChangeEventProxy::Notify(JSCont
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(mWorkerPrivate->GetJSContext() == aCx);
 
   // Release the WorkerStore and remove the DataStoreChangeEventProxy from the
   // features of the worker thread since the worker thread has been cancelled.
   if (aStatus >= Canceling) {
     mWorkerStore = nullptr;
-    mWorkerPrivate->RemoveFeature(aCx, this);
+    mWorkerPrivate->RemoveFeature(this);
     mCleanedUp = true;
   }
 
   return true;
 }
 
 END_WORKERS_NAMESPACE
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -1892,17 +1892,17 @@ ScriptExecutorRunnable::ShutdownScriptLo
         LogExceptionToConsole(aCx, aWorkerPrivate);
         mScriptLoader.mRv.Throw(NS_ERROR_DOM_NETWORK_ERR);
       }
     } else {
       mScriptLoader.mRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     }
   }
 
-  aWorkerPrivate->RemoveFeature(aCx, &mScriptLoader);
+  aWorkerPrivate->RemoveFeature(&mScriptLoader);
   aWorkerPrivate->StopSyncLoop(mSyncLoopTarget, aResult);
 }
 
 void
 ScriptExecutorRunnable::LogExceptionToConsole(JSContext* aCx,
                                               WorkerPrivate* aWorkerPrivate)
 {
   aWorkerPrivate->AssertIsOnWorkerThread();
@@ -1944,25 +1944,25 @@ LoadAllScripts(JSContext* aCx, WorkerPri
 
   RefPtr<ScriptLoaderRunnable> loader =
     new ScriptLoaderRunnable(aWorkerPrivate, syncLoop.EventTarget(),
                              aLoadInfos, aIsMainScript, aWorkerScriptType,
                              aRv);
 
   NS_ASSERTION(aLoadInfos.IsEmpty(), "Should have swapped!");
 
-  if (!aWorkerPrivate->AddFeature(aCx, loader)) {
+  if (!aWorkerPrivate->AddFeature(loader)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   if (NS_FAILED(NS_DispatchToMainThread(loader))) {
     NS_ERROR("Failed to dispatch!");
 
-    aWorkerPrivate->RemoveFeature(aCx, loader);
+    aWorkerPrivate->RemoveFeature(loader);
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   syncLoop.Run();
 }
 
 } /* anonymous namespace */
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -407,82 +407,81 @@ public:
     aWorkerPrivate->AssertIsOnWorkerThread();
   }
 
   bool
   Init()
   {
     MOZ_ASSERT(mWorkerPrivate);
     mWorkerPrivate->AssertIsOnWorkerThread();
-    JSContext* cx = mWorkerPrivate->GetJSContext();
 
     // We need to listen for worker termination in case the event handler
     // never completes or never resolves the waitUntil promise. There are
     // two possible scenarios:
     // 1. The keepAlive token expires and the worker is terminated, in which
     //    case the registration/update promise will be rejected
     // 2. A new service worker is registered which will terminate the current
     //    installing worker.
-    if (NS_WARN_IF(!mWorkerPrivate->AddFeature(cx, this))) {
+    if (NS_WARN_IF(!mWorkerPrivate->AddFeature(this))) {
       NS_WARNING("LifeCycleEventWatcher failed to add feature.");
-      ReportResult(cx, false);
+      ReportResult(false);
       return false;
     }
 
     return true;
   }
 
   bool
   Notify(JSContext* aCx, Status aStatus) override
   {
     if (aStatus < Terminating) {
       return true;
     }
 
     MOZ_ASSERT(GetCurrentThreadWorkerPrivate() == mWorkerPrivate);
-    ReportResult(aCx, false);
+    ReportResult(false);
 
     return true;
   }
 
   void
-  ReportResult(JSContext* aCx, bool aResult)
+  ReportResult(bool aResult)
   {
     mWorkerPrivate->AssertIsOnWorkerThread();
 
     if (mDone) {
       return;
     }
     mDone = true;
 
     mCallback->SetResult(aResult);
     nsresult rv = NS_DispatchToMainThread(mCallback);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       NS_RUNTIMEABORT("Failed to dispatch life cycle event handler.");
     }
 
-    mWorkerPrivate->RemoveFeature(aCx, this);
+    mWorkerPrivate->RemoveFeature(this);
   }
 
   void
   ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
   {
     MOZ_ASSERT(GetCurrentThreadWorkerPrivate() == mWorkerPrivate);
     mWorkerPrivate->AssertIsOnWorkerThread();
 
-    ReportResult(aCx, true);
+    ReportResult(true);
   }
 
   void
   RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
   {
     MOZ_ASSERT(GetCurrentThreadWorkerPrivate() == mWorkerPrivate);
     mWorkerPrivate->AssertIsOnWorkerThread();
 
-    ReportResult(aCx, false);
+    ReportResult(false);
 
     // Note, all WaitUntil() rejections are reported to client consoles
     // by the WaitUntilHandler in ServiceWorkerEvents.  This ensures that
     // errors in non-lifecycle events like FetchEvent and PushEvent are
     // reported properly.
   }
 };
 
@@ -520,17 +519,17 @@ LifecycleEventWorkerRunnable::DispatchLi
   }
 
   RefPtr<Promise> waitUntil;
   DispatchExtendableEventOnWorkerScope(aCx, aWorkerPrivate->GlobalScope(),
                                        event, getter_AddRefs(waitUntil));
   if (waitUntil) {
     waitUntil->AppendNativeHandler(watcher);
   } else {
-    watcher->ReportResult(aCx, false);
+    watcher->ReportResult(false);
   }
 
   return true;
 }
 
 } // anonymous namespace
 
 nsresult
--- a/dom/workers/ServiceWorkerRegistration.cpp
+++ b/dom/workers/ServiceWorkerRegistration.cpp
@@ -1065,17 +1065,17 @@ void
 ServiceWorkerRegistrationWorkerThread::InitListener()
 {
   MOZ_ASSERT(!mListener);
   WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
   MOZ_ASSERT(worker);
   worker->AssertIsOnWorkerThread();
 
   mListener = new WorkerListener(worker, this);
-  if (!worker->AddFeature(worker->GetJSContext(), this)) {
+  if (!worker->AddFeature(this)) {
     mListener = nullptr;
     NS_WARNING("Could not add feature");
     return;
   }
 
   RefPtr<StartListeningRunnable> r =
     new StartListeningRunnable(mListener);
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(r)));
@@ -1123,17 +1123,17 @@ ServiceWorkerRegistrationWorkerThread::R
   }
 
   // We can assert worker here, because:
   // 1) We always AddFeature, so if the worker has shutdown already, we'll have
   //    received Notify and removed it. If AddFeature had failed, mListener will
   //    be null and we won't reach here.
   // 2) Otherwise, worker is still around even if we are going away.
   mWorkerPrivate->AssertIsOnWorkerThread();
-  mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
+  mWorkerPrivate->RemoveFeature(this);
 
   mListener->ClearRegistration();
 
   if (aReason == RegistrationIsGoingAway) {
     RefPtr<AsyncStopListeningRunnable> r =
       new AsyncStopListeningRunnable(mListener);
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(r)));
   } else if (aReason == WorkerIsGoingAway) {
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -5097,17 +5097,17 @@ WorkerPrivate::RemoveChildWorker(JSConte
   mChildWorkers.RemoveElement(aChildWorker);
 
   if (mChildWorkers.IsEmpty() && !ModifyBusyCountFromWorker(false)) {
     NS_WARNING("Failed to modify busy count!");
   }
 }
 
 bool
-WorkerPrivate::AddFeature(JSContext* aCx, WorkerFeature* aFeature)
+WorkerPrivate::AddFeature(WorkerFeature* aFeature)
 {
   AssertIsOnWorkerThread();
 
   {
     MutexAutoLock lock(mMutex);
 
     if (mStatus >= Canceling) {
       return false;
@@ -5120,17 +5120,17 @@ WorkerPrivate::AddFeature(JSContext* aCx
     return false;
   }
 
   mFeatures.AppendElement(aFeature);
   return true;
 }
 
 void
-WorkerPrivate::RemoveFeature(JSContext* aCx, WorkerFeature* aFeature)
+WorkerPrivate::RemoveFeature(WorkerFeature* aFeature)
 {
   AssertIsOnWorkerThread();
 
   MOZ_ASSERT(mFeatures.Contains(aFeature), "Didn't know about this one!");
   mFeatures.RemoveElement(aFeature);
 
   if (mFeatures.IsEmpty() && !ModifyBusyCountFromWorker(false)) {
     NS_WARNING("Failed to modify busy count!");
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -1066,20 +1066,20 @@ public:
 
   bool
   AddChildWorker(JSContext* aCx, ParentType* aChildWorker);
 
   void
   RemoveChildWorker(JSContext* aCx, ParentType* aChildWorker);
 
   bool
-  AddFeature(JSContext* aCx, WorkerFeature* aFeature);
+  AddFeature(WorkerFeature* aFeature);
 
   void
-  RemoveFeature(JSContext* aCx, WorkerFeature* aFeature);
+  RemoveFeature(WorkerFeature* aFeature);
 
   void
   NotifyFeatures(JSContext* aCx, Status aStatus);
 
   bool
   HasActiveFeatures()
   {
     return !(mChildWorkers.IsEmpty() && mTimeouts.IsEmpty() &&
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1721,19 +1721,17 @@ void
 XMLHttpRequest::MaybePin(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mRooted) {
     return;
   }
 
-  JSContext* cx = GetCurrentThreadJSContext();
-
-  if (!mWorkerPrivate->AddFeature(cx, this)) {
+  if (!mWorkerPrivate->AddFeature(this)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   NS_ADDREF_THIS();
 
   mRooted = true;
 }
@@ -1841,19 +1839,17 @@ XMLHttpRequest::DispatchPrematureAbortEv
 
 void
 XMLHttpRequest::Unpin()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   MOZ_ASSERT(mRooted, "Mismatched calls to Unpin!");
 
-  JSContext* cx = GetCurrentThreadJSContext();
-
-  mWorkerPrivate->RemoveFeature(cx, this);
+  mWorkerPrivate->RemoveFeature(this);
 
   mRooted = false;
 
   NS_RELEASE_THIS();
 }
 
 void
 XMLHttpRequest::SendInternal(SendRunnable* aRunnable,