From d5aaa4349ef50fccab3278e76849900b9b56bf63 Mon Sep 17 00:00:00 2001 From: jugglinmike Date: Wed, 14 Sep 2022 03:18:15 -0400 Subject: [PATCH] Remove flag data for default-enabled features (#2297) A recent change in the BCD project policy stipulates that information about feature flags should be removed whenever a feature becomes supported by default [1]. Modify the `update-bcd` script to honor the new policy whenever new test results trigger that condition. Include a test for the case where positive test results are added for a feature that is already supported via a prefix. This patch intentionally doesn't change that behavior because prefixes "are part of the web platform that web developers have to deal with." [2] The test is to prevent regressions and emphasize the intention. [1] https://github.com/mdn/browser-compat-data/pull/16637 [2] https://matrix.to/#/!cGYYDEJwjktUBMSTQT:mozilla.org/$JTWeMpzNMULBTZcx-pWFnUNX7DIzE5xPySd70Kpr-MU?via=mozilla.org&via=matrix.org&via=igalia.com), --- unittest/unit/bcd.test.js | 26 ++++++++ unittest/unit/find-missing-features.js | 17 ++++- unittest/unit/update-bcd.ts | 89 ++++++++++++++++++++++++++ update-bcd.ts | 12 +++- 4 files changed, 139 insertions(+), 5 deletions(-) diff --git a/unittest/unit/bcd.test.js b/unittest/unit/bcd.test.js index d5909318b..6dc1ace2d 100644 --- a/unittest/unit/bcd.test.js +++ b/unittest/unit/bcd.test.js @@ -79,6 +79,32 @@ export default { } } }, + UnflaggedInterface: { + __compat: { + support: { + chrome: [ + { + version_added: '83', + flags: {}, + notes: 'Not supported on Windows XP.' + } + ] + } + } + }, + UnprefixedInterface: { + __compat: { + support: { + chrome: [ + { + version_added: '83', + prefix: 'webkit', + notes: 'Not supported on Windows XP.' + } + ] + } + } + }, NullAPI: { __compat: {support: {chrome: {version_added: '80'}}} }, diff --git a/unittest/unit/find-missing-features.js b/unittest/unit/find-missing-features.js index 4b0ea4d8f..b1bce4355 100644 --- a/unittest/unit/find-missing-features.js +++ b/unittest/unit/find-missing-features.js @@ -30,6 +30,8 @@ describe('find-missing-features', () => { 'api.DummyAPI', 'api.DummyAPI.dummy', 'api.ExperimentalInterface', + 'api.UnflaggedInterface', + 'api.UnprefixedInterface', 'api.NullAPI', 'api.RemovedInterface', 'api.SuperNewInterface', @@ -56,6 +58,9 @@ describe('find-missing-features', () => { 'api.DummyAPI.dummy', 'api.ExperimentalInterface', 'api.TryingOutInterface', + 'api.UnflaggedInterface', + 'api.UnprefixedInterface', + 'api.webkitUnprefixedInterface', 'api.NullAPI', 'api.RemovedInterface', 'api.SuperNewInterface', @@ -85,6 +90,8 @@ describe('find-missing-features', () => { 'api.DummyAPI', 'api.DummyAPI.dummy', 'api.ExperimentalInterface', + 'api.UnflaggedInterface', + 'api.UnprefixedInterface', 'api.NullAPI', 'api.RemovedInterface', 'api.SuperNewInterface', @@ -92,7 +99,7 @@ describe('find-missing-features', () => { 'css.properties.font-style', 'javascript.builtins.Date' ], - total: 19 + total: 21 }; assert.deepEqual(getMissing(bcd, tests), expected); @@ -128,11 +135,13 @@ describe('find-missing-features', () => { 'api.DummyAPI', 'api.DummyAPI.dummy', 'api.ExperimentalInterface', + 'api.UnflaggedInterface', + 'api.UnprefixedInterface', 'api.NullAPI', 'api.RemovedInterface', 'api.SuperNewInterface' ], - total: 14 + total: 16 }); }); @@ -148,6 +157,8 @@ describe('find-missing-features', () => { 'api.DummyAPI', 'api.DummyAPI.dummy', 'api.ExperimentalInterface', + 'api.UnflaggedInterface', + 'api.UnprefixedInterface', 'api.NullAPI', 'api.RemovedInterface', 'api.SuperNewInterface', @@ -155,7 +166,7 @@ describe('find-missing-features', () => { 'css.properties.font-style', 'javascript.builtins.Date' ], - total: 19 + total: 21 }); assert.isTrue( diff --git a/unittest/unit/update-bcd.ts b/unittest/unit/update-bcd.ts index 7c987fa1c..4c9c7a0c2 100644 --- a/unittest/unit/update-bcd.ts +++ b/unittest/unit/update-bcd.ts @@ -67,6 +67,16 @@ const reports: Report[] = [ exposure: 'Window', result: true }, + { + name: 'api.UnflaggedInterface', + exposure: 'Window', + result: null + }, + { + name: 'api.UnprefixedInterface', + exposure: 'Window', + result: null + }, { name: 'api.NullAPI', exposure: 'Window', @@ -147,6 +157,16 @@ const reports: Report[] = [ exposure: 'Window', result: true }, + { + name: 'api.UnflaggedInterface', + exposure: 'Window', + result: true + }, + { + name: 'api.UnprefixedInterface', + exposure: 'Window', + result: true + }, { name: 'api.NewInterfaceNotInBCD', exposure: 'Window', @@ -226,6 +246,16 @@ const reports: Report[] = [ exposure: 'Window', result: true }, + { + name: 'api.UnflaggedInterface', + exposure: 'Window', + result: true + }, + { + name: 'api.UnprefixedInterface', + exposure: 'Window', + result: true + }, { name: 'api.NewInterfaceNotInBCD', exposure: 'Window', @@ -353,6 +383,8 @@ describe('BCD updater', () => { ['api.AudioContext.close', false], ['api.DeprecatedInterface', true], ['api.ExperimentalInterface', true], + ['api.UnflaggedInterface', null], + ['api.UnprefixedInterface', null], ['api.NullAPI', null], ['api.RemovedInterface', true], ['api.SuperNewInterface', false], @@ -374,6 +406,8 @@ describe('BCD updater', () => { ['api.AudioContext.close', false], ['api.DeprecatedInterface', true], ['api.ExperimentalInterface', true], + ['api.UnflaggedInterface', true], + ['api.UnprefixedInterface', true], ['api.NewInterfaceNotInBCD', false], ['api.NullAPI', null], ['api.RemovedInterface', false], @@ -511,6 +545,34 @@ describe('BCD updater', () => { ] ]) ], + [ + 'api.UnflaggedInterface', + new Map([ + [ + 'chrome', + new Map([ + ['82', null], + ['83', null], + ['84', true], + ['85', true] + ]) + ] + ]) + ], + [ + 'api.UnprefixedInterface', + new Map([ + [ + 'chrome', + new Map([ + ['82', null], + ['83', null], + ['84', true], + ['85', true] + ]) + ] + ]) + ], [ 'api.NewInterfaceNotInBCD', new Map([ @@ -648,6 +710,8 @@ describe('BCD updater', () => { chrome: [{version_added: '0> ≤83', version_removed: '85'}] }, 'api.ExperimentalInterface': {chrome: [{version_added: '0> ≤83'}]}, + 'api.UnflaggedInterface': {chrome: [{version_added: '0> ≤84'}]}, + 'api.UnprefixedInterface': {chrome: [{version_added: '0> ≤84'}]}, 'api.NewInterfaceNotInBCD': {chrome: [{version_added: '85'}]}, 'api.NullAPI': {chrome: []}, 'api.RemovedInterface': { @@ -793,6 +857,31 @@ describe('BCD updater', () => { } } }, + UnflaggedInterface: { + __compat: { + support: { + chrome: { + version_added: '≤84' + } + } + } + }, + UnprefixedInterface: { + __compat: { + support: { + chrome: [ + { + version_added: '≤84' + }, + { + version_added: '83', + prefix: 'webkit', + notes: 'Not supported on Windows XP.' + } + ] + } + } + }, NullAPI: { __compat: {support: {chrome: {version_added: '80'}}} }, diff --git a/update-bcd.ts b/update-bcd.ts index 192c52a71..84ca1804f 100644 --- a/update-bcd.ts +++ b/update-bcd.ts @@ -363,10 +363,18 @@ export const update = ( inferredStatement.version_added = inferredStatement.version_added.replace('0> ', ''); } - allStatements.unshift(inferredStatement); + // Remove flag data for features which are enabled by default. + // + // See https://github.com/mdn/browser-compat-data/pull/16637 + const nonFlagStatements = allStatements.filter( + (statement) => !('flags' in statement) + ); entry.__compat.support[browser] = - allStatements.length === 1 ? allStatements[0] : allStatements; + nonFlagStatements.length === 0 + ? inferredStatement + : [inferredStatement].concat(nonFlagStatements); modified = true; + continue; }