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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user