Bug 1268849 Don't crash in GetServiceWorkersTestingEnabled if window is torn down and GetScriptableTop() returns nullptr. r=bz
authorBen Kelly <ben@wanderview.com>
Fri, 29 Apr 2016 17:23:02 -0700
changeset 358105 f3a5c8b5e17073a1e68f079da93f8dbe10e454a9
parent 358104 5e1a999558939aa410044b86a4437d1485c0112b
child 358106 b622cbd9ba13d01abcb1d04684dcb39c22a08590
push id16941
push userbmo:jbeich@FreeBSD.org
push dateSun, 01 May 2016 11:16:34 +0000
reviewersbz
bugs1268849
milestone49.0a1
Bug 1268849 Don't crash in GetServiceWorkersTestingEnabled if window is torn down and GetScriptableTop() returns nullptr. r=bz
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3974,16 +3974,19 @@ nsPIDOMWindowOuter::SetServiceWorkersTes
 }
 
 bool
 nsPIDOMWindowOuter::GetServiceWorkersTestingEnabled()
 {
   // Automatically get this setting from the top level window so that nested
   // iframes get the correct devtools setting.
   nsCOMPtr<nsPIDOMWindowOuter> topWindow = GetScriptableTop();
+  if (!topWindow) {
+    return false;
+  }
   return topWindow->mServiceWorkersTestingEnabled;
 }
 
 bool
 nsPIDOMWindowInner::GetAudioCaptured() const
 {
   MOZ_ASSERT(IsInnerWindow());
   return mAudioCaptured;