Bug 1451172 - Fallback to current global in FindAssociatedGlobal when nsIGlobalObject doesn't have JS object anymore. r=bz, a=RyanVM
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 08 Aug 2018 09:07:47 +0300
changeset 480867 a1f21507bec348ffe61f5711f739e9ccc21cf1d9
parent 480866 8c8be6dfdacc6d5a4c73bc7ccfa3a0e5548c89d2
child 480868 00a7708e3cff57b85e8794916235fe65e16e6e34
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, RyanVM
bugs1451172
milestone62.0
Bug 1451172 - Fallback to current global in FindAssociatedGlobal when nsIGlobalObject doesn't have JS object anymore. r=bz, a=RyanVM
dom/bindings/BindingUtils.h
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -1699,17 +1699,19 @@ inline JSObject*
 FindAssociatedGlobal(JSContext* cx, nsIGlobalObject* const& p)
 {
   if (!p) {
     return JS::CurrentGlobalOrNull(cx);
   }
 
   JSObject* global = p->GetGlobalJSObject();
   if (!global) {
-    return nullptr;
+    // nsIGlobalObject doesn't have a JS object anymore,
+    // fallback to the current global.
+    return JS::CurrentGlobalOrNull(cx);
   }
 
   MOZ_ASSERT(JS_IsGlobalObject(global));
   // This object could be gray if the nsIGlobalObject is the only thing keeping
   // it alive.
   JS::ExposeObjectToActiveJS(global);
   return global;
 }