mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 502239 - fix focusElement() misuse. r=enn
This commit is contained in:
parent
37602b8380
commit
1e32437863
@ -1211,9 +1211,9 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
||||
window.addEventListener("fullscreen", onFullScreen, true);
|
||||
|
||||
if (isLoadingBlank && gURLBar && isElementVisible(gURLBar))
|
||||
focusElement(gURLBar);
|
||||
gURLBar.focus();
|
||||
else
|
||||
focusElement(content);
|
||||
gBrowser.selectedBrowser.focus();
|
||||
|
||||
if (gURLBar)
|
||||
gURLBar.emptyText = gURLBarEmptyText.value;
|
||||
|
@ -132,7 +132,7 @@
|
||||
else
|
||||
loadURI(url, null, postData, true /* allow third party fixup */);
|
||||
|
||||
focusElement(content);
|
||||
gBrowser.selectedBrowser.focus();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -95,16 +95,29 @@ function getBoolPref ( prefname, def )
|
||||
// window itself.
|
||||
function focusElement(aElement)
|
||||
{
|
||||
var msg;
|
||||
|
||||
// if a content window, focus the <browser> instead as window.focus()
|
||||
// raises the window
|
||||
if (aElement instanceof Window) {
|
||||
var browser = getBrowserFromContentWindow(aElement);
|
||||
if (browser)
|
||||
browser.focus();
|
||||
if (!browser)
|
||||
throw "aElement is not a content window";
|
||||
browser.focus();
|
||||
msg = "focusElement(content) is deprecated. Use gBrowser.selectedBrowser.focus() instead.";
|
||||
}
|
||||
else {
|
||||
aElement.focus();
|
||||
msg = "focusElement(element) is deprecated. Use element.focus() instead.";
|
||||
}
|
||||
|
||||
var scriptError = Components.classes["@mozilla.org/scripterror;1"]
|
||||
.createInstance(Components.interfaces.nsIScriptError);
|
||||
scriptError.init(msg, document.location.href, null, null,
|
||||
null, scriptError.warningFlag, "chrome javascript");
|
||||
Components.classes["@mozilla.org/consoleservice;1"]
|
||||
.getService(Components.interfaces.nsIConsoleService)
|
||||
.logMessage(scriptError);
|
||||
}
|
||||
|
||||
// openUILink handles clicks on UI elements that cause URLs to load.
|
||||
@ -253,14 +266,10 @@ function openUILinkIn( url, where, allowThirdPartyFixup, postData, referrerUrl )
|
||||
// resulted in a new frontmost window (e.g. "javascript:window.open('');").
|
||||
var fm = Components.classes["@mozilla.org/focus-manager;1"].
|
||||
getService(Components.interfaces.nsIFocusManager);
|
||||
if (window == fm.activeWindow) {
|
||||
if (window == fm.activeWindow)
|
||||
w.content.focus();
|
||||
}
|
||||
else {
|
||||
let browser = w.getBrowserFromContentWindow(w.content);
|
||||
if (browser)
|
||||
browser.focus();
|
||||
}
|
||||
else
|
||||
w.gBrowser.selectedBrowser.focus();
|
||||
}
|
||||
|
||||
// Used as an onclick handler for UI elements with link-like behavior.
|
||||
|
@ -116,7 +116,7 @@
|
||||
|
||||
// Focus the location bar
|
||||
if (mainWindow.gURLBar)
|
||||
mainWindow.focusElement(mainWindow.gURLBar);
|
||||
mainWindow.gURLBar.focus();
|
||||
}
|
||||
]]></script>
|
||||
</head>
|
||||
|
@ -50,7 +50,7 @@ function test() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// ensure that the URL bar is not focused initially
|
||||
focusElement(content);
|
||||
browser.focus();
|
||||
isnot(document.commandDispatcher.focusedElement, gURLBar.inputField,
|
||||
"URL Bar should not be focused before entering the private browsing mode");
|
||||
// ensure that the URL bar is not empty initially
|
||||
|
Loading…
Reference in New Issue
Block a user