commit dd5b0029a7f61b32c82e18da2d37be2b060ec39f
parent 8d73b933b1a5af0cc15c2d680f077944780bf53d
Author: Daisuke Akatsuka <daisuke@birchill.co.jp>
Date: Thu, 23 Oct 2025 16:15:24 +0000
Bug 1995892: Increase the geolocation cache period to two hours r=adw
Differential Revision: https://phabricator.services.mozilla.com/D269699
Diffstat:
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/browser/components/urlbar/private/GeolocationUtils.sys.mjs b/browser/components/urlbar/private/GeolocationUtils.sys.mjs
@@ -15,7 +15,7 @@ ChromeUtils.defineLazyGetter(lazy, "logger", () =>
// Cache period for Merino's geolocation response. This is intentionally a small
// amount of time. See the `cachePeriodMs` discussion in `MerinoClient`.
-const GEOLOCATION_CACHE_PERIOD_MS = 120000; // 2 minutes
+const GEOLOCATION_CACHE_PERIOD_MS = 2 * 60 * 60 * 1000; // 2 hours.
// The mean Earth radius used in distance calculations.
const EARTH_RADIUS_KM = 6371.009;
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_weather.js b/browser/components/urlbar/tests/quicksuggest/unit/test_weather.js
@@ -918,7 +918,7 @@ add_task(async function merinoCache() {
);
// Set the date forward 0.5 minutes, which is shorter than the geolocation
- // cache period of 2 minutes and the weather cache period of 1 minute.
+ // cache period of 2 hours and the weather cache period of 1 minute.
dateNowStub.returns(startDateMs + 0.5 * 60 * 1000);
// Search 2: Firefox should use the cached responses, so it should not call
@@ -972,10 +972,12 @@ add_task(async function merinoCache() {
"accuweather provider should have been called on search 3"
);
- // Set the date forward 3 minutes.
- dateNowStub.returns(startDateMs + 3 * 60 * 1000);
+ // Set the date forward 1.5 hours that is still shorter than the geolocation
+ // period.
+ dateNowStub.returns(startDateMs + 1.5 * 60 * 60 * 1000);
- // Search 4: Firefox should call Merino for both weather and geolocation.
+ // Search 4: Firefox should still call Merino for the weather suggestion but
+ // not for geolocation.
info("Doing search 4");
callsByProvider = await doSearch({
query,
@@ -988,15 +990,41 @@ add_task(async function merinoCache() {
},
});
info("search 4 callsByProvider: " + JSON.stringify(callsByProvider));
+ Assert.ok(
+ !callsByProvider.geolocation,
+ "geolocation provider should not have been called on search 4"
+ );
+ Assert.equal(
+ callsByProvider.accuweather.length,
+ 1,
+ "accuweather provider should have been called on search 4"
+ );
+
+ // Set the date forward 3 hours.
+ dateNowStub.returns(startDateMs + 3 * 60 * 60 * 1000);
+
+ // Search 5: Firefox should call Merino for both weather and geolocation.
+ info("Doing search 5");
+ callsByProvider = await doSearch({
+ query,
+ expectedTitleL10n: {
+ id: "urlbar-result-weather-title",
+ args: {
+ city: "Waterloo",
+ region: "IA",
+ },
+ },
+ });
+ info("search 5 callsByProvider: " + JSON.stringify(callsByProvider));
Assert.equal(
callsByProvider.geolocation.length,
1,
- "geolocation provider should have been called on search 4"
+ "geolocation provider should have been called on search 5"
);
Assert.equal(
callsByProvider.accuweather.length,
1,
- "accuweather provider should have been called on search 4"
+ "accuweather provider should have been called on search 5"
);
sandbox.restore();