Bug 1179153 - location bar shows "search with Google" as the default action even when keyword.enabled is false. r=Mossop
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 28 Jul 2015 17:51:18 +0200
changeset 286677 5c091530338bbc59f74717c4a88754cc18cf7bce
parent 286676 825a6e29bff104f105670025fd971679eb44ba39
child 286678 72146c45a5902bab7468f6ee5c4a44c0d5dd3175
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop
bugs1179153
milestone42.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 1179153 - location bar shows "search with Google" as the default action even when keyword.enabled is false. r=Mossop
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/tests/unifiedcomplete/test_visiturl.js
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -414,16 +414,20 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
     store.matchTitleToken = prefs.get(...PREF_MATCH_TITLE);
     store.matchURLToken = prefs.get(...PREF_MATCH_URL);
     store.suggestHistory = prefs.get(...PREF_SUGGEST_HISTORY);
     store.suggestBookmark = prefs.get(...PREF_SUGGEST_BOOKMARK);
     store.suggestOpenpage = prefs.get(...PREF_SUGGEST_OPENPAGE);
     store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
     store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
     store.maxCharsForSearchSuggestions = prefs.get(...PREF_MAX_CHARS_FOR_SUGGEST);
+    store.keywordEnabled = true;
+    try {
+      store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled");
+    } catch (ex) {}
 
     // If history is not set, onlyTyped value should be ignored.
     if (!store.suggestHistory) {
       store.suggestTyped = false;
     }
     store.defaultBehavior = types.concat("Typed").reduce((memo, type) => {
       let prefValue = store["suggest" + type];
       return memo | (prefValue &&
@@ -468,24 +472,27 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
     observe(subject, topic, data) {
       // Avoid re-entrancy when flipping linked preferences.
       if (this._ignoreNotifications)
         return;
       this._ignoreNotifications = true;
       loadPrefs(subject, topic, data);
       this._ignoreNotifications = false;
     },
-    QueryInterface: XPCOMUtils.generateQI([ Ci.nsIObserver ])
+    QueryInterface: XPCOMUtils.generateQI([
+      Ci.nsIObserver,
+      Ci.nsISupportsWeakReference ])
   };
 
   // Synchronize suggest.* prefs with autocomplete.enabled at initialization
   syncEnabledPref();
 
   loadPrefs();
   prefs.observe("", store);
+  Services.prefs.addObserver("keyword.enabled", store, true);
 
   return Object.seal(store);
 });
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Helper functions
 
 /**
@@ -1169,17 +1176,19 @@ Search.prototype = {
     // schemes we know should have a host. This allows new schemes to be
     // implemented without us accidentally blocking access to them.
     let hostExpected = new Set(["http", "https", "ftp", "chrome", "resource"]);
     if (hostExpected.has(uri.scheme) && !uri.host)
       return false;
 
     // If the result is something that looks like a single-worded hostname
     // we need to check the domain whitelist to treat it as such.
+    // We also want to return a "visit" if keyword.enabled is false.
     if (uri.asciiHost &&
+        Prefs.keywordEnabled &&
         REGEXP_SINGLEWORD_HOST.test(uri.asciiHost) &&
         !Services.uriFixup.isDomainWhitelisted(uri.asciiHost, -1)) {
       return false;
     }
 
     let value = makeActionURL("visiturl", {
       url: uri.spec,
       input: this._originalSearchString,
--- a/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js
@@ -56,9 +56,21 @@ add_task(function*() {
   });
 
   do_print("visit url, ipv6 literal");
   yield check_autocomplete({
     search: "[2001:db8::1]",
     searchParam: "enable-actions",
     matches: [ makeVisitMatch("[2001:db8::1]", "http://[2001:db8::1]/") ]
   });
+
+  // Setting keyword.enabled to false should always try to visit.
+  Services.prefs.setBoolPref("keyword.enabled", false);
+  do_register_cleanup(() => {
+    Services.prefs.clearUserPref("keyword.enabled");
+  });
+  do_print("visit url, keyword.enabled = false");
+  yield check_autocomplete({
+    search: "bacon",
+    searchParam: "enable-actions",
+    matches: [ makeVisitMatch("bacon", "http://bacon/") ]
+  });
 });