diff --git a/unittest/unit/bcd.test.js b/unittest/unit/bcd.test.js index 71705add7..9426f484a 100644 --- a/unittest/unit/bcd.test.js +++ b/unittest/unit/bcd.test.js @@ -76,6 +76,9 @@ export default { }, RemovedInterface: { __compat: {support: {chrome: {version_added: null}}} + }, + SuperNewInterface: { + __compat: {support: {chrome: {version_added: '100'}}} } }, browsers: { diff --git a/unittest/unit/find-missing-features.js b/unittest/unit/find-missing-features.js index e02b17692..80f58fea1 100644 --- a/unittest/unit/find-missing-features.js +++ b/unittest/unit/find-missing-features.js @@ -40,6 +40,7 @@ describe('find-missing-features', () => { 'api.ExperimentalInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-family', 'css.properties.font-face', 'javascript.builtins.Array', @@ -64,6 +65,7 @@ describe('find-missing-features', () => { 'api.TryingOutInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-family', 'css.properties.font-face', 'javascript.builtins.Array', @@ -91,10 +93,11 @@ describe('find-missing-features', () => { 'api.ExperimentalInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-face', 'javascript.builtins.Date' ], - total: 17 + total: 18 }); }); @@ -118,9 +121,10 @@ describe('find-missing-features', () => { 'api.DummyAPI.dummy', 'api.ExperimentalInterface', 'api.NullAPI', - 'api.RemovedInterface' + 'api.RemovedInterface', + 'api.SuperNewInterface' ], - total: 13 + total: 14 }); }); @@ -138,10 +142,11 @@ describe('find-missing-features', () => { 'api.ExperimentalInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-face', 'javascript.builtins.Date' ], - total: 17 + total: 18 }); assert.isTrue( diff --git a/unittest/unit/update-bcd.js b/unittest/unit/update-bcd.js index 7b8121df9..f678326d7 100644 --- a/unittest/unit/update-bcd.js +++ b/unittest/unit/update-bcd.js @@ -83,6 +83,11 @@ const reports = [ info: {exposure: 'Window'}, result: true }, + { + name: 'api.SuperNewInterface', + info: {exposure: 'Window'}, + result: false + }, { name: 'css.properties.font-family', info: {exposure: 'Window'}, @@ -158,6 +163,11 @@ const reports = [ info: {exposure: 'Window'}, result: false }, + { + name: 'api.SuperNewInterface', + info: {exposure: 'Window'}, + result: false + }, { name: 'css.properties.font-family', info: {exposure: 'Window'}, @@ -227,6 +237,11 @@ const reports = [ info: {exposure: 'Window'}, result: true }, + { + name: 'api.SuperNewInterface', + info: {exposure: 'Window'}, + result: false + }, { name: 'css.properties.font-family', info: {exposure: 'Window'}, @@ -331,6 +346,7 @@ describe('BCD updater', () => { ['api.ExperimentalInterface', true], ['api.NullAPI', null], ['api.RemovedInterface', true], + ['api.SuperNewInterface', false], ['css.properties.font-family', true], ['css.properties.font-face', true] ]) @@ -351,6 +367,7 @@ describe('BCD updater', () => { ['api.NewInterfaceNotInBCD', false], ['api.NullAPI', null], ['api.RemovedInterface', false], + ['api.SuperNewInterface', false], ['css.properties.font-family', true], ['css.properties.font-face', true] ]) @@ -521,6 +538,20 @@ describe('BCD updater', () => { ] ]) ], + [ + 'api.SuperNewInterface', + new Map([ + [ + 'chrome', + new Map([ + ['82', null], + ['83', false], + ['84', false], + ['85', false] + ]) + ] + ]) + ], [ 'css.properties.font-family', new Map([ @@ -596,6 +627,9 @@ describe('BCD updater', () => { {version_added: '85'} ] }, + 'api.SuperNewInterface': { + chrome: [{version_added: false}] + }, 'css.properties.font-family': {chrome: [{version_added: '84'}]}, 'css.properties.font-face': {chrome: []} }; @@ -739,6 +773,9 @@ describe('BCD updater', () => { // {version_added: '≤83', version_removed: '84'} // ]}} __compat: {support: {chrome: {version_added: null}}} + }, + SuperNewInterface: { + __compat: {support: {chrome: {version_added: '100'}}} } }, browsers: { diff --git a/update-bcd.js b/update-bcd.js index a616940ac..14d80ae4e 100644 --- a/update-bcd.js +++ b/update-bcd.js @@ -316,7 +316,34 @@ const update = (bcd, supportMatrix, filter) => { continue; } + let dataIsOlder = false; if ( + inferredStatement.version_added === false && + typeof simpleStatement.version_added === 'string' + ) { + // Make sure not to update BCD if it is set to a version newer than we have in our data + + for (const [version, result] of Array.from( + versionMap.entries() + ).reverse()) { + if ( + result !== null && + compareVersions.compare( + version, + simpleStatement.version_added.replace('≤', ''), + '<=' + ) + ) { + // A version we have data for is the same or newer than the version in BCD + dataIsOlder = true; + break; + } + } + } + + if (dataIsOlder) { + continue; + } else if ( typeof simpleStatement.version_added === 'string' && typeof inferredStatement.version_added === 'string' && inferredStatement.version_added.includes('≤')