зеркало из https://github.com/mozilla/pjs.git
Bug 65993: window.open("") should open a blank browser window, but loads the homepage instead. This should fix a whole bunch of similar complaints about the homepage loading instead of, or right before, the url you wanted from e.g. mail/news. r=jst, r=racham, sr=ben. Many thanks to racham for helping me test my patches.
This commit is contained in:
Родитель
3651df1e28
Коммит
41488538fa
|
@ -270,7 +270,7 @@ PrintUsage(void)
|
||||||
fprintf(stderr, "\t<url>: a fully defined url string like http:// etc..\n");
|
fprintf(stderr, "\t<url>: a fully defined url string like http:// etc..\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsresult OpenWindow(const char *urlstr, const PRUnichar *args)
|
static nsresult OpenWindow(const char *urlstr, const PRUnichar *args, const char *aFeatures=0)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CMD_LINE
|
#ifdef DEBUG_CMD_LINE
|
||||||
printf("OpenWindow(%s,?)\n",urlstr);
|
printf("OpenWindow(%s,?)\n",urlstr);
|
||||||
|
@ -283,10 +283,19 @@ static nsresult OpenWindow(const char *urlstr, const PRUnichar *args)
|
||||||
|
|
||||||
sarg->SetData(args);
|
sarg->SetData(args);
|
||||||
|
|
||||||
|
nsCAutoString features("chrome,dialog=no,all");
|
||||||
|
if (aFeatures) {
|
||||||
|
features.Append(",");
|
||||||
|
features.Append(aFeatures);
|
||||||
|
}
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("features: %s...\n", features.get());
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
rv = wwatch->OpenWindow(0, urlstr, "_blank",
|
rv = wwatch->OpenWindow(0, urlstr, "_blank",
|
||||||
"chrome,dialog=no,all", sarg,
|
features.get(), sarg,
|
||||||
getter_AddRefs(newWindow));
|
getter_AddRefs(newWindow));
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -679,9 +688,37 @@ static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width)
|
||||||
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
rv = OpenChromeURL(chromeUrlForTask, height, width);
|
nsCOMPtr <nsICmdLineService> cmdLine = do_GetService("@mozilla.org/appshell/commandLineService;1", &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
nsXPIDLCString urlToLoad;
|
||||||
|
rv = cmdLine->GetURLToLoad(getter_Copies(urlToLoad));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
nsCAutoString features;
|
||||||
|
features.Assign("height=");
|
||||||
|
features.AppendInt(height);
|
||||||
|
features.Append(",width=");
|
||||||
|
features.AppendInt(width);
|
||||||
|
|
||||||
|
if (!urlToLoad.IsEmpty()) {
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("url to load: %s\n", urlToLoad.get());
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
|
||||||
|
NS_ConvertUTF8toUCS2 url(urlToLoad);
|
||||||
|
rv = OpenWindow(chromeUrlForTask, url.get(), features.get());
|
||||||
|
} else {
|
||||||
|
nsXPIDLString defaultArgs;
|
||||||
|
rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("default args: %s\n", NS_ConvertUCS2toUTF8(defaultArgs).get());
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
rv = OpenWindow(chromeUrlForTask, defaultArgs.get(), features.get());
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,28 +316,6 @@ function Startup()
|
||||||
if ("arguments" in window && window.arguments.length >= 1 && window.arguments[0])
|
if ("arguments" in window && window.arguments.length >= 1 && window.arguments[0])
|
||||||
uriToLoad = window.arguments[0];
|
uriToLoad = window.arguments[0];
|
||||||
|
|
||||||
if (!turboMode) {
|
|
||||||
var cmdLineService =
|
|
||||||
Components.classes["@mozilla.org/appshell/commandLineService;1"]
|
|
||||||
.getService(Components.interfaces.nsICmdLineService);
|
|
||||||
var cmdLineUrl = cmdLineService.URLToLoad;
|
|
||||||
|
|
||||||
// try the command line first
|
|
||||||
if (cmdLineUrl && !appCore.cmdLineURLUsed) {
|
|
||||||
uriToLoad = cmdLineUrl;
|
|
||||||
appCore.cmdLineURLUsed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ok, no command line, try the default args
|
|
||||||
if (!uriToLoad) {
|
|
||||||
var cmdLineHandler =
|
|
||||||
Components.classes["@mozilla.org/commandlinehandler/general-startup;1?type=browser"]
|
|
||||||
.getService(Components.interfaces.nsICmdLineHandler);
|
|
||||||
uriToLoad = cmdLineHandler.defaultArgs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (uriToLoad && uriToLoad != "about:blank") {
|
if (uriToLoad && uriToLoad != "about:blank") {
|
||||||
gURLBar.value = uriToLoad;
|
gURLBar.value = uriToLoad;
|
||||||
loadURI(uriToLoad);
|
loadURI(uriToLoad);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче