Bug 1494471 - Ignore the autofill threshold when autofilling URLs r=mak
authorDrew Willcoxon <adw@mozilla.com>
Thu, 11 Oct 2018 08:34:25 +0000
changeset 499229 94bc301b5bd40d1f42189d686e9d8317c99e70c5
parent 499228 ab32d2dc93e2969169b901d6c5be9ec07d8ffc07
child 499230 45bc3a854dd1484266c7da28d56e8baa6c54a8d8
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1494471
milestone64.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 1494471 - Ignore the autofill threshold when autofilling URLs r=mak Differential Revision: https://phabricator.services.mozilla.com/D7361
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/tests/unifiedcomplete/autofill_tasks.js
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -274,46 +274,41 @@ const SQL_ORIGIN_PREFIX_BOOKMARKED_QUERY
 );
 
 // Result row indexes for urlQuery()
 const QUERYINDEX_URL_URL = 1;
 const QUERYINDEX_URL_STRIPPED_URL = 2;
 const QUERYINDEX_URL_FRECENCY = 3;
 
 function urlQuery(conditions1, conditions2) {
+  // We limit the search to places that are either bookmarked or have a frecency
+  // over some small, arbitrary threshold (20) in order to avoid scanning as few
+  // rows as possible.  Keep in mind that we run this query every time the user
+  // types a key when the urlbar value looks like a URL with a path.
   return `/* do not warn (bug no): cannot use an index to sort */
-          ${SQL_AUTOFILL_WITH}
           SELECT :query_type,
                  url,
                  :strippedURL,
                  frecency,
                  foreign_count > 0 AS bookmarked,
                  id
           FROM moz_places
           WHERE rev_host = :revHost
-                AND (
-                  MAX(frecency, 0) >= ${SQL_AUTOFILL_FRECENCY_THRESHOLD}
-                  OR bookmarked
-                )
-                AND hidden = 0
+                AND (bookmarked OR frecency > 20)
                 ${conditions1}
           UNION ALL
           SELECT :query_type,
                  url,
                  :strippedURL,
                  frecency,
                  foreign_count > 0 AS bookmarked,
                  id
           FROM moz_places
           WHERE rev_host = :revHost || 'www.'
-                AND (
-                  MAX(frecency, 0) >= ${SQL_AUTOFILL_FRECENCY_THRESHOLD}
-                  OR bookmarked
-                )
-                AND hidden = 0
+                AND (bookmarked OR frecency > 20)
                 ${conditions2}
           ORDER BY frecency DESC, id DESC
           LIMIT 1 `;
 }
 
 const SQL_URL_QUERY = urlQuery(
   `AND strip_prefix_and_userinfo(url) BETWEEN :strippedURL AND :strippedURL || X'FFFF'`,
   `AND strip_prefix_and_userinfo(url) BETWEEN 'www.' || :strippedURL AND 'www.' || :strippedURL || X'FFFF'`
@@ -2199,17 +2194,16 @@ Search.prototype = {
       strippedURL = strippedURL.substr(this._strippedPrefix.length);
     }
     strippedURL = host + strippedURL.substr(host.length);
 
     let opts = {
       query_type: QUERYTYPE_AUTOFILL_URL,
       revHost,
       strippedURL,
-      stddevMultiplier: UrlbarPrefs.get("autoFill.stddevMultiplier"),
     };
 
     let bookmarked = this.hasBehavior("bookmark") &&
                      !this.hasBehavior("history");
 
     if (this._strippedPrefix) {
       opts.prefix = this._strippedPrefix;
       if (bookmarked) {
--- a/toolkit/components/places/tests/unifiedcomplete/autofill_tasks.js
+++ b/toolkit/components/places/tests/unifiedcomplete/autofill_tasks.js
@@ -539,39 +539,58 @@ function addAutofillTasks(origins) {
     // https://example.com/ falls below the autofill threshold.  It should not
     // be autofilled now.
     for (let i = 0; i < 10; i++) {
       await PlacesTestUtils.addVisits([
         { uri: "https://not-" + url },
       ]);
     }
 
-    // Enable actions to make sure that the failure to make an autofill match
-    // does not interrupt creating another type of heuristic match, in this case
-    // a search (for "ex") in the `origins` case, and a visit in the `!origins`
-    // case.
-    await check_autocomplete({
-      search,
-      searchParam: "enable-actions",
-      matches: [
-        origins ?
-          makeSearchMatch(search, { style: ["heuristic"] }) :
-          makeVisitMatch(search, "http://" + search, { heuristic: true }),
-        {
-          value: "https://not-" + url,
-          comment: "test visit for https://not-" + url,
-          style: ["favicon"],
-        },
-        {
-          value: "https://" + url,
-          comment: "test visit for https://" + url,
-          style: ["favicon"],
-        },
-      ],
-    });
+    // Enable actions.  In the `origins` case, the failure to make an autofill
+    // match should not interrupt creating another type of heuristic match, in
+    // this case a search (for "ex").  In the `!origins` case, autofill should
+    // still happen since there's no threshold comparison.
+    if (origins) {
+      await check_autocomplete({
+        search,
+        searchParam: "enable-actions",
+        matches: [
+          makeSearchMatch(search, { style: ["heuristic"] }),
+          {
+            value: "https://not-" + url,
+            comment: "test visit for https://not-" + url,
+            style: ["favicon"],
+          },
+          {
+            value: "https://" + url,
+            comment: "test visit for https://" + url,
+            style: ["favicon"],
+          },
+        ],
+      });
+    } else {
+      await check_autocomplete({
+        search,
+        searchParam: "enable-actions",
+        autofilled: url,
+        completed: "https://" + url,
+        matches: [
+          {
+            value: url,
+            comment: "https://" + comment,
+            style: ["autofill", "heuristic"],
+          },
+          {
+            value: "https://not-" + url,
+            comment: "test visit for https://not-" + url,
+            style: ["favicon"],
+          },
+        ],
+      });
+    }
 
     // Remove the visits to the different host.
     await PlacesUtils.history.remove([
       "https://not-" + url,
     ]);
 
     // https should be completed again.
     await check_autocomplete({