Bug 1031074 - Don't unblock scripts if we never blocked them. r=gabor

This commit is contained in:
Blake Kaplan 2014-06-30 16:30:13 -07:00
Родитель 9a2a8959f1
Коммит edc87ef0c9
2 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -24,15 +24,16 @@
class AutoError { class AutoError {
public: public:
AutoError(mozilla::dom::ImportLoader* loader) AutoError(mozilla::dom::ImportLoader* loader, bool scriptsBlocked = true)
: mLoader(loader) : mLoader(loader)
, mPassed(false) , mPassed(false)
, mScriptsBlocked(scriptsBlocked)
{} {}
~AutoError() ~AutoError()
{ {
if (!mPassed) { if (!mPassed) {
mLoader->Error(); mLoader->Error(mScriptsBlocked);
} }
} }
@ -41,6 +42,7 @@ public:
private: private:
mozilla::dom::ImportLoader* mLoader; mozilla::dom::ImportLoader* mLoader;
bool mPassed; bool mPassed;
bool mScriptsBlocked;
}; };
namespace mozilla { namespace mozilla {
@ -164,7 +166,7 @@ ImportLoader::Done()
} }
void void
ImportLoader::Error() ImportLoader::Error(bool aUnblockScripts)
{ {
mDocument = nullptr; mDocument = nullptr;
mStopped = true; mStopped = true;
@ -172,7 +174,10 @@ ImportLoader::Error()
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
DispatchErrorEvent(mLinks[i]); DispatchErrorEvent(mLinks[i]);
} }
UnblockScripts(); if (aUnblockScripts) {
UnblockScripts();
}
ReleaseResources(); ReleaseResources();
} }
@ -188,7 +193,7 @@ void ImportLoader::ReleaseResources()
void void
ImportLoader::Open() ImportLoader::Open()
{ {
AutoError ae(this); AutoError ae(this, false);
// Imports should obey to the master documents CSP. // Imports should obey to the master documents CSP.
nsCOMPtr<nsIDocument> master = mImportParent->MasterDocument(); nsCOMPtr<nsIDocument> master = mImportParent->MasterDocument();
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(master); nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(master);

Просмотреть файл

@ -100,7 +100,7 @@ private:
void DispatchLoadEvent(nsINode* aNode); void DispatchLoadEvent(nsINode* aNode);
// Must be called when an error has occured during load. // 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. // Must be called when the import document has been loaded successfully.
void Done(); void Done();