Bug 1318070 - Make sure multi-word queries are rejected when keyword.enabled is false draft
authorWes Kocher <wkocher@mozilla.com>
Sun, 19 Mar 2017 00:26:07 -0700
changeset 501234 ffd767a916bc509b3d618bcad3196e27e1acc320
parent 501163 e1576dd8bd9d3a4ca418cf347133b8a4957ddeca
child 549813 d92feae71a1e421af72ed4a6718a1fe8e51c7920
push id49911
push userkwierso@gmail.com
push dateSun, 19 Mar 2017 07:27:10 +0000
bugs1318070
milestone55.0a1
Bug 1318070 - Make sure multi-word queries are rejected when keyword.enabled is false 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
@@ -1564,16 +1564,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 }) ]
   });