From 16b8c06bbff13308033b0cffef3eba9bc619236f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 11 Nov 2020 08:54:07 -0600 Subject: [PATCH] chore: cherry-pick daad98ce from chromium (#26430) Fixes #26419 The "IsOS/IsAtLeastOS/IsAtMostOS" functions are driven from the Darwin version number, which is always accurate. Adjust the SysInfo::OperatingSystemVersionNumbers() function to return accurate version numbers (or the best we can deduce) so that all version numbers returned by helper functions are accurate and consistent. Bug: 1101439 Bug: 1108832 Change-Id: I2ca92478d76bf572cc55875cba443f4978482d10 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315490 Reviewed-by: Mark Mentovai Commit-Queue: Avi Drissman Cr-Commit-Position: refs/heads/master@{#791491} --- patches/chromium/.patches | 1 + ..._macos_os_version_numbers_consistent.patch | 43 +++++++++++++++++++ spec/api-process-spec.js | 3 ++ 3 files changed, 47 insertions(+) create mode 100644 patches/chromium/make_macos_os_version_numbers_consistent.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 3ac90939597be..1259cd0499d46 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -151,3 +151,4 @@ cherry-pick-229fdaf8fc05.patch cherry-pick-1ed869ad4bb3.patch cherry-pick-8f24f935c903.patch crashpad-initialize-logging.patch +make_macos_os_version_numbers_consistent.patch diff --git a/patches/chromium/make_macos_os_version_numbers_consistent.patch b/patches/chromium/make_macos_os_version_numbers_consistent.patch new file mode 100644 index 0000000000000..3b308d89df2ab --- /dev/null +++ b/patches/chromium/make_macos_os_version_numbers_consistent.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Avi Drissman +Date: Sat, 25 Jul 2020 17:38:19 +0000 +Subject: Make macOS OS version numbers consistent + +The "IsOS/IsAtLeastOS/IsAtMostOS" functions are driven from the Darwin +version number, which is always accurate. Adjust the +SysInfo::OperatingSystemVersionNumbers() function to return accurate +version numbers (or the best we can deduce) so that all version +numbers returned by helper functions are accurate and consistent. + +Bug: 1101439 +Bug: 1108832 +Change-Id: I2ca92478d76bf572cc55875cba443f4978482d10 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315490 +Reviewed-by: Mark Mentovai +Commit-Queue: Avi Drissman +Cr-Commit-Position: refs/heads/master@{#791491} + +diff --git a/base/system/sys_info_mac.mm b/base/system/sys_info_mac.mm +index 265d7678060fd003b4f28b2b50f8a80be5253c88..3becbd628e19084de6fd87de4adcdec2c5af67b4 100644 +--- a/base/system/sys_info_mac.mm ++++ b/base/system/sys_info_mac.mm +@@ -62,6 +62,19 @@ void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version, + *major_version = version.majorVersion; + *minor_version = version.minorVersion; + *bugfix_version = version.patchVersion; ++ ++ // TODO(https://crbug.com/1108832): If an app is built against a pre-macOS ++ // 11.0 SDK, macOS will lie as to what version it is, saying that it is macOS ++ // "10.16" rather than "11.0". The problem is that the "IsOS/IsAtLeastOS/ ++ // IsAtMostOS" functions are driven from the Darwin version number, which ++ // isn't lied about, and therefore the values returned by this function and ++ // those functions are inconsistent. Therefore, unlie about these values. ++ ++ if (*major_version == 10 && *minor_version >= 16) { ++ *major_version = *minor_version - 5; ++ *minor_version = *bugfix_version; ++ *bugfix_version = 0; ++ } + } + + // static diff --git a/spec/api-process-spec.js b/spec/api-process-spec.js index 6eada5c945feb..03b83b08b3284 100644 --- a/spec/api-process-spec.js +++ b/spec/api-process-spec.js @@ -70,6 +70,9 @@ describe('process module', () => { describe('process.getSystemVersion()', () => { it('returns a string', () => { expect(process.getSystemVersion()).to.be.a('string'); + if (process.platform === 'darwin') { + expect(process.getSystemVersion()).to.not.equal('10.16'); // #26419 + } }); });