Bug 1260439 - workerdebuggersandbox_moved needs to update the wrappercache. r=bz, a=al
authorEddy Bruel <ejpbruel@mozilla.com>
Thu, 31 Mar 2016 08:48:47 +0200
changeset 325794 6e8c76e38e0522e0cde432c8ecccfab501018204
parent 325793 14e52344932f82bc77c75be85a610b9055a9fd45
child 325795 71cedf188b34d56d1e7e98ad3bfa93d7819eba4a
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, al
bugs1260439
milestone47.0a2
Bug 1260439 - workerdebuggersandbox_moved needs to update the wrappercache. r=bz, a=al
dom/workers/WorkerScope.cpp
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -765,24 +765,27 @@ workerdebuggersandbox_resolve(JSContext 
                               JS::Handle<jsid> id, bool *resolvedp)
 {
   return JS_ResolveStandardClass(cx, obj, id, resolvedp);
 }
 
 static void
 workerdebuggersandbox_finalize(js::FreeOp *fop, JSObject *obj)
 {
-  nsIGlobalObject *globalObject =
-    static_cast<nsIGlobalObject *>(JS_GetPrivate(obj));
-  NS_RELEASE(globalObject);
+  WorkerDebuggerSandboxPrivate *sandboxPrivate =
+    static_cast<WorkerDebuggerSandboxPrivate *>(JS_GetPrivate(obj));
+  NS_RELEASE(sandboxPrivate);
 }
 
 static void
 workerdebuggersandbox_moved(JSObject *obj, const JSObject *old)
 {
+  WorkerDebuggerSandboxPrivate *sandboxPrivate =
+    static_cast<WorkerDebuggerSandboxPrivate *>(JS_GetPrivate(obj));
+  sandboxPrivate->UpdateWrapper(obj, old);
 }
 
 const js::Class workerdebuggersandbox_class = {
     "workerdebuggersandbox",
     JSCLASS_GLOBAL_FLAGS | JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
     nullptr,
     nullptr,
     nullptr,
@@ -832,21 +835,21 @@ WorkerDebuggerGlobalScope::CreateSandbox
     }
 
     if (!JS_SetPrototype(aCx, sandbox, prototype)) {
       JS_ReportError(aCx, "Can't set sandbox prototype!");
       aResult.set(nullptr);
       return;
     }
 
-    nsCOMPtr<nsIGlobalObject> globalObject =
+    RefPtr<WorkerDebuggerSandboxPrivate> sandboxPrivate =
       new WorkerDebuggerSandboxPrivate(sandbox);
 
-    // Pass on ownership of globalObject to |sandbox|.
-    JS_SetPrivate(sandbox, globalObject.forget().take());
+    // Pass on ownership of sandboxPrivate to |sandbox|.
+    JS_SetPrivate(sandbox, sandboxPrivate.forget().take());
   }
 
   JS_FireOnNewGlobalObject(aCx, sandbox);
 
   if (!JS_WrapObject(aCx, &sandbox)) {
     JS_ReportError(aCx, "Can't wrap sandbox!");
     aResult.set(nullptr);
     return;
@@ -940,17 +943,17 @@ GetGlobalObjectForGlobal(JSObject* globa
   nsIGlobalObject* globalObject = nullptr;
   UNWRAP_WORKER_OBJECT(WorkerGlobalScope, global, globalObject);
 
   if (!globalObject) {
     UNWRAP_OBJECT(WorkerDebuggerGlobalScope, global, globalObject);
 
     if (!globalObject) {
       MOZ_ASSERT(IsDebuggerSandbox(global));
-      globalObject = static_cast<nsIGlobalObject *>(JS_GetPrivate(global));
+      globalObject = static_cast<WorkerDebuggerSandboxPrivate*>(JS_GetPrivate(global));
 
       MOZ_ASSERT(globalObject);
     }
   }
 
   return globalObject;
 }