Bug 223816 - find function in midas window not working, NS_ERROR_DOM_BAD_URI error. r+sr=bzbarsky

This commit is contained in:
martijn.martijn%gmail.com 2006-04-21 20:16:27 +00:00
Родитель 8cde2f4313
Коммит f207e836f4
1 изменённых файлов: 20 добавлений и 7 удалений

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

@ -732,14 +732,27 @@ nsresult nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow,
nsCOMPtr<nsIDocument> theDoc = do_QueryInterface(domDoc);
if (!theDoc) return NS_ERROR_FAILURE;
nsIURI *docURI = theDoc->GetDocumentURI();
NS_ENSURE_TRUE(docURI, NS_ERROR_FAILURE);
// Get the security manager and do the same-origin check
nsCOMPtr<nsIScriptSecurityManager> secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = secMan->CheckSameOrigin(nsnull, docURI);
if (NS_FAILED(rv)) return rv;
PRBool hasCap = PR_FALSE;
secMan->IsCapabilityEnabled("UniversalBrowserWrite", &hasCap);
if (!hasCap)
secMan->IsCapabilityEnabled("UniversalXPConnect", &hasCap);
if (!hasCap) {
nsIPrincipal *principal = theDoc->GetNodePrincipal();
if (!principal)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrincipal> subject;
rv = secMan->GetSubjectPrincipal(getter_AddRefs(subject));
NS_ENSURE_SUCCESS(rv, rv);
if (subject) {
rv = secMan->CheckSameOriginPrincipal(subject, principal);
NS_ENSURE_SUCCESS(rv, rv);
}
}
if (!mFind) {
mFind = do_CreateInstance(NS_FIND_CONTRACTID, &rv);