diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index da2c5fa31cfa..207abc2228d8 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -99,9 +99,7 @@ # include "nsCocoaFeatures.h" #endif -#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID) -# include "mozilla/browser/NimbusFeatures.h" -#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID +#include "mozilla/browser/NimbusFeatures.h" //----------------------------------------------------------------------------- #include "mozilla/net/HttpChannelChild.h" @@ -129,10 +127,8 @@ #define NS_HTTP_PROTOCOL_FLAGS \ (URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE) -#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID) -# define UA_EXPERIMENT_NAME "firefox100"_ns -# define UA_EXPERIMENT_VAR "firefoxVersion"_ns -#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID +#define UA_EXPERIMENT_NAME "firefox100"_ns +#define UA_EXPERIMENT_VAR "firefoxVersion"_ns //----------------------------------------------------------------------------- @@ -142,7 +138,6 @@ namespace mozilla::net { LazyLogModule gHttpLog("nsHttp"); -#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID) static void ExperimentUserAgentUpdated(const char* /* aNimbusPref */, void* aUserData) { MOZ_ASSERT(aUserData != nullptr); @@ -176,7 +171,6 @@ static void ExperimentUserAgentUpdated(const char* /* aNimbusPref */, aExperimentUserAgent->Truncate(); aExperimentUserAgent->AppendPrintf(uaFormat, firefoxVersion, firefoxVersion); } -#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID #ifdef ANDROID static nsCString GetDeviceModelId() { @@ -279,9 +273,7 @@ nsHttpHandler::nsHttpHandler() mUserAgentOverride.SetIsVoid(true); -#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID) mExperimentUserAgent.SetIsVoid(true); -#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID MOZ_ASSERT(!gHttpHandler, "HTTP handler already created!"); @@ -389,14 +381,12 @@ nsresult nsHttpHandler::Init() { gCallbackPrefs, this); PrefsChanged(nullptr); -#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID) // monitor Firefox Version Experiment enrollment NimbusFeatures::OnUpdate(UA_EXPERIMENT_NAME, UA_EXPERIMENT_VAR, ExperimentUserAgentUpdated, &mExperimentUserAgent); // Load the experiment state once for startup ExperimentUserAgentUpdated("", &mExperimentUserAgent); -#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID Telemetry::ScalarSet(Telemetry::ScalarID::NETWORKING_HTTP3_ENABLED, mHttp3Enabled); @@ -759,13 +749,11 @@ const nsCString& nsHttpHandler::UserAgent() { return mUserAgentOverride; } -#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID) if (!mExperimentUserAgent.IsVoid()) { LOG(("using Firefox 100 Experiment User-Agent : %s\n", mExperimentUserAgent.get())); return mExperimentUserAgent; } -#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID if (mUserAgentIsDirty) { BuildUserAgent(); diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 21e752b620b5..313de72be1c9 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -648,9 +648,7 @@ class nsHttpHandler final : public nsIHttpProtocolHandler, nsCString mSpoofedUserAgent; nsCString mUserAgentOverride; -#if defined(MOZ_BUILD_APP_IS_BROWSER) && !defined(ANDROID) nsCString mExperimentUserAgent; -#endif // MOZ_BUILD_APP_IS_BROWSER && !ANDROID bool mUserAgentIsDirty{true}; // true if mUserAgent should be rebuilt bool mAcceptLanguagesIsDirty{true}; diff --git a/toolkit/components/moz.build b/toolkit/components/moz.build index af472c0e41d9..ca48baaed16d 100644 --- a/toolkit/components/moz.build +++ b/toolkit/components/moz.build @@ -129,8 +129,7 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android": if CONFIG["MOZ_BUILD_APP"] == "browser": DIRS += ["normandy", "messaging-system"] -if CONFIG["MOZ_BUILD_APP"] in ["browser", "comm/mail"]: - DIRS += ["nimbus"] +DIRS += ["nimbus"] if CONFIG["MOZ_BACKGROUNDTASKS"]: DIRS += ["backgroundtasks"] diff --git a/toolkit/components/nimbus/ExperimentAPI.jsm b/toolkit/components/nimbus/ExperimentAPI.jsm index 475996b9f297..c28a7a7da807 100644 --- a/toolkit/components/nimbus/ExperimentAPI.jsm +++ b/toolkit/components/nimbus/ExperimentAPI.jsm @@ -291,11 +291,14 @@ const ExperimentAPI = { */ const NimbusFeatures = {}; for (let feature in FeatureManifest) { - XPCOMUtils.defineLazyGetter( - NimbusFeatures, - feature, - () => new _ExperimentFeature(feature) - ); + XPCOMUtils.defineLazyGetter(NimbusFeatures, feature, () => { + if (AppConstants.MOZ_BUILD_APP !== "browser") { + throw new Error( + `NimbusFeatures.${feature} APIs are only available for browser builds.` + ); + } + return new _ExperimentFeature(feature); + }); } class _ExperimentFeature { diff --git a/toolkit/components/nimbus/test/browser/browser.ini b/toolkit/components/nimbus/test/browser/browser.ini index 88bf3f20776b..e1f8b3057024 100644 --- a/toolkit/components/nimbus/test/browser/browser.ini +++ b/toolkit/components/nimbus/test/browser/browser.ini @@ -4,6 +4,9 @@ support-files = prefs = # This turns off the update interval for fetching recipes from Remote Settings app.normandy.run_interval_seconds=0 +skip-if = + toolkit == "android" + appname == "thunderbird" [browser_experiment_single_feature_enrollment.js] [browser_remotesettingsexperimentloader_remote_defaults.js] diff --git a/toolkit/components/nimbus/test/unit/xpcshell.ini b/toolkit/components/nimbus/test/unit/xpcshell.ini index 36c4a91701df..f7e3276a827c 100644 --- a/toolkit/components/nimbus/test/unit/xpcshell.ini +++ b/toolkit/components/nimbus/test/unit/xpcshell.ini @@ -1,9 +1,12 @@ [DEFAULT] head = head.js -tags = messaging-system +tags = nimbus firefox-appdir = browser support-files = reference_aboutwelcome_experiment_content.json +skip-if = + toolkit == "android" + appname == "thunderbird" [test_ExperimentManager_context.js] [test_ExperimentManager_enroll.js]