Bug 1769585: Change default useCountThreshold to not handle input history passed 30 days. r=adw
authorDaisuke Akatsuka <daisuke@birchill.co.jp>
Thu, 19 May 2022 05:57:33 +0000
changeset 618200 e34d221b6f46e9bd5f10d76bc7668ba5f1311f3f
parent 618199 04bc8e2ce305df53bde127a52e392229142cf605
child 618201 66e9853fa8c033a4a268693a560eeb47fe0d34a0
push id39719
push usersmolnar@mozilla.com
push dateThu, 19 May 2022 16:03:14 +0000
treeherdermozilla-central@cc776278c4ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1769585
milestone102.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 1769585: Change default useCountThreshold to not handle input history passed 30 days. r=adw Differential Revision: https://phabricator.services.mozilla.com/D146653
browser/components/urlbar/UrlbarPrefs.jsm
browser/components/urlbar/tests/unit/test_autofill_adaptiveHistory.js
--- a/browser/components/urlbar/UrlbarPrefs.jsm
+++ b/browser/components/urlbar/UrlbarPrefs.jsm
@@ -47,17 +47,19 @@ const PREF_URLBAR_DEFAULTS = new Map([
   ["autoFill", true],
 
   // Whether enabling adaptive history autofill. This pref is a fallback for the
   // Nimbus variable `autoFillAdaptiveHistoryEnabled`.
   ["autoFill.adaptiveHistory.enabled", false],
 
   // Threshold for use count of input history that we handle as adaptive history
   // autofill. If the use count is this value or more, it will be a candidate.
-  ["autoFill.adaptiveHistory.useCountThreshold", [0.1, "float"]],
+  // Set the threshold to not be candidate the input history passed
+  // approximately 30 days since user input it as the default.
+  ["autoFill.adaptiveHistory.useCountThreshold", [0.47, "float"]],
 
   // If true, the domains of the user's installed search engines will be
   // autofilled even if the user hasn't actually visited them.
   ["autoFill.searchEngines", false],
 
   // Affects the frecency threshold of the autofill algorithm.  The threshold is
   // the mean of all origin frecencies plus one standard deviation multiplied by
   // this value.  See UrlbarProviderPlaces.
--- a/browser/components/urlbar/tests/unit/test_autofill_adaptiveHistory.js
+++ b/browser/components/urlbar/tests/unit/test_autofill_adaptiveHistory.js
@@ -766,17 +766,17 @@ const TEST_DATA = [
             uri: "http://example.com/test",
             title: "test visit for http://example.com/test",
           }),
       ],
     },
   },
 ];
 
-add_task(async function() {
+add_task(async function inputTest() {
   for (const {
     description,
     pref,
     useCountThreshold,
     source,
     visitHistory,
     inputHistory,
     bookmarks,
@@ -823,8 +823,91 @@ add_task(async function() {
       matches: expected.results.map(f => f(context)),
     });
 
     await cleanupPlaces();
     UrlbarPrefs.clear("autoFill.adaptiveHistory.enabled");
     UrlbarPrefs.clear("autoFill.adaptiveHistory.useCountThreshold");
   }
 });
+
+add_task(async function decayTest() {
+  UrlbarPrefs.set("autoFill.adaptiveHistory.enabled", true);
+
+  await PlacesTestUtils.addVisits(["http://example.com/test"]);
+  await UrlbarUtils.addToInputHistory("http://example.com/test", "exa");
+
+  const initContext = createContext("exa", { isPrivate: false });
+  await check_results({
+    context: initContext,
+    autofilled: "example.com/test",
+    completed: "http://example.com/test",
+    matches: [
+      makeVisitResult(initContext, {
+        uri: "http://example.com/test",
+        title: "example.com/test",
+        heuristic: true,
+      }),
+    ],
+  });
+
+  // The decay rate for a day is 0.975 defined in
+  // nsNavHistory::PREF_FREC_DECAY_RATE_DEF. Therefore, after 30 days, as
+  // use_count will be 0.975^30 = 0.468, we set the useCountThreshold 0.47 to not
+  // take the input history passed 30 days.
+  UrlbarPrefs.set("autoFill.adaptiveHistory.useCountThreshold", 0.47);
+
+  // Make 29 days later.
+  for (let i = 0; i < 29; i++) {
+    PlacesUtils.history
+      .QueryInterface(Ci.nsIObserver)
+      .observe(null, "idle-daily", "");
+    await PlacesTestUtils.waitForNotification(
+      "pages-rank-changed",
+      () => true,
+      "places"
+    );
+  }
+  const midContext = createContext("exa", { isPrivate: false });
+  await check_results({
+    context: midContext,
+    autofilled: "example.com/test",
+    completed: "http://example.com/test",
+    matches: [
+      makeVisitResult(midContext, {
+        uri: "http://example.com/test",
+        title: "example.com/test",
+        heuristic: true,
+      }),
+    ],
+  });
+
+  // Total 30 days later.
+  PlacesUtils.history
+    .QueryInterface(Ci.nsIObserver)
+    .observe(null, "idle-daily", "");
+  await PlacesTestUtils.waitForNotification(
+    "pages-rank-changed",
+    () => true,
+    "places"
+  );
+  const context = createContext("exa", { isPrivate: false });
+  await check_results({
+    context,
+    autofilled: "example.com/",
+    completed: "http://example.com/",
+    matches: [
+      makeVisitResult(context, {
+        uri: "http://example.com/",
+        title: "example.com",
+        heuristic: true,
+      }),
+      makeVisitResult(context, {
+        uri: "http://example.com/test",
+        title: "test visit for http://example.com/test",
+      }),
+    ],
+  });
+
+  await cleanupPlaces();
+  UrlbarPrefs.clear("autoFill.adaptiveHistory.enabled");
+  UrlbarPrefs.clear("autoFill.adaptiveHistory.useCountThreshold");
+});