From 868833e264e8db9d8eddef3ad4b17aa1cd355c8f Mon Sep 17 00:00:00 2001 From: hanna alemu Date: Wed, 29 May 2024 14:43:17 +0000 Subject: [PATCH] Bug 1897321 - Add minVersion variable to whatsNewPage Nimbus feature r=omc-reviewers,firefox-desktop-core-reviewers ,aminomancer Differential Revision: https://phabricator.services.mozilla.com/D211892 --- browser/app/profile/firefox.js | 2 ++ .../components/BrowserContentHandler.sys.mjs | 17 ++++++++++++++--- toolkit/components/nimbus/FeatureManifest.yaml | 6 ++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index e691e0521c5a..a1516796431f 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -3062,7 +3062,9 @@ pref("browser.backup.sqlite.step_delay_ms", 250); pref("browser.profiles.enabled", false); pref("startup.homepage_override_url_nimbus", ""); +// These prefs are referring to the Fx update version pref("startup.homepage_override_nimbus_maxVersion", ""); +pref("startup.homepage_override_nimbus_minVersion", ""); // Pref to enable the content relevancy feature. pref("toolkit.contentRelevancy.enabled", false); diff --git a/browser/components/BrowserContentHandler.sys.mjs b/browser/components/BrowserContentHandler.sys.mjs index 3ae02814acf8..71c37aa6044f 100644 --- a/browser/components/BrowserContentHandler.sys.mjs +++ b/browser/components/BrowserContentHandler.sys.mjs @@ -750,17 +750,28 @@ nsBrowserContentHandler.prototype = { const nimbusOverrideUrl = Services.urlFormatter.formatURLPref( "startup.homepage_override_url_nimbus" ); + // This defines the maximum allowed Fx update version to see the + // nimbus WNP. For ex, if maxVersion is set to 127 but user updates + // to 128, they will not qualify. const maxVersion = Services.prefs.getCharPref( "startup.homepage_override_nimbus_maxVersion", "" ); + // This defines the minimum allowed Fx update version to see the + // nimbus WNP. For ex, if minVersion is set to 126 but user updates + // to 124, they will not qualify. + const minVersion = Services.prefs.getCharPref( + "startup.homepage_override_nimbus_minVersion", + "" + ); let nimbusWNP; - // Update version should be less than or equal to maxVersion set by - // the experiment + // The update version should be less than or equal to maxVersion and + // greater or equal to minVersion set by the experiment. if ( nimbusOverrideUrl && - Services.vc.compare(update.appVersion, maxVersion) <= 0 + Services.vc.compare(update.appVersion, maxVersion) <= 0 && + Services.vc.compare(update.appVersion, minVersion) >= 0 ) { try { let uri = Services.io.newURI(nimbusOverrideUrl); diff --git a/toolkit/components/nimbus/FeatureManifest.yaml b/toolkit/components/nimbus/FeatureManifest.yaml index d3e03e004d4e..166462073fa5 100644 --- a/toolkit/components/nimbus/FeatureManifest.yaml +++ b/toolkit/components/nimbus/FeatureManifest.yaml @@ -1338,6 +1338,12 @@ whatsNewPage: setPref: branch: user pref: startup.homepage_override_nimbus_maxVersion + minVersion: + description: Minimum Firefox update version + type: string + setPref: + branch: user + pref: startup.homepage_override_nimbus_minVersion pbNewtab: description: "A Firefox Messaging System message for the pbNewtab message channel"