** checking in for mstoltz **

Disable scripts on the requested docshell and containing docshells. Also, made setCurrentURI() scriptable ( approved by Adam Lock ). b=154647, r=harishd, sr=jst
This commit is contained in:
harishd%netscape.com 2002-06-27 20:58:42 +00:00
parent 9b33dcc62e
commit 5ce8f55dd0
2 changed files with 24 additions and 7 deletions

View File

@ -1369,7 +1369,7 @@ nsScriptSecurityManager::GetRootDocShell(JSContext *cx, nsIDocShell **result)
if (!scriptContext) return NS_ERROR_FAILURE;
nsCOMPtr<nsIScriptGlobalObject> globalObject;
scriptContext->GetGlobalObject(getter_AddRefs(globalObject));
if (!globalObject) return NS_ERROR_FAILURE;
if (!globalObject) return NS_ERROR_FAILURE;
rv = globalObject->GetDocShell(getter_AddRefs(docshell));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDocShellTreeItem> docshellTreeItem(do_QueryInterface(docshell, &rv));
@ -1415,15 +1415,32 @@ nsScriptSecurityManager::CanExecuteScripts(JSContext* cx,
}
//-- See if the current window allows JS execution
nsCOMPtr<nsIScriptContext> scriptContext = (nsIScriptContext*)JS_GetContextPrivate(cx);
if (!scriptContext) return NS_ERROR_FAILURE;
nsCOMPtr<nsIScriptGlobalObject> globalObject;
scriptContext->GetGlobalObject(getter_AddRefs(globalObject));
if (!globalObject) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShell> docshell;
rv = GetRootDocShell(cx, getter_AddRefs(docshell));
if (NS_SUCCEEDED(rv))
{
rv = globalObject->GetDocShell(getter_AddRefs(docshell));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(docshell));
if (!treeItem) return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDocShellTreeItem> parentItem;
// Walk up the docshell tree to see if any containing docshell disallows scripts
do {
rv = docshell->GetAllowJavascript(result);
if (NS_FAILED(rv)) return rv;
if (!*result)
return NS_OK;
}
return NS_OK; // Do not run scripts
rv = treeItem->GetParent(getter_AddRefs(parentItem));
if (NS_FAILED(rv)) return rv;
if (parentItem)
{
treeItem = parentItem;
docshell = do_QueryInterface(treeItem, &rv);
if (NS_FAILED(rv)) return rv;
}
} while (parentItem);
//-- See if JS is disabled globally (via prefs)
*result = mIsJavaScriptEnabled;

View File

@ -145,7 +145,7 @@ interface nsIDocShell : nsISupports
* document. Note if you want to get the current URI, use the read-only
* property on nsIWebNavigation.
*/
[noscript] void setCurrentURI(in nsIURI aURI);
void setCurrentURI(in nsIURI aURI);
/**
* Notify the associated content viewer and all child docshells that they are