Bug 1030707 - Part 2: Replace AutoPushJSContext in DataStoreAddRunnable::MainThreadRun. r=bholley
authorBob Owen <bobowencode@gmail.com>
Mon, 30 Jun 2014 16:05:22 +0100
changeset 191912 2bceb1dd6129d932064637fd85b752aa3baa6c74
parent 191911 6eb721c3b80f8000be5c0142f26cde190fb3d363
child 191913 bdcaaf2af7bbbcabfac5ba06c16bc4931674ac58
push id45691
push userryanvm@gmail.com
push dateWed, 02 Jul 2014 15:14:27 +0000
treeherdermozilla-inbound@4b66860fde6d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1030707
milestone33.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 1030707 - Part 2: Replace AutoPushJSContext in DataStoreAddRunnable::MainThreadRun. r=bholley
dom/workers/DataStore.cpp
--- a/dom/workers/DataStore.cpp
+++ b/dom/workers/DataStore.cpp
@@ -280,26 +280,23 @@ public:
   }
 
 protected:
   virtual bool
   MainThreadRun() MOZ_OVERRIDE
   {
     AssertIsOnMainThread();
 
-    // Get the JSContext for the target window
-    nsCOMPtr<nsIScriptGlobalObject> sgo =
-      do_QueryInterface(static_cast<DOMEventTargetHelper*>
-                        (mBackingStore.get())->GetOwner());
-    MOZ_ASSERT(sgo);
-
-    nsCOMPtr<nsIScriptContext> scriptContext = sgo->GetContext();
-    AutoPushJSContext cx(scriptContext ? scriptContext->GetNativeContext()
-                                       : nsContentUtils::GetSafeJSContext());
-    MOZ_ASSERT(cx);
+    // Initialise an AutoJSAPI with the target window.
+    AutoJSAPI jsapi;
+    if (NS_WARN_IF(!jsapi.Init(mBackingStore->GetParentObject()))) {
+      mRv.Throw(NS_ERROR_UNEXPECTED);
+      return true;
+    }
+    JSContext* cx = jsapi.cx();
 
     JS::Rooted<JS::Value> value(cx);
     if (!mObjBuffer.read(cx, &value)) {
       JS_ClearPendingException(cx);
       mRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
       return true;
     }