explicitly skip URL load if no URL param was specified in window.open. fixes bug 20757. similar to rev 1.200 (backed out in 1.201), though something went wrong with that one. not sure what. this one tests well. patch submitted by bissiri@eecs.umich.edu. r:me

This commit is contained in:
danm%netscape.com 2000-01-11 22:52:04 +00:00
Родитель 4be3dc2230
Коммит 5d32515178
1 изменённых файлов: 38 добавлений и 23 удалений

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

@ -2207,21 +2207,29 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
char* options;
*aReturn = nsnull;
PRBool nameSpecified = PR_FALSE;
PRBool loadURL = PR_TRUE;
if (argc > 0) {
if (argc == 0) {
loadURL = PR_FALSE;
} else if (argc > 0) {
JSString *mJSStrURL = JS_ValueToString(cx, argv[0]);
if (nsnull == mJSStrURL) {
return NS_ERROR_FAILURE;
}
if (mDocument) {
nsAutoString mURL;
mURL.SetString(JS_GetStringChars(mJSStrURL));
if (mURL.Equals("")) {
loadURL = PR_FALSE;
} else {
if (mDocument) {
// Build absolute URL relative to this document.
nsAutoString mURL, mEmpty;
nsIURI* mDocURL = 0;
nsIDocument* mDoc;
mURL.SetString(JS_GetStringChars(mJSStrURL));
if (NS_OK == mDocument->QueryInterface(kIDocumentIID, (void**)&mDoc)) {
mDocURL = mDoc->GetDocumentURL();
NS_RELEASE(mDoc);
@ -2233,15 +2241,16 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
rv = NS_MakeAbsoluteURI(mURL, baseUri, mAbsURL);
NS_RELEASE(baseUri);
} else {
} else {
// No document. Probably because this window's URL hasn't finished
// loading. All we can do is hope the URL we've been given is absolute.
mAbsURL.SetString(JS_GetStringChars(mJSStrURL));
nsCOMPtr<nsIURI> test;
// Make URI; if mAbsURL is relative (or otherwise bogus) this will fail.
rv = NS_NewURI( getter_AddRefs(test), mAbsURL );
}
if (NS_FAILED(rv)) return rv;
}
if (NS_FAILED(rv)) return rv;
}
/* Sanity-check the optional window_name argument. */
@ -2304,22 +2313,24 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
if (aDialog && argc > 3)
AttachArguments(*aReturn, argv+3, argc-3);
// Get security manager, check to see if URI is allowed.
nsCOMPtr<nsIURI> newUrl;
nsCOMPtr<nsIScriptSecurityManager> secMan;
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetStaticScriptContext(cx, (JSObject*) mScriptObject,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(scriptCX->GetSecurityManager(getter_AddRefs(secMan))) ||
NS_FAILED(NS_NewURI(getter_AddRefs(newUrl), mAbsURL)) ||
NS_FAILED(secMan->CheckLoadURIFromScript(cx, newUrl)))
{
NS_RELEASE(newOuterShell);
NS_RELEASE(webShellContainer);
return NS_ERROR_FAILURE;
if (loadURL) {
// Get security manager, check to see if URI is allowed.
nsCOMPtr<nsIURI> newUrl;
nsCOMPtr<nsIScriptSecurityManager> secMan;
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetStaticScriptContext(cx, (JSObject*) mScriptObject,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(scriptCX->GetSecurityManager(getter_AddRefs(secMan))) ||
NS_FAILED(NS_NewURI(getter_AddRefs(newUrl), mAbsURL)) ||
NS_FAILED(secMan->CheckLoadURIFromScript(cx, newUrl)))
{
NS_RELEASE(newOuterShell);
NS_RELEASE(webShellContainer);
return NS_ERROR_FAILURE;
}
}
nsCOMPtr<nsIDocShellTreeItem> newShellAsItem(do_QueryInterface(newOuterShell));
NS_ASSERTION(newShellAsItem, "We got a shell that isn't an item!");
if (nameSpecified) {
@ -2328,7 +2339,11 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
else {
newShellAsItem->SetName(nsnull);
}
newOuterShell->LoadURL(mAbsURL.GetUnicode());
if (loadURL) {
newOuterShell->LoadURL(mAbsURL.GetUnicode());
}
SizeAndShowOpenedWebShell(newOuterShell, options, windowIsNew, aDialog);
if (windowIsModal) {
nsIBrowserWindow *newWindow;