Skip to content

Commit

Permalink
Manually map Safari versions in getMatchingBrowserVersion (#16594)
Browse files Browse the repository at this point in the history
* Manually map Safari versions in getMatchingBrowserVersion

This is not ideal, but it fixes the problem now. Tests are in place to
ensure that if we fix it in some other way, there's no observable
difference.

* Retain Safari/iOS 15/15.1 data for PerformanceNavigationTiming
  • Loading branch information
foolip authored Jul 14, 2022
1 parent 68e7d00 commit 734b667
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 16 deletions.
48 changes: 36 additions & 12 deletions api/PerformanceNavigationTiming.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -61,7 +63,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -97,7 +101,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -133,7 +139,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -169,7 +177,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -205,7 +215,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -241,7 +253,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -277,7 +291,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -313,7 +329,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -349,7 +367,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -385,7 +405,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -421,7 +443,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down
8 changes: 4 additions & 4 deletions scripts/release/mirror.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ describe('mirror', () => {
['1.2', '1'],
['1.3', '1'],
['2', '1'],
['3', '2'], // wrong, should be 1
['3', '2'],
['3.1', '2'],
['4', '3.2'], // ambiguous
['4', '3.2'],
['5', '4.2'],
['5.1', '6'],
['6', '6'],
['7', '8'], // wrong, should be 7
['7', '7'],
['8', '8'],
['9', '9'],
['9.1', '9.3'],
Expand All @@ -85,7 +85,7 @@ describe('mirror', () => {
['13.1', '13.4'],
['14', '14'],
['14.1', '14.5'],
['15', '15.1'], // wrong, should be 15
['15', '15'],
['15.1', '15.1'],
['15.2', '15.2'],
['15.3', '15.3'],
Expand Down
41 changes: 41 additions & 0 deletions scripts/release/mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ import compareVersions from 'compare-versions';
import bcd from '../../index.js';
const { browsers } = bcd;

/**
* @typedef {import('../types').Identifier} Identifier
* @typedef {import('../types').SupportStatement} SupportStatement
* @typedef {import('../types').ReleaseStatement} ReleaseStatement
*/

const matchingSafariVersions = new Map([
['≤4', '≤3'],
['1', '1'],
['1.1', '1'],
['1.2', '1'],
['1.3', '1'],
['2', '1'],
['3', '2'],
['3.1', '2'],
['4', '3.2'],
['5', '4.2'],
['5.1', '6'],
['9.1', '9.3'],
['10.1', '10.3'],
['11.1', '11.3'],
['12.1', '12.2'],
['13.1', '13.4'],
['14.1', '14.5'],
]);

/**
* @param {string} targetBrowser
* @param {string} sourceVersion
Expand All @@ -33,6 +59,21 @@ export const getMatchingBrowserVersion = (
}
/* c8 ignore stop */

if (targetBrowser === 'safari_ios') {
// The mapping between Safari macOS and iOS releases is complicated and
// cannot be entirely derived from the WebKit versions. After Safari 15
// the versions have been the same, so map earlier versions manually
// and then assume if the versions are identical it's also a match.
const v = matchingSafariVersions.get(sourceVersion);
if (v) {
return v;
}
if (sourceVersion in browserData.releases) {
return sourceVersion;
}
throw new Error(`Cannot find iOS version matching Safari ${sourceVersion}`);
}

const releaseKeys = Object.keys(browserData.releases);
releaseKeys.sort(compareVersions);

Expand Down

0 comments on commit 734b667

Please sign in to comment.