Merge mozilla-beta to release. a=merge FIREFOX_51_0_BUILD2 FIREFOX_51_0_RELEASE
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 18 Jan 2017 15:36:53 -0500
changeset 465643 ea82b5e20cbbd103f8fa65f0df0386ee4135cc47
parent 465642 aa8b10dca83df22981e98ce094adc7bcfb54101a (current diff)
parent 465434 8e692dd4176cba81ce020b29ae8b352dc1db724a (diff)
child 465644 e293c578e69b52052d892b6338b6a61f61a4ac7f
push id42661
push userfelipc@gmail.com
push dateTue, 24 Jan 2017 16:14:20 +0000
reviewersmerge
milestone51.0
Merge mozilla-beta to release. a=merge
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4519,18 +4519,26 @@ nsDocument::SetScriptGlobalObject(nsIScr
     // clients.  We only do this for content principal documents
     // since we can never observe system or null principals.
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     if (os) {
       os->AddObserver(this, "service-worker-get-client", /* ownsWeak */ false);
     }
   }
 
+  // BlockOnload() might be called before mScriptGlobalObject is set.
+  // We may need to add the blocker once mScriptGlobalObject is set.
+  bool needOnloadBlocker = !mScriptGlobalObject && aScriptGlobalObject;
+
   mScriptGlobalObject = aScriptGlobalObject;
 
+  if (needOnloadBlocker) {
+    EnsureOnloadBlocker();
+  }
+
   if (aScriptGlobalObject) {
     mHasHadScriptHandlingObject = true;
     mHasHadDefaultView = true;
     // Go back to using the docshell for the layout history state
     mLayoutHistoryState = nullptr;
     mScopeObject = do_GetWeakReference(aScriptGlobalObject);
 #ifdef DEBUG
     if (!mWillReparent) {