Bug 897399: handle the inner window disappearing after beforescriptexecute without crashing, r=sicking, a=akeybl
authorGavin Sharp <gavin@gavinsharp.com>
Fri, 02 Aug 2013 10:55:50 -0700
changeset 153810 29075d7c93cf72000e8a8726f23e0687564b4a51
parent 153809 9ab56e74f6b6aa19ec36db26cdcc3eaef601ce70
child 153811 2be44fda75525c10b3633c0d925bfc876a841c9e
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, akeybl
bugs897399
milestone25.0a2
Bug 897399: handle the inner window disappearing after beforescriptexecute without crashing, r=sicking, a=akeybl
content/base/src/nsScriptLoader.cpp
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -734,16 +734,22 @@ nsScriptLoader::ProcessRequest(nsScriptL
   bool runScript = !!pwin;
   if (runScript) {
     nsContentUtils::DispatchTrustedEvent(scriptElem->OwnerDoc(),
                                          scriptElem,
                                          NS_LITERAL_STRING("beforescriptexecute"),
                                          true, true, &runScript);
   }
 
+  // Inner window could have gone away after firing beforescriptexecute
+  pwin = mDocument->GetInnerWindow();
+  if (!pwin) {
+    runScript = false;
+  }
+
   nsresult rv = NS_OK;
   if (runScript) {
     if (doc) {
       doc->BeginEvaluatingExternalScript();
     }
     aRequest->mElement->BeginEvaluating();
     rv = EvaluateScript(aRequest, *script);
     aRequest->mElement->EndEvaluating();