browser-compat-data
browser-compat-data copied to clipboard
Fix mirror script when upstream set to newer version than downstream
This PR fixes the mirorring script to set the downstream browser data to {version_added: false}
(AKA, don't copy notes and partial_implementation
) if the upstream is set to a newer version than the latest downstream browser. For example, if a feature was implemented in Chrome 121 and we're mirroring to Samsung Internet, but the latest version of Samsung Internet lines up with Chrome 115, it will be set to simply false
.
Fixes #21690.
Note: some statements can now be set to mirror due to this change, so the lint is failing. I will apply these changes once the PR is approved.
I think this PR adds the additional check to resolve https://github.com/mdn/browser-compat-data/issues/21690:
if (newData.version_added === false && sourceData.version_added !== false) {
// If the feature is added in an upstream version newer than available in the downstream browser, don't copy notes, etc.
return { version_added: false };
}
I reviewed this bit by writing the following test code which I think we cannot add to the tests because the browser release data is a moving target and we don't have mocks for it:
it('Dont copy notes etc. if feature is added in an upstream version newer than available in the downstream browser', () => {
const support: InternalSupportBlock = {
chrome_android: {
version_added: '122',
partial_implementation: true,
notes: 'This feature has quirks.',
},
};
const mirrored = mirrorSupport('samsunginternet_android', support);
assert.deepEqual(mirrored, { version_added: false });
});
The test code fails on main and passes with this PR, so that seems good. (I don't know why some code was moved around, though)
Then there is something that this code also produces:
"firefox": {
"version_added": "preview",
"partial_implementation": true,
"notes": "Currently supported on Linux and Windows only."
},
"firefox_android": "mirror",
Instead of what we have now:
"firefox": {
"version_added": "preview",
"partial_implementation": true,
"notes": "Currently supported on Linux and Windows only."
},
"firefox_android": {
"version_added": false
},
I think that's wrong. I think it shouldn't mirror. So, the CI failure is correct but I think the solution is not to change the data. It is to fix the mirror script. Maybe this problem is only due to "preview"?
we cannot add to the tests because the browser release data is a moving target and we don't have mocks for it
Yeah, we should be using mock browser data when running unittests in BCD. That's what the collector does.
I think that's wrong. I think it shouldn't mirror. So, the CI failure is correct but I think the solution is not to change the data. It is to fix the mirror script. Maybe this problem is only due to "preview"?
Hmm...this is a tricky one. On one hand, I'd say that the mirroring script is outputting the correct results; if the downstream browser doesn't support preview editions, and the upstream browser is set to "preview", the downstream browser should indeed become "false". On the other hand, if "preview" is replaced with a version number down the line, and the downstream browser is still set to mirror, the notes and partial implementation will get copied down.
Maybe this isn't much of an issue since we're running the collector on mobile browsers again?