Bug 1031074 - Don't unblock scripts if we never blocked them. r=gabor
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 30 Jun 2014 16:30:13 -0700
changeset 191632 f00ebb996486218b60f198d6fd6f1b419bc009c9
parent 191631 3fa5aac520f67263986d6ae11d3b0da2c28e775f
child 191633 d774d2c87e78660c41dba7dc0710ffabec49a549
push id27055
push usercbook@mozilla.com
push dateTue, 01 Jul 2014 12:01:46 +0000
treeherdermozilla-central@4a9353b5762d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1031074
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1031074 - Don't unblock scripts if we never blocked them. r=gabor
content/base/src/ImportManager.cpp
content/base/src/ImportManager.h
--- a/content/base/src/ImportManager.cpp
+++ b/content/base/src/ImportManager.cpp
@@ -19,33 +19,35 @@
 #include "nsIDOMEvent.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsScriptLoader.h"
 #include "nsNetUtil.h"
 
 class AutoError {
 public:
-  AutoError(mozilla::dom::ImportLoader* loader)
+  AutoError(mozilla::dom::ImportLoader* loader, bool scriptsBlocked = true)
     : mLoader(loader)
     , mPassed(false)
+    , mScriptsBlocked(scriptsBlocked)
   {}
 
   ~AutoError()
   {
     if (!mPassed) {
-      mLoader->Error();
+      mLoader->Error(mScriptsBlocked);
     }
   }
 
   void Pass() { mPassed = true; }
 
 private:
   mozilla::dom::ImportLoader* mLoader;
   bool mPassed;
+  bool mScriptsBlocked;
 };
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN(ImportLoader)
   NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
   NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
@@ -159,41 +161,44 @@ ImportLoader::Done()
   for (uint32_t i = 0; i < count; i++) {
     DispatchLoadEvent(mLinks[i]);
   }
   UnblockScripts();
   ReleaseResources();
 }
 
 void
-ImportLoader::Error()
+ImportLoader::Error(bool aUnblockScripts)
 {
   mDocument = nullptr;
   mStopped = true;
   uint32_t count = mLinks.Count();
   for (uint32_t i = 0; i < count; i++) {
     DispatchErrorEvent(mLinks[i]);
   }
-  UnblockScripts();
+  if (aUnblockScripts) {
+    UnblockScripts();
+  }
+
   ReleaseResources();
 }
 
 // Release all the resources we don't need after there is no more
 // data available on the channel, and the parser is done.
 void ImportLoader::ReleaseResources()
 {
   mParserStreamListener = nullptr;
   mChannel = nullptr;
   mImportParent = nullptr;
 }
 
 void
 ImportLoader::Open()
 {
-  AutoError ae(this);
+  AutoError ae(this, false);
   // Imports should obey to the master documents CSP.
   nsCOMPtr<nsIDocument> master = mImportParent->MasterDocument();
   nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(master);
   nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
   int16_t shouldLoad = nsIContentPolicy::ACCEPT;
   nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_SCRIPT,
                                           mURI,
                                           principal,
--- a/content/base/src/ImportManager.h
+++ b/content/base/src/ImportManager.h
@@ -95,17 +95,17 @@ private:
   // the right event.
   void DispatchEventIfFinished(nsINode* aNode);
 
   // Dispatch event for a single referrer LinkElement.
   void DispatchErrorEvent(nsINode* aNode);
   void DispatchLoadEvent(nsINode* aNode);
 
   // Must be called when an error has occured during load.
-  void Error();
+  void Error(bool aUnblockScripts);
 
   // Must be called when the import document has been loaded successfully.
   void Done();
 
   // When the reading from the channel and the parsing
   // of the document is done, we can release the resources
   // that we don't need any longer to hold on.
   void ReleaseResources();