Bug 1292321 - Pressing tab key in address bar selects one-off search buttons instead of the entries in the history dropdown list. r=florian
authorDrew Willcoxon <adw@mozilla.com>
Fri, 12 Aug 2016 22:25:11 -0700
changeset 400465 4cf5aa807f27376197743b62eff2b2c3c2891b44
parent 400464 1ba6215e84c3b34b928898331c3d444b3dd96ee3
child 400466 d33489bb88626f512cf7aa58d631f6875aa2d696
push id26149
push userjwein@mozilla.com
push dateSat, 13 Aug 2016 20:25:08 +0000
reviewersflorian
bugs1292321
milestone51.0a1
Bug 1292321 - Pressing tab key in address bar selects one-off search buttons instead of the entries in the history dropdown list. r=florian MozReview-Commit-ID: AnUZolRLBcl
browser/base/content/test/urlbar/browser_urlbarOneOffs.js
browser/base/content/urlbarBindings.xml
browser/components/search/content/search.xml
--- a/browser/base/content/test/urlbar/browser_urlbarOneOffs.js
+++ b/browser/base/content/test/urlbar/browser_urlbarOneOffs.js
@@ -149,19 +149,19 @@ add_task(function* searchWith() {
 
   assertState(0, -1, typedValue);
 
   let item = gURLBar.popup.richlistbox.firstChild;
   Assert.equal(item._actionText.textContent,
                "Search with " + Services.search.currentEngine.name,
                "Sanity check: first result's action text");
 
-  // Tab to the first one-off.  Now the first result and the first one-off
+  // Alt+Down to the first one-off.  Now the first result and the first one-off
   // should both be selected.
-  EventUtils.synthesizeKey("VK_TAB", {})
+  EventUtils.synthesizeKey("VK_DOWN", { altKey: true })
   assertState(0, 0, typedValue);
 
   let engineName = gURLBar.popup.oneOffSearchButtons.selectedButton.engine.name;
   Assert.notEqual(engineName, Services.search.currentEngine.name,
                   "Sanity check: First one-off engine should not be " +
                   "the current engine");
   Assert.equal(item._actionText.textContent,
                "Search with " + engineName,
@@ -191,18 +191,18 @@ add_task(function* oneOffClick() {
 add_task(function* oneOffReturn() {
   gBrowser.selectedTab = gBrowser.addTab();
 
   let typedValue = "foo";
   yield promiseAutocompleteResultPopup(typedValue, window, true);
 
   assertState(0, -1, typedValue);
 
-  // Tab to select the first one-off.
-  EventUtils.synthesizeKey("VK_TAB", {})
+  // Alt+Down to select the first one-off.
+  EventUtils.synthesizeKey("VK_DOWN", { altKey: true })
   assertState(0, 0, typedValue);
 
   let resultsPromise = promiseSearchResultsLoaded();
   EventUtils.synthesizeKey("VK_RETURN", {})
   yield resultsPromise;
 
   gBrowser.removeTab(gBrowser.selectedTab);
 });
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1287,16 +1287,17 @@ file, You can obtain one at http://mozil
       <xul:richlistbox anonid="richlistbox" class="autocomplete-richlistbox"
                        flex="1"/>
       <xul:hbox anonid="footer">
         <children/>
         <xul:vbox anonid="one-off-search-buttons"
                   class="search-one-offs"
                   compact="true"
                   includecurrentengine="true"
+                  disabletab="true"
                   flex="1"/>
       </xul:hbox>
     </content>
 
     <implementation>
       <field name="_maxResults">0</field>
 
       <field name="_bundle" readonly="true">
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1746,17 +1746,18 @@
           let stopEvent = false;
 
           // Tab cycles through the one-offs and moves the focus out at the end.
           // But only if non-Shift modifiers aren't also pressed, to avoid
           // clobbering other shortcuts.
           if (event.keyCode == KeyEvent.DOM_VK_TAB &&
               !event.altKey &&
               !event.ctrlKey &&
-              !event.metaKey) {
+              !event.metaKey &&
+              this.getAttribute("disabletab") != "true") {
             stopEvent = this.advanceSelection(!event.shiftKey, false, true);
           }
 
           // Alt + up/down is very similar to (shift +) tab but differs in that
           // it loops through the list, whereas tab will move the focus out.
           else if (event.altKey &&
                    (event.keyCode == KeyEvent.DOM_VK_DOWN ||
                     event.keyCode == KeyEvent.DOM_VK_UP)) {