Bug 1099046 - Autocomplete popup displays "moz-action:searchengine,..." for keyword searches while pressing Shift. r=mak
authorBlair McBride <bmcbride@mozilla.com>
Tue, 06 Jan 2015 19:13:46 +1300
changeset 248057 f9d665c7c6675bacf91613bca0c7e8de2a24df87
parent 248056 1f6ca2c7d05a89a27e8b22df0bfc19953cb8857b
child 248058 7e69ba4b7dd98db1119f85e46459cb4e410b2cd5
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1099046
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1099046 - Autocomplete popup displays "moz-action:searchengine,..." for keyword searches while pressing Shift. r=mak
browser/base/content/browser.css
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_action_keyword_override.js
toolkit/content/widgets/autocomplete.xml
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -413,26 +413,26 @@ toolbar:not(#TabsToolbar) > #personal-bo
 
 .ac-url-text:-moz-locale-dir(rtl),
 .ac-title:-moz-locale-dir(rtl) > description {
   direction: ltr !important;
 }
 
 /* For results that are actions, their description text is shown instead of
    the URL - this needs to follow the locale's direction, unlike URLs. */
-panel:not([noactions]) > richlistbox > richlistitem[type~="action"]:-moz-locale-dir(rtl) > .ac-url-box {
+panel:not([noactions]) > richlistbox > richlistitem.overridable-action:-moz-locale-dir(rtl) > .ac-url-box {
   direction: rtl;
 }
 
-panel[noactions] > richlistbox > richlistitem[type~="action"] > .ac-url-box > .ac-url > .ac-action-text,
-panel[noactions] > richlistbox > richlistitem[type~="action"] > .ac-url-box > .ac-action-icon {
+panel[noactions] > richlistbox > richlistitem.overridable-action > .ac-url-box > .ac-url > .ac-action-text,
+panel[noactions] > richlistbox > richlistitem.overridable-action > .ac-url-box > .ac-action-icon {
   visibility: collapse;
 }
 
-panel[noactions] > richlistbox > richlistitem[type~="action"] > .ac-url-box > .ac-url > .ac-url-text {
+panel[noactions] > richlistbox > richlistitem.overridable-action > .ac-url-box > .ac-url > .ac-url-text {
   visibility: visible;
 }
 
 #urlbar:not([actiontype="switchtab"]) > #urlbar-display-box {
   display: none;
 }
 
 #PopupAutoComplete {
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -107,16 +107,17 @@ support-files =
   content_aboutAccounts.js
 [browser_aboutSupport_newtab_security_state.js]
 [browser_aboutHealthReport.js]
 skip-if = os == "linux" # Bug 924307
 [browser_aboutHome.js]
 skip-if = e10s # Bug 1093153 - no about:home support yet
 [browser_aboutSyncProgress.js]
 [browser_action_keyword.js]
+[browser_action_keyword_override.js]
 [browser_action_searchengine.js]
 [browser_action_searchengine_alias.js]
 [browser_addKeywordSearch.js]
 [browser_search_favicon.js]
 [browser_alltabslistener.js]
 [browser_autocomplete_a11y_label.js]
 skip-if = e10s # Bug 1101993 - times out for unknown reasons when run in the dir (works on its own)
 [browser_autocomplete_no_title.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_action_keyword_override.js
@@ -0,0 +1,35 @@
+add_task(function*() {
+  // This test is only relevant if UnifiedComplete is enabled.
+  if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
+    todo(false, "Stop supporting old autocomplete components.");
+    return;
+  }
+
+  let itemId =
+    PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
+                                         NetUtil.newURI("http://example.com/?q=%s"),
+                                         PlacesUtils.bookmarks.DEFAULT_INDEX,
+                                         "test");
+  PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
+
+  registerCleanupFunction(() => {
+    PlacesUtils.bookmarks.removeItem(itemId);
+  });
+
+  yield promiseAutocompleteResultPopup("keyword search");
+  let result = gURLBar.popup.richlistbox.children[0];
+
+  info("Before override");
+  is_element_hidden(result._url, "URL element should be hidden");
+  is_element_visible(result._extra, "Extra element should be visible");
+
+  info("During override");
+  EventUtils.synthesizeKey("VK_SHIFT" , { type: "keydown" });
+  is_element_hidden(result._url, "URL element should be hidden");
+  is_element_visible(result._extra, "Extra element should be visible");
+
+  EventUtils.synthesizeKey("VK_SHIFT" , { type: "keyup" });
+
+  gURLBar.popup.hidePopup();
+  yield promisePopupHidden(gURLBar.popup);
+});
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1586,32 +1586,34 @@ extends="chrome://global/content/binding
           let emphasiseUrl = true;
 
           // Hide the title's extra box by default, until we find out later if
           // we need extra stuff.
           this._extraBox.hidden = true;
           this._titleBox.flex = 1;
 
           this.removeAttribute("actiontype");
+          this.classList.remove("overridable-action");
 
           // The ellipses are hidden via their visibility so that they always
           // take up space and don't pop in on top of text when shown.  For
           // keyword searches, however, the title ellipsis should not take up
           // space when hidden.  Setting the hidden property accomplishes that.
           this._titleOverflowEllipsis.hidden = false;
 
           let types = new Set(type.split(/\s+/));
           let initialTypes = new Set(types);
 
           // If the type includes an action, set up the item appropriately.
           if (types.has("action")) {
             let action = this._parseActionUrl(url);
             this.setAttribute("actiontype", action.type);
 
             if (action.type == "switchtab") {
+              this.classList.add("overridable-action");
               displayUrl = action.params.url;
               let desc = this._stringBundle.GetStringFromName("switchToTab");
               this._setUpDescription(this._action, desc, true);
             } else if (action.type == "searchengine") {
               emphasiseUrl = false;
 
               let sourceStr = this._stringBundle.GetStringFromName("searchWithEngineForQuery");
               title = this._generateEmphasisPairs(sourceStr, [
@@ -1714,17 +1716,18 @@ extends="chrome://global/content/binding
               let paramsIndex = search.indexOf(" ");
               if (paramsIndex != -1)
                 params = search.substr(paramsIndex + 1);
 
               // Emphasize the keyword parameters
               this._setUpDescription(this._extra, params);
 
               // Don't emphasize keyword searches in the title or url
-              this.setAttribute("text", "");
+              emphasiseUrl = false;
+              emphasiseTitle = false;
             } else {
               // Don't show any description for non keyword types.
               this._setUpDescription(this._extra, "", true);
             }
             // If the result has the type favicon and a known search provider,
             // customize it the same way as a keyword result.
             type = "keyword";
           }