Bug 1318070 - Make sure multi-word queries are rejected when keyword.enabled is false r=mak
authorWes Kocher <wkocher@mozilla.com>
Tue, 21 Mar 2017 10:57:20 -0700
changeset 348647 784c281fcc1e290b05cb6a6218f64018ff30c48e
parent 348646 141019b411dce51d3b308db6856fcccb709c25b3
child 348648 ca006aa6abf0200ede96ec9abe146e9f06a6e6ed
push id31532
push userkwierso@gmail.com
push dateTue, 21 Mar 2017 22:32:51 +0000
treeherdermozilla-central@18bb0299dd9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1318070
milestone55.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 1318070 - Make sure multi-word queries are rejected when keyword.enabled is false r=mak 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 }) ]
   });