From 2d42120dfce04f2984b7ca719c659cc3cb1af14b Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 7 May 2022 17:26:17 -0500 Subject: Issue #23 - Hardcode platformVersion to 52.9 and introduce runtimeVersion with the real version. --- components/addons/src/AddonManager.jsm | 2 +- components/addons/src/AddonRepository.jsm | 2 +- components/addons/src/AddonUpdateChecker.jsm | 6 +++--- components/addons/src/XPIProvider.jsm | 4 ++-- components/blocklist/nsBlocklistService.js | 6 +++--- components/urlformatter/nsURLFormatter.js | 2 +- modules/UpdateUtils.jsm | 2 +- system/runtime/nsAppRunner.cpp | 19 ++++++++++++++----- xpcom/components/ManifestParser.cpp | 10 ++++++++++ xpcom/system/nsIPlatformInfo.idl | 10 ++++++++-- 10 files changed, 44 insertions(+), 19 deletions(-) diff --git a/components/addons/src/AddonManager.jsm b/components/addons/src/AddonManager.jsm index 44aa11d65..950a756b2 100644 --- a/components/addons/src/AddonManager.jsm +++ b/components/addons/src/AddonManager.jsm @@ -779,7 +779,7 @@ var AddonManagerInternal = { Services.prefs.setCharPref(PREF_EM_LAST_APP_VERSION, Services.appinfo.version); Services.prefs.setCharPref(PREF_EM_LAST_PLATFORM_VERSION, - Services.appinfo.platformVersion); + Services.appinfo.runtimeVersion); Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, (appChanged === undefined ? 0 : -1)); this.validateBlocklist(); diff --git a/components/addons/src/AddonRepository.jsm b/components/addons/src/AddonRepository.jsm index 41fb5c06d..a857a5530 100644 --- a/components/addons/src/AddonRepository.jsm +++ b/components/addons/src/AddonRepository.jsm @@ -1545,7 +1545,7 @@ this.AddonRepository = { let appVersion = null; if (override.appID == TOOLKIT_ID) - appVersion = aPlatformVersion || Services.appinfo.platformVersion; + appVersion = aPlatformVersion || Services.appinfo.runtimeVersion; else appVersion = aAppVersion || Services.appinfo.version; diff --git a/components/addons/src/AddonUpdateChecker.jsm b/components/addons/src/AddonUpdateChecker.jsm index bfff493bf..0001f921a 100644 --- a/components/addons/src/AddonUpdateChecker.jsm +++ b/components/addons/src/AddonUpdateChecker.jsm @@ -494,7 +494,7 @@ function parseJSONManifest(aId, aUpdateKey, aRequest, aManifestData) { } let appID = Services.appinfo.ID; - let platformVersion = Services.appinfo.platformVersion; + let platformVersion = Services.appinfo.runtimeVersion; // The list of available updates let updates = getProperty(addon, "updates", "array", []); @@ -854,7 +854,7 @@ this.AddonUpdateChecker = { if (!aAppVersion) aAppVersion = Services.appinfo.version; if (!aPlatformVersion) - aPlatformVersion = Services.appinfo.platformVersion; + aPlatformVersion = Services.appinfo.runtimeVersion; for (let update of aUpdates) { if (Services.vc.compare(update.version, aVersion) == 0) { @@ -897,7 +897,7 @@ this.AddonUpdateChecker = { if (!aAppVersion) aAppVersion = Services.appinfo.version; if (!aPlatformVersion) - aPlatformVersion = Services.appinfo.platformVersion; + aPlatformVersion = Services.appinfo.runtimeVersion; let blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. getService(Ci.nsIBlocklistService); diff --git a/components/addons/src/XPIProvider.jsm b/components/addons/src/XPIProvider.jsm index ed12659c9..4d203b573 100644 --- a/components/addons/src/XPIProvider.jsm +++ b/components/addons/src/XPIProvider.jsm @@ -6168,7 +6168,7 @@ UpdateChecker.prototype = { if ((this.appVersion && Services.vc.compare(this.appVersion, Services.appinfo.version) != 0) || (this.platformVersion && - Services.vc.compare(this.platformVersion, Services.appinfo.platformVersion) != 0)) { + Services.vc.compare(this.platformVersion, Services.appinfo.runtimeVersion) != 0)) { compatUpdate = AUC.getCompatibilityUpdate(aUpdates, this.addon.version, false, this.appVersion, this.platformVersion, @@ -6350,7 +6350,7 @@ AddonInternal.prototype = { if (!aAppVersion) aAppVersion = Services.appinfo.version; if (!aPlatformVersion) - aPlatformVersion = Services.appinfo.platformVersion; + aPlatformVersion = Services.appinfo.runtimeVersion; let version; if (app.id == Services.appinfo.ID) { diff --git a/components/blocklist/nsBlocklistService.js b/components/blocklist/nsBlocklistService.js index 188fdfb38..724422494 100644 --- a/components/blocklist/nsBlocklistService.js +++ b/components/blocklist/nsBlocklistService.js @@ -387,7 +387,7 @@ Blocklist.prototype = { if (!appVersion) appVersion = gApp.version; if (!toolkitVersion) - toolkitVersion = gApp.platformVersion; + toolkitVersion = gApp.runtimeVersion; var blItem = this._findMatchingAddonEntry(addonEntries, addon); if (!blItem) @@ -529,7 +529,7 @@ Blocklist.prototype = { dsURI = dsURI.replace(/%OS_VERSION%/g, gOSVersion); dsURI = dsURI.replace(/%LOCALE%/g, getLocale()); dsURI = dsURI.replace(/%CHANNEL%/g, "@MOZ_UPDATE_CHANNEL@"); - dsURI = dsURI.replace(/%PLATFORM_VERSION%/g, gApp.platformVersion); + dsURI = dsURI.replace(/%PLATFORM_VERSION%/g, gApp.runtimeVersion); dsURI = dsURI.replace(/%DISTRIBUTION%/g, getDistributionPrefValue(PREF_APP_DISTRIBUTION)); dsURI = dsURI.replace(/%DISTRIBUTION_VERSION%/g, @@ -1137,7 +1137,7 @@ Blocklist.prototype = { if (!appVersion) appVersion = gApp.version; if (!toolkitVersion) - toolkitVersion = gApp.platformVersion; + toolkitVersion = gApp.runtimeVersion; for (var blockEntry of pluginEntries) { var matchFailed = false; diff --git a/components/urlformatter/nsURLFormatter.js b/components/urlformatter/nsURLFormatter.js index 8bb68bc45..8a199e808 100644 --- a/components/urlformatter/nsURLFormatter.js +++ b/components/urlformatter/nsURLFormatter.js @@ -97,7 +97,7 @@ nsURLFormatterService.prototype = { VERSION: function() { return this.appInfo.version; }, MAJOR_VERSION: function() { return this.appInfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); }, APPBUILDID: function() { return this.appInfo.appBuildID; }, - PLATFORMVERSION: function() { return this.appInfo.platformVersion; }, + PLATFORMVERSION: function() { return this.appInfo.runtimeVersion; }, PLATFORMBUILDID: function() { return this.appInfo.platformBuildID; }, APP: function() { return this.appInfo.name.toLowerCase().replace(/ /, ""); }, OS: function() { return this.appInfo.OS; }, diff --git a/modules/UpdateUtils.jsm b/modules/UpdateUtils.jsm index 5e3a2e100..48d36e0f6 100644 --- a/modules/UpdateUtils.jsm +++ b/modules/UpdateUtils.jsm @@ -78,7 +78,7 @@ this.UpdateUtils = { [/%WIDGET_TOOLKIT%/g, "@MOZ_WIDGET_TOOLKIT@"], [/%CHANNEL%/g, this.UpdateChannel], [/%CUSTOM%/g, custom], - [/%PLATFORM_VERSION%/g, Services.appinfo.platformVersion], + [/%PLATFORM_VERSION%/g, Services.appinfo.runtimeVersion], [/%DISTRIBUTION%/g, distribution], [/%DISTRIBUTION_VERSION%/g, distributionVersion], [/%LOCALE%/g, this.Locale] diff --git a/system/runtime/nsAppRunner.cpp b/system/runtime/nsAppRunner.cpp index 4071e7730..e0e9885ff 100644 --- a/system/runtime/nsAppRunner.cpp +++ b/system/runtime/nsAppRunner.cpp @@ -175,7 +175,8 @@ extern void InstallSignalHandlers(const char *ProgramName); int gArgc; char **gArgv; -static const char gToolkitVersion[] = NS_STRINGIFY(GRE_MILESTONE); +static const char gToolkitVersion[] = "52.9.0"; +static const char gRuntimeVersion[] = NS_STRINGIFY(GRE_MILESTONE); static const char gToolkitBuildID[] = NS_STRINGIFY(MOZ_BUILDID); static nsIProfileLock* gProfileLock; @@ -683,6 +684,14 @@ nsXULAppInfo::GetVersion(nsACString& aResult) return NS_OK; } +NS_IMETHODIMP +nsXULAppInfo::GetRuntimeVersion(nsACString& aResult) +{ + aResult.Assign(gRuntimeVersion); + + return NS_OK; +} + NS_IMETHODIMP nsXULAppInfo::GetPlatformVersion(nsACString& aResult) { @@ -2800,11 +2809,11 @@ XREMain::XRE_mainInit(bool* aExitFlag) SetAllocatedString(mAppData->maxVersion, "1.*"); } - if (mozilla::Version(mAppData->minVersion) > gToolkitVersion || - mozilla::Version(mAppData->maxVersion) < gToolkitVersion) { - Output(true, "Error: Platform version '%s' is not compatible with\n" + if (mozilla::Version(mAppData->minVersion) > gRuntimeVersion || + mozilla::Version(mAppData->maxVersion) < gRuntimeVersion) { + Output(true, "Error: Runtime version '%s' is not compatible with\n" "minVersion >= %s\nmaxVersion <= %s\n", - gToolkitVersion, + gRuntimeVersion, mAppData->minVersion, mAppData->maxVersion); return 1; } diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp index 8d94a1545..e8e7a4467 100644 --- a/xpcom/components/ManifestParser.cpp +++ b/xpcom/components/ManifestParser.cpp @@ -465,6 +465,7 @@ ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf, NS_NAMED_LITERAL_STRING(kRemoteRequired, "remoterequired"); NS_NAMED_LITERAL_STRING(kApplication, "application"); NS_NAMED_LITERAL_STRING(kAppVersion, "appversion"); + NS_NAMED_LITERAL_STRING(kRuntimeVersion, "runtimeversion"); NS_NAMED_LITERAL_STRING(kGeckoVersion, "platformversion"); NS_NAMED_LITERAL_STRING(kOs, "os"); NS_NAMED_LITERAL_STRING(kOsVersion, "osversion"); @@ -479,6 +480,7 @@ ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf, nsAutoString appID; nsAutoString appVersion; + nsAutoString runtimeVersion; nsAutoString geckoVersion; nsAutoString osTarget; nsAutoString abi; @@ -502,6 +504,11 @@ ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf, CopyUTF8toUTF16(s, appVersion); } + rv = xapp->GetRuntimeVersion(s); + if (NS_SUCCEEDED(rv)) { + CopyUTF8toUTF16(s, runtimeVersion); + } + rv = xapp->GetPlatformVersion(s); if (NS_SUCCEEDED(rv)) { CopyUTF8toUTF16(s, geckoVersion); @@ -634,6 +641,7 @@ ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf, bool ok = true; TriState stAppVersion = eUnspecified; + TriState stRuntimeVersion = eUnspecified; TriState stGeckoVersion = eUnspecified; TriState stApp = eUnspecified; TriState stOsVersion = eUnspecified; @@ -654,6 +662,7 @@ ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf, CheckStringFlag(kProcess, wtoken, process, stProcess) || CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) || CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion) || + CheckVersionFlag(kRuntimeVersion, wtoken, runtimeVersion, stRuntimeVersion) || CheckVersionFlag(kGeckoVersion, wtoken, geckoVersion, stGeckoVersion)) { continue; } @@ -699,6 +708,7 @@ ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf, if (!ok || stApp == eBad || stAppVersion == eBad || + stRuntimeVersion == eBad || stGeckoVersion == eBad || stOs == eBad || stOsVersion == eBad || diff --git a/xpcom/system/nsIPlatformInfo.idl b/xpcom/system/nsIPlatformInfo.idl index fba78b6ec..086a86594 100644 --- a/xpcom/system/nsIPlatformInfo.idl +++ b/xpcom/system/nsIPlatformInfo.idl @@ -4,11 +4,17 @@ #include "nsISupports.idl" -[scriptable, uuid(ab6650cf-0806-4aea-b8f2-40fdae74f1cc)] +[scriptable, uuid(4700f5a9-0a54-4ba7-8642-5410eca17785)] interface nsIPlatformInfo : nsISupports { /** - * The version of the XULRunner platform. + * The TRUE version of the runtime. + */ + readonly attribute ACString runtimeVersion; + + /** + * Deprecated: The version of the XULRunner platform. + * Always returns "52.9.0" */ readonly attribute ACString platformVersion; -- cgit v1.2.3