From 783b0033f35996fe4a0a95d7653b614d6d7724b3 Mon Sep 17 00:00:00 2001 From: Gavin Sharp Date: Wed, 20 Jul 2011 16:21:55 -0400 Subject: [PATCH] Bug 672813: clicking the Go button needs to focus the content area, r=dao --- .../test/browser_locationBarExternalLoad.js | 4 ++++ browser/base/content/urlbarBindings.xml | 17 +++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/browser/base/content/test/browser_locationBarExternalLoad.js b/browser/base/content/test/browser_locationBarExternalLoad.js index b0b177534cfd..2bc88a989e32 100644 --- a/browser/base/content/test/browser_locationBarExternalLoad.js +++ b/browser/base/content/test/browser_locationBarExternalLoad.js @@ -46,6 +46,10 @@ function testURL(url, loadFunc, endFunc) { loadFunc(url); addPageShowListener(function () { + let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); + is(fm.focusedElement, null, "should be no focused element"); + is(fm.focusedWindow, gBrowser.contentWindow, "content window should be focused"); + ok(!gBrowser.contentPrincipal.equals(pagePrincipal), "load of " + url + " by " + loadFunc.name + " should produce a page with a different principal"); endFunc(); diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index ca4134e519ef..ee76d2f053e0 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -327,6 +327,11 @@ gBrowser.loadURIWithFlags(url, flags, null, null, postData); } + // Focus the content area before triggering loads, since if the load + // occurs in a new tab, we want focus to be restored to the content + // area when the current tab is re-selected. + gBrowser.selectedBrowser.focus(); + if (aTriggeringEvent instanceof MouseEvent) { // We have a mouse event (from the go button), so use the standard // UI link behaviors @@ -335,18 +340,12 @@ loadCurrent(); } else { this.handleRevert(); - content.focus(); openUILinkIn(url, where, { allowThirdPartyFixup: true, postData: postData }); } - return; - } - - if (aTriggeringEvent && - aTriggeringEvent.altKey && - !isTabEmpty(gBrowser.selectedTab)) { + } else if (aTriggeringEvent && aTriggeringEvent.altKey && + !isTabEmpty(gBrowser.selectedTab)) { this.handleRevert(); - content.focus(); gBrowser.loadOneTab(url, { postData: postData, inBackground: false, @@ -356,8 +355,6 @@ } else { loadCurrent(); } - - gBrowser.selectedBrowser.focus(); ]]>