Bug 1259338 Ensure that AllowWindowInteractionHandler is released on worker thread. r=khuey a=ritu
authorBen Kelly <ben@wanderview.com>
Thu, 14 Apr 2016 07:10:08 -0700
changeset 323941 067c944ee1e26bcc93f30dd1007741008814b05f
parent 323940 589bd8060a90ac2022b7f6dee222cbc4bfc34aa7
child 323942 7bb53c007a2ecde84e470b86ee3ec39fccea9518
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, ritu
bugs1259338
milestone47.0a2
Bug 1259338 Ensure that AllowWindowInteractionHandler is released on worker thread. r=khuey a=ritu
dom/workers/ServiceWorkerPrivate.cpp
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -733,16 +733,25 @@ private:
   PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
   {
     // Silence bad assertions.
   }
 
   bool
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override;
 
+  NS_IMETHOD
+  Cancel() override
+  {
+    // Always ensure the handler is released on the worker thread, even if we
+    // are cancelled.
+    mHandler = nullptr;
+    return WorkerRunnable::Cancel();
+  }
+
   RefPtr<AllowWindowInteractionHandler> mHandler;
 };
 
 class AllowWindowInteractionHandler final : public PromiseNativeHandler
 {
   friend class ClearWindowAllowedRunnable;
   nsCOMPtr<nsITimer> mTimer;
 
@@ -843,16 +852,17 @@ public:
 };
 
 NS_IMPL_ISUPPORTS0(AllowWindowInteractionHandler)
 
 bool
 ClearWindowAllowedRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
 {
   mHandler->ClearWindowAllowed(aWorkerPrivate);
+  mHandler = nullptr;
   return true;
 }
 
 class SendNotificationClickEventRunnable final : public ExtendableEventWorkerRunnable
 {
   const nsString mID;
   const nsString mTitle;
   const nsString mDir;