Bug 463299 - Hitting Esc when text was entered in the search box shouldn't close the all tabs / ctrl-tab panel. r=gavin
authorDão Gottwald <dao@mozilla.com>
Thu, 06 Nov 2008 20:20:34 +0100
changeset 21387 40d02210c6c57b8003f3019e4a6db4af0383f881
parent 21386 bd37f61d0b0bacf82739776d93d29984a5a84b7b
child 21388 9621d305de924551414f89a2be91e244fab49dc2
child 21391 13eb132ec2c8d518c903f82539aa5e496f23980f
push id3523
push userdgottwald@mozilla.com
push dateThu, 06 Nov 2008 19:20:50 +0000
treeherdermozilla-central@40d02210c6c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs463299
milestone1.9.1b2pre
Bug 463299 - Hitting Esc when text was entered in the search box shouldn't close the all tabs / ctrl-tab panel. r=gavin
browser/base/content/browser-tabPreviews.js
browser/base/content/browser.xul
browser/base/content/test/browser_ctrlTab.js
--- a/browser/base/content/browser-tabPreviews.js
+++ b/browser/base/content/browser-tabPreviews.js
@@ -429,17 +429,19 @@ var ctrlTab = {
     this.selectedIndex = 0;
     this.page = 0;
     this.advanceSelected();
   },
 
   onKeyPress: function ctrlTab__onKeyPress(event) {
     var isOpen = this.isOpen;
 
-    if (isOpen && event.target == this.searchField)
+    if (isOpen &&
+        event.target == this.searchField &&
+        event.keyCode != event.DOM_VK_ESCAPE)
       return;
 
     if (isOpen) {
       event.preventDefault();
       event.stopPropagation();
     }
 
     switch (event.keyCode) {
@@ -610,18 +612,17 @@ var ctrlTab = {
           this.removeClosingTabFromUI(event.target);
         break;
       case "keypress":
         this.onKeyPress(event);
         break;
       case "keydown":
       case "keyup":
         if (event.target == this.searchField) {
-          if (event.keyCode == event.DOM_VK_RETURN ||
-              event.keyCode == event.DOM_VK_ESCAPE)
+          if (event.keyCode == event.DOM_VK_RETURN)
             this.panel.focus();
         } else {
           // Manually consume the events, as the panel is open but doesn't
           // necessarily have focus.
           event.stopPropagation();
           event.preventDefault();
         }
 
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -228,17 +228,17 @@
         </vbox>
       </hbox>
     </panel>
 
     <tooltip id="urlTooltip">
       <label crop="center" flex="1" class="tooltip-label"/>
     </tooltip>
 
-    <panel id="ctrlTab-panel" class="KUI-panel" hidden="true" norestorefocus="true"
+    <panel id="ctrlTab-panel" class="KUI-panel" hidden="true" norestorefocus="true" ignorekeys="true"
 #ifdef XP_WIN
 # XXX bug 457997
       noautohide="true"
 #endif
     >
       <hbox pack="center">
         <textbox id="ctrlTab-search"
                  type="search"
--- a/browser/base/content/test/browser_ctrlTab.js
+++ b/browser/base/content/test/browser_ctrlTab.js
@@ -86,23 +86,31 @@ function test() {
     EventUtils.synthesizeKey("f", { ctrlKey: true });
     is(document.activeElement, ctrlTab.searchField.inputField,
        "Ctrl+Tab -> Ctrl+F focuses the panel's search field");
 
     releaseCtrl();
     ok(isOpen(),
        "panel is sticky after focusing the search field and releasing the Ctrl key");
 
+    ctrlTab.searchField.value = "foo";
+    EventUtils.synthesizeKey("VK_ESCAPE", {});
+    is(ctrlTab.searchField.value, "",
+       "ESC key clears the search field");
+    ok(isOpen(),
+       "Clearing the search field with ESC keeps the panel open");
+
     // blur the search field
     EventUtils.synthesizeKey("VK_TAB", {});
     isnot(document.activeElement, ctrlTab.searchField.inputField,
           "Tab key blurs the panel's search field");
 
     // advance selection and close panel
     EventUtils.synthesizeKey("VK_TAB", {});
+    EventUtils.synthesizeKey("VK_TAB", {});
     EventUtils.synthesizeKey("VK_RETURN", {});
     ok(!isOpen(),
        "Enter key closes the panel");
     is(gBrowser.tabContainer.selectedIndex, 1,
        "Tab key advances the selection while the panel is sticky");
 
     gBrowser.removeCurrentTab();
     gBrowser.removeCurrentTab();