Block scripts in subframes if the parent has script blocked in the

scriptloader.  Fixes bug 383331, r+sr+a=sicking


git-svn-id: svn://10.0.0.236/trunk@236846 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2007-09-28 15:15:07 +00:00
parent a44d56281c
commit 7206991ea7
2 changed files with 54 additions and 2 deletions

View File

@@ -171,6 +171,12 @@ nsScriptLoader::~nsScriptLoader()
for (PRInt32 i = 0; i < mPendingRequests.Count(); i++) {
mPendingRequests[i]->FireScriptAvailable(NS_ERROR_ABORT);
}
// Unblock the kids, in case any of them moved to a different document
// subtree in the meantime and therefore aren't actually going away.
for (PRUint32 j = 0; j < mPendingChildLoaders.Length(); ++j) {
mPendingChildLoaders[j]->RemoveExecuteBlocker();
}
}
NS_IMPL_ISUPPORTS1(nsScriptLoader, nsIStreamLoaderObserver)
@@ -636,7 +642,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
void
nsScriptLoader::ProcessPendingRequestsAsync()
{
if (mPendingRequests.Count()) {
if (mPendingRequests.Count() || !mPendingChildLoaders.IsEmpty()) {
nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsScriptLoader>(this,
&nsScriptLoader::ProcessPendingRequests);
@@ -653,6 +659,33 @@ nsScriptLoader::ProcessPendingRequests()
mPendingRequests.RemoveObjectAt(0);
ProcessRequest(request);
}
while (ReadyToExecuteScripts() && !mPendingChildLoaders.IsEmpty()) {
nsRefPtr<nsScriptLoader> child = mPendingChildLoaders[0];
mPendingChildLoaders.RemoveElementAt(0);
child->RemoveExecuteBlocker();
}
}
PRBool
nsScriptLoader::ReadyToExecuteScripts()
{
// Make sure the SelfReadyToExecuteScripts check is first, so that
// we don't block twice on an ancestor.
if (!SelfReadyToExecuteScripts()) {
return PR_FALSE;
}
for (nsIDocument* doc = mDocument; doc; doc = doc->GetParentDocument()) {
nsScriptLoader* ancestor = doc->ScriptLoader();
if (!ancestor->SelfReadyToExecuteScripts() &&
ancestor->AddPendingChildLoader(this)) {
AddExecuteBlocker();
return PR_FALSE;
}
}
return PR_TRUE;
}