Bug 1260439 - workerdebuggersandbox_moved needs to update the wrappercache;r=bz
authorEddy Bruel <ejpbruel@mozilla.com>
Thu, 31 Mar 2016 08:48:47 +0200
changeset 291197 50ab25f4ea759f2910bb9a0ba942c963c8de05d7
parent 291196 f71f7068c9f0de5d9a006c67c4d1e397dc3b0b0b
child 291198 2579ddeadeb1574d16c4f3efc489f45b4c8ac439
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1260439
milestone48.0a1
Bug 1260439 - workerdebuggersandbox_moved needs to update the wrappercache;r=bz
dom/workers/WorkerScope.cpp
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -774,24 +774,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,
@@ -841,21 +844,21 @@ WorkerDebuggerGlobalScope::CreateSandbox
       return;
     }
 
     if (!JS_SetPrototype(aCx, sandbox, prototype)) {
       aRv.NoteJSContextException(aCx);
       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)) {
     aRv.NoteJSContextException(aCx);
     return;
   }
@@ -992,17 +995,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;
 }