Bug 1500108 - Remove the history.onlyTyped preference and behavior from the Address Bar. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 24 Oct 2018 13:01:42 +0000
changeset 442768 27a7c02c5fdf499664213387949679bf94dafa35
parent 442767 4ff8166e26697789c95de2b03d45893e4ba90f87
child 442769 b48368889eb5756251512ac0595078d49983be42
push id34922
push usershindli@mozilla.com
push dateWed, 24 Oct 2018 16:46:21 +0000
treeherdermozilla-central@45632b51fa05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1500108
milestone65.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 1500108 - Remove the history.onlyTyped preference and behavior from the Address Bar. r=adw Differential Revision: https://phabricator.services.mozilla.com/D9512
browser/app/profile/firefox.js
browser/components/urlbar/UrlbarPrefs.jsm
toolkit/components/places/SQLFunctions.cpp
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/mozIPlacesAutoComplete.idl
toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
toolkit/components/places/tests/unifiedcomplete/test_417798.js
toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
toolkit/components/places/tests/unifiedcomplete/test_special_search.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -307,20 +307,16 @@ pref("browser.urlbar.suggest.searches", 
 pref("browser.urlbar.userMadeSearchSuggestionsChoice", false);
 // The suggestion opt-out hint will be hidden after being shown 4 times.
 pref("browser.urlbar.timesBeforeHidingSuggestionsHint", 4);
 
 // Limit the number of characters sent to the current search engine to fetch
 // suggestions.
 pref("browser.urlbar.maxCharsForSearchSuggestions", 20);
 
-// Restrictions to current suggestions can also be applied (intersection).
-// Typed suggestion works only if history is set to true.
-pref("browser.urlbar.suggest.history.onlyTyped",    false);
-
 pref("browser.urlbar.formatting.enabled", true);
 pref("browser.urlbar.trimURLs", true);
 
 pref("browser.urlbar.oneOffSearches", true);
 
 // If changed to true, copying the entire URL from the location bar will put the
 // human readable (percent-decoded) URL on the clipboard.
 pref("browser.urlbar.decodeURLsOnCopy", false);
@@ -1167,17 +1163,16 @@ pref("services.sync.prefs.sync.browser.s
 pref("services.sync.prefs.sync.browser.tabs.loadInBackground", true);
 pref("services.sync.prefs.sync.browser.tabs.warnOnClose", true);
 pref("services.sync.prefs.sync.browser.tabs.warnOnOpen", true);
 pref("services.sync.prefs.sync.browser.urlbar.autocomplete.enabled", true);
 pref("services.sync.prefs.sync.browser.urlbar.matchBuckets", true);
 pref("services.sync.prefs.sync.browser.urlbar.maxRichResults", true);
 pref("services.sync.prefs.sync.browser.urlbar.suggest.bookmark", true);
 pref("services.sync.prefs.sync.browser.urlbar.suggest.history", true);
-pref("services.sync.prefs.sync.browser.urlbar.suggest.history.onlyTyped", true);
 pref("services.sync.prefs.sync.browser.urlbar.suggest.openpage", true);
 pref("services.sync.prefs.sync.browser.urlbar.suggest.searches", true);
 pref("services.sync.prefs.sync.dom.disable_open_during_load", true);
 pref("services.sync.prefs.sync.dom.disable_window_flip", true);
 pref("services.sync.prefs.sync.dom.disable_window_move_resize", true);
 pref("services.sync.prefs.sync.dom.event.contextmenu.enabled", true);
 pref("services.sync.prefs.sync.extensions.personas.current", true);
 pref("services.sync.prefs.sync.extensions.update.enabled", true);
--- a/browser/components/urlbar/UrlbarPrefs.jsm
+++ b/browser/components/urlbar/UrlbarPrefs.jsm
@@ -92,21 +92,16 @@ const PREF_URLBAR_DEFAULTS = new Map([
   ["maxRichResults", 10],
 
   // Results will include the user's bookmarks when this is true.
   ["suggest.bookmark", true],
 
   // Results will include the user's history when this is true.
   ["suggest.history", true],
 
-  // Results will include the user's history when this is true, but only those
-  // URLs with the "typed" flag (which includes but isn't limited to URLs the
-  // user has typed in the urlbar).
-  ["suggest.history.onlyTyped", false],
-
   // Results will include switch-to-tab results when this is true.
   ["suggest.openpage", true],
 
   // Results will include search suggestions when this is true.
   ["suggest.searches", false],
 
   // When using switch to tabs, if set to true this will move the tab into the
   // active window.
@@ -208,18 +203,16 @@ class Preferences {
   observe(subject, topic, data) {
     let pref = data.replace(PREF_URLBAR_BRANCH, "");
     if (!PREF_URLBAR_DEFAULTS.has(pref) && !PREF_OTHER_DEFAULTS.has(pref))
       return;
     this._map.delete(pref);
     // Some prefs may influence others.
     if (pref == "matchBuckets") {
       this._map.delete("matchBucketsSearch");
-    } else if (pref == "suggest.history") {
-      this._map.delete("suggest.history.onlyTyped");
     }
     if (pref == "autocomplete.enabled" || pref.startsWith("suggest.")) {
       this._map.delete("defaultBehavior");
       this._map.delete("emptySearchDefaultBehavior");
       this._updateLinkedPrefs(pref);
     }
   }
 
@@ -290,39 +283,32 @@ class Preferences {
             val = PlacesUtils.convertMatchBucketsStringToArray(val);
             return [ ...DEFAULT_BUCKETS_BEFORE,
                     ...val,
                     ...DEFAULT_BUCKETS_AFTER ];
           } catch (ex) { /* invalid format, will just return matchBuckets */ }
         }
         return this.get("matchBuckets");
       }
-      case "suggest.history.onlyTyped": {
-        // If history is not set, onlyTyped value should be ignored.
-        return this.get("suggest.history") && this._readPref(pref);
-      }
       case "defaultBehavior": {
         let val = 0;
-        for (let type of [...Object.keys(SUGGEST_PREF_TO_BEHAVIOR), "history.onlyTyped"]) {
-          let behavior = type == "history.onlyTyped" ?
-            "TYPED" : SUGGEST_PREF_TO_BEHAVIOR[type].toUpperCase();
-          val |= this.get("suggest." + type) &&
-                 Ci.mozIPlacesAutoComplete["BEHAVIOR_" + behavior];
+        for (let type of Object.keys(SUGGEST_PREF_TO_BEHAVIOR)) {
+          let behavior = `BEHAVIOR_${SUGGEST_PREF_TO_BEHAVIOR[type].toUpperCase()}`;
+          val |= this.get("suggest." + type) && Ci.mozIPlacesAutoComplete[behavior];
         }
         return val;
       }
       case "emptySearchDefaultBehavior": {
         // Further restrictions to apply for "empty searches" (searching for
         // "").  The empty behavior is typed history, if history is enabled.
         // Otherwise, it is bookmarks, if they are enabled. If both history and
         // bookmarks are disabled, it defaults to open pages.
         let val = Ci.mozIPlacesAutoComplete.BEHAVIOR_RESTRICT;
         if (this.get("suggest.history")) {
-          val |= Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY |
-                Ci.mozIPlacesAutoComplete.BEHAVIOR_TYPED;
+          val |= Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY;
         } else if (this.get("suggest.bookmark")) {
           val |= Ci.mozIPlacesAutoComplete.BEHAVIOR_BOOKMARK;
         } else {
           val |= Ci.mozIPlacesAutoComplete.BEHAVIOR_OPENPAGE;
         }
         return val;
       }
       case "matchBehavior": {
--- a/toolkit/components/places/SQLFunctions.cpp
+++ b/toolkit/components/places/SQLFunctions.cpp
@@ -549,16 +549,18 @@ namespace places {
         StringBeginsWith(url, NS_LITERAL_CSTRING("javascript:")) &&
         !HAS_BEHAVIOR(JAVASCRIPT) &&
         !StringBeginsWith(searchString, NS_LITERAL_CSTRING("javascript:"))) {
       NS_ADDREF(*_result = mCachedZero);
       return NS_OK;
     }
 
     int32_t visitCount = aArguments->AsInt32(kArgIndexVisitCount);
+    // Filtering on typed is no more used by Firefox, it is still being used by
+    // comm-central clients.
     bool typed = aArguments->AsInt32(kArgIndexTyped) ? true : false;
     bool bookmark = aArguments->AsInt32(kArgIndexBookmark) ? true : false;
     nsDependentCString tags = getSharedUTF8String(aArguments, kArgIndexTags);
     int32_t openPageCount = aArguments->AsInt32(kArgIndexOpenPageCount);
     bool matches = false;
     if (HAS_BEHAVIOR(RESTRICT)) {
       // Make sure we match all the filter requirements.  If a given restriction
       // is active, make sure the corresponding condition is not true.
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -637,21 +637,16 @@ Search.prototype = {
    *
    * @param type
    *        The behavior type to set.
    */
   setBehavior(type) {
     type = type.toUpperCase();
     this._behavior |=
       Ci.mozIPlacesAutoComplete["BEHAVIOR_" + type];
-
-    // Setting the "typed" behavior should also set the "history" behavior.
-    if (type == "TYPED") {
-      this.setBehavior("history");
-    }
   },
 
   /**
    * Determines if the specified AutoComplete behavior is set.
    *
    * @param aType
    *        The behavior type to test for.
    * @return true if the behavior is set, false otherwise.
@@ -2131,29 +2126,25 @@ Search.prototype = {
 
   /**
    * @return a string consisting of the search query to be used based on the
    * previously set urlbar suggestion preferences.
    */
   get _suggestionPrefQuery() {
     if (!this.hasBehavior("restrict") && this.hasBehavior("history") &&
         this.hasBehavior("bookmark")) {
-      return this.hasBehavior("typed") ? defaultQuery("AND h.typed = 1")
-                                       : defaultQuery();
+      return defaultQuery();
     }
     let conditions = [];
     if (this.hasBehavior("history")) {
       // Enforce ignoring the visit_count index, since the frecency one is much
       // faster in this case.  ANALYZE helps the query planner to figure out the
       // faster path, but it may not have up-to-date information yet.
       conditions.push("+h.visit_count > 0");
     }
-    if (this.hasBehavior("typed")) {
-      conditions.push("h.typed = 1");
-    }
     if (this.hasBehavior("bookmark")) {
       conditions.push("bookmarked");
     }
     if (this.hasBehavior("tag")) {
       conditions.push("tags NOTNULL");
     }
 
     return conditions.length ? defaultQuery("AND " + conditions.join(" AND "))
--- a/toolkit/components/places/mozIPlacesAutoComplete.idl
+++ b/toolkit/components/places/mozIPlacesAutoComplete.idl
@@ -77,16 +77,17 @@ interface mozIPlacesAutoComplete : nsISu
 
   /**
    * Search the URL of pages.
    */
   const long BEHAVIOR_URL = 1 << 4;
 
   /**
    * Search for typed pages.
+   * No more supported by Firefox, it is still being used by comm-central clients.
    */
   const long BEHAVIOR_TYPED = 1 << 5;
 
   /**
    * Search javascript: URLs.
    */
   const long BEHAVIOR_JAVASCRIPT = 1 << 6;
 
--- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
@@ -35,17 +35,16 @@ const TITLE_SEARCH_ENGINE_SEPARATOR = " 
 
 async function cleanup() {
   Services.prefs.clearUserPref("browser.urlbar.autocomplete.enabled");
   Services.prefs.clearUserPref("browser.urlbar.autoFill");
   Services.prefs.clearUserPref("browser.urlbar.autoFill.searchEngines");
   let suggestPrefs = [
     "history",
     "bookmark",
-    "history.onlyTyped",
     "openpage",
     "searches",
   ];
   for (let type of suggestPrefs) {
     Services.prefs.clearUserPref("browser.urlbar.suggest." + type);
   }
   Services.prefs.clearUserPref("browser.search.suggest.enabled");
   await PlacesUtils.bookmarks.eraseEverything();
--- a/toolkit/components/places/tests/unifiedcomplete/test_417798.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_417798.js
@@ -23,20 +23,20 @@ add_task(async function test_javascript_
   });
 
   info("Match non-javascript: with 'javascript'");
   await check_autocomplete({
     search: "javascript",
     matches: [ { uri: uri1, title: "Title with javascript:" } ],
   });
 
-  info("Match nothing with 'javascript:'");
+  info("Match non-javascript with 'javascript:'");
   await check_autocomplete({
     search: "javascript:",
-    matches: [],
+    matches: [ { uri: uri1, title: "Title with javascript:" } ],
   });
 
   info("Match nothing with '5 javascript:'");
   await check_autocomplete({
     search: "5 javascript:",
     matches: [ ],
   });
 
--- a/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js
@@ -14,19 +14,19 @@ add_task(async function test_javascript_
   let uri4 = NetUtil.newURI("http://t.foo/3");
   let uri5 = NetUtil.newURI("http://t.foo/4");
   let uri6 = NetUtil.newURI("http://t.foo/5");
   let uri7 = NetUtil.newURI("http://t.foo/6");
 
   await PlacesTestUtils.addVisits([
     { uri: uri1, title: "title" },
     { uri: uri2, title: "title" },
-    { uri: uri3, title: "title", transition: TRANSITION_TYPED},
-    { uri: uri4, title: "title", transition: TRANSITION_TYPED },
-    { uri: uri6, title: "title", transition: TRANSITION_TYPED },
+    { uri: uri3, title: "title" },
+    { uri: uri4, title: "title" },
+    { uri: uri6, title: "title" },
     { uri: uri7, title: "title" },
   ]);
 
   await addBookmark({ uri: uri2,
                       title: "title" });
   await addBookmark({ uri: uri4,
                       title: "title" });
   await addBookmark({ uri: uri5,
@@ -38,64 +38,74 @@ add_task(async function test_javascript_
 
   // Now remove page 6 from history, so it is an unvisited bookmark.
   await PlacesUtils.history.remove(uri6);
 
   info("Match everything");
   await check_autocomplete({
     search: "foo",
     searchParam: "enable-actions",
-    matches: [ makeSearchMatch("foo", { heuristic: true }),
-               { uri: uri1, title: "title" },
-               { uri: uri2, title: "title", style: ["bookmark"] },
-               { uri: uri3, title: "title" },
-               { uri: uri4, title: "title", style: ["bookmark"] },
-               { uri: uri5, title: "title", style: ["bookmark"] },
-               { uri: uri6, title: "title", style: ["bookmark"] },
-               makeSwitchToTabMatch("http://t.foo/6", { title: "title" }),
-             ],
+    matches: [
+      makeSearchMatch("foo", { heuristic: true }),
+      { uri: uri1, title: "title" },
+      { uri: uri2, title: "title", style: ["bookmark"] },
+      { uri: uri3, title: "title" },
+      { uri: uri4, title: "title", style: ["bookmark"] },
+      { uri: uri5, title: "title", style: ["bookmark"] },
+      { uri: uri6, title: "title", style: ["bookmark"] },
+      makeSwitchToTabMatch("http://t.foo/6", { title: "title" }),
+    ],
   });
 
   // Note the next few tests do *not* get a search result as enable-actions
   // isn't specified.
   info("Match only history");
   await check_autocomplete({
     search: `foo ${UrlbarTokenizer.RESTRICT.HISTORY}`,
-    matches: [ { uri: uri1, title: "title" },
-               { uri: uri2, title: "title" },
-               { uri: uri3, title: "title" },
-               { uri: uri4, title: "title" },
-               { uri: uri7, title: "title" } ],
+    matches: [
+      { uri: uri1, title: "title" },
+      { uri: uri2, title: "title" },
+      { uri: uri3, title: "title" },
+      { uri: uri4, title: "title" },
+      { uri: uri7, title: "title" },
+    ],
   });
 
-  info("Drop-down empty search matches only typed history");
+  info("Drop-down empty search matches history sorted by frecency desc");
   await check_autocomplete({
     search: "",
-    matches: [ { uri: uri3, title: "title" },
-               { uri: uri4, title: "title" } ],
+    matches: [
+      { uri: uri7, title: "title" },
+      { uri: uri4, title: "title" },
+      { uri: uri3, title: "title" },
+      { uri: uri2, title: "title" },
+      { uri: uri1, title: "title" },
+    ],
   });
 
   info("Drop-down empty search matches only bookmarks");
   Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
   Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   await check_autocomplete({
     search: "",
-    matches: [ { uri: uri2, title: "title", style: ["bookmark"] },
-               { uri: uri4, title: "title", style: ["bookmark"] },
-               { uri: uri5, title: "title", style: ["bookmark"] },
-               { uri: uri6, title: "title", style: ["bookmark"] } ],
+    matches: [
+      { uri: uri2, title: "title", style: ["bookmark"] },
+      { uri: uri4, title: "title", style: ["bookmark"] },
+      { uri: uri5, title: "title", style: ["bookmark"] },
+      { uri: uri6, title: "title", style: ["bookmark"] },
+    ],
   });
 
   info("Drop-down empty search matches only open tabs");
   Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
   await check_autocomplete({
     search: "",
     searchParam: "enable-actions",
     matches: [
-               makeSwitchToTabMatch("http://t.foo/6", { title: "title" }),
-             ],
+      makeSwitchToTabMatch("http://t.foo/6", { title: "title" }),
+    ],
   });
 
   Services.prefs.clearUserPref("browser.urlbar.suggest.history");
   Services.prefs.clearUserPref("browser.urlbar.suggest.bookmark");
 
   await cleanup();
 });
--- a/toolkit/components/places/tests/unifiedcomplete/test_special_search.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_special_search.js
@@ -7,17 +7,16 @@
  * history/bookmark/tagged items and title/url matches.
  *
  * Test 485122 by making sure results don't have tags when restricting result
  * to just history either by default behavior or dynamic query restrict.
  */
 
 function setSuggestPrefsToFalse() {
   Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
-  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", false);
   Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", false);
 }
 
 add_task(async function test_special_searches() {
   let uri1 = NetUtil.newURI("http://url/");
   let uri2 = NetUtil.newURI("http://url/2");
   let uri3 = NetUtil.newURI("http://foo.bar/");
   let uri4 = NetUtil.newURI("http://foo.bar/2");
@@ -282,52 +281,25 @@ add_task(async function test_special_sea
                { uri: uri7, title: "title", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar"], style: [ "bookmark-tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] } ],
   });
 
-  info("foo -> default history, is star, is typed");
-  setSuggestPrefsToFalse();
-  Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
-  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", true);
-  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
-  await check_autocomplete({
-    search: "foo",
-    matches: [ { uri: uri4, title: "foo.bar" },
-               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] } ],
-  });
-
   info("foo -> is star");
   setSuggestPrefsToFalse();
   Services.prefs.setBoolPref("browser.urlbar.suggest.history", false);
   Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
   await check_autocomplete({
     search: "foo",
     matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri7, title: "title", style: [ "bookmark" ] },
                { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
                { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
                { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] } ],
   });
 
-  info("foo -> is star, is typed");
-  setSuggestPrefsToFalse();
-  // only typed should be ignored
-  Services.prefs.setBoolPref("browser.urlbar.suggest.history.onlyTyped", true);
-  Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", true);
-  await check_autocomplete({
-    search: "foo",
-    matches: [ { uri: uri6, title: "foo.bar", style: [ "bookmark" ] },
-               { uri: uri7, title: "title", style: [ "bookmark" ] },
-               { uri: uri8, title: "foo.bar", style: [ "bookmark" ] },
-               { uri: uri9, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
-               { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
-               { uri: uri11, title: "title", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] },
-               { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ], style: [ "bookmark-tag" ] }  ],
-  });
-
   await cleanup();
 });