Bug 1318070 - Make sure multi-word queries are rejected when keyword.enabled is false r=mak a=gchang
authorWes Kocher <wkocher@mozilla.com>
Tue, 21 Mar 2017 10:57:20 -0700
changeset 376920 2bbf316c5d61239405d741d66424549ff06e94ab
parent 376919 2f76881b7ba245bb4cfaa4e2c63fa2a040ccce46
child 376921 f6e3c8ec61337e3cdea66a60dc4ba6e5ffb51fd2
push id7090
push usercbook@mozilla.com
push dateThu, 23 Mar 2017 15:43:59 +0000
treeherdermozilla-beta@2fca9bc9660f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, gchang
bugs1318070
milestone53.0
Bug 1318070 - Make sure multi-word queries are rejected when keyword.enabled is false r=mak a=gchang MozReview-Commit-ID: 6kMU2oTy456
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/tests/unifiedcomplete/test_visit_url.js
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -1388,16 +1388,30 @@ Search.prototype = {
   *_matchUnknownUrl() {
     let flags = Ci.nsIURIFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS |
                 Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
     let fixupInfo = null;
     try {
       fixupInfo = Services.uriFixup.getFixupURIInfo(this._originalSearchString,
                                                     flags);
     } catch (e) {
+      if (e.result == Cr.NS_ERROR_MALFORMED_URI && !Prefs.keywordEnabled) {
+        let value = PlacesUtils.mozActionURI("visiturl", {
+          url: this._originalSearchString,
+          input: this._originalSearchString,
+        });
+        this._addMatch({
+          value,
+          comment: this._originalSearchString,
+          style: "action visiturl",
+          frecency: 0,
+        });
+
+        return true;
+      }
       return false;
     }
 
     // If the URI cannot be fixed or the preferred URI would do a keyword search,
     // that basically means this isn't useful to us. Note that
     // fixupInfo.keywordAsSent will never be true if the keyword.enabled pref
     // is false or there are no engines, so in that case we will always return
     // a "visit".
--- a/toolkit/components/places/tests/unifiedcomplete/test_visit_url.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_visit_url.js
@@ -136,16 +136,22 @@ add_task(function*() {
     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/", { heuristic: true }) ]
   });
+  do_print("visit two word query, keyword.enabled = false");
+  yield check_autocomplete({
+    search: "bacon lovers",
+    searchParam: "enable-actions",
+    matches: [ makeVisitMatch("bacon lovers", "bacon lovers", { heuristic: true }) ]
+  });
   Services.prefs.setBoolPref("keyword.enabled", keywordEnabled);
 
   do_print("visit url, scheme+host");
   yield check_autocomplete({
     search: "http://example",
     searchParam: "enable-actions",
     matches: [ makeVisitMatch("http://example", "http://example/", { heuristic: true }) ]
   });