Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Remove flag data for default-enabled features (#2297)
Browse files Browse the repository at this point in the history
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] mdn/browser-compat-data#16637
[2] https://matrix.to/#/!cGYYDEJwjktUBMSTQT:mozilla.org/$JTWeMpzNMULBTZcx-pWFnUNX7DIzE5xPySd70Kpr-MU?via=mozilla.org&via=matrix.org&via=igalia.com),
  • Loading branch information
jugglinmike committed Sep 14, 2022
1 parent e52bb2f commit d5aaa43
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 5 deletions.
26 changes: 26 additions & 0 deletions unittest/unit/bcd.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}}
},
Expand Down
17 changes: 14 additions & 3 deletions unittest/unit/find-missing-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -85,14 +90,16 @@ describe('find-missing-features', () => {
'api.DummyAPI',
'api.DummyAPI.dummy',
'api.ExperimentalInterface',
'api.UnflaggedInterface',
'api.UnprefixedInterface',
'api.NullAPI',
'api.RemovedInterface',
'api.SuperNewInterface',
'css.properties.font-face',
'css.properties.font-style',
'javascript.builtins.Date'
],
total: 19
total: 21
};

assert.deepEqual(getMissing(bcd, tests), expected);
Expand Down Expand Up @@ -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
});
});

Expand All @@ -148,14 +157,16 @@ describe('find-missing-features', () => {
'api.DummyAPI',
'api.DummyAPI.dummy',
'api.ExperimentalInterface',
'api.UnflaggedInterface',
'api.UnprefixedInterface',
'api.NullAPI',
'api.RemovedInterface',
'api.SuperNewInterface',
'css.properties.font-face',
'css.properties.font-style',
'javascript.builtins.Date'
],
total: 19
total: 21
});

assert.isTrue(
Expand Down
89 changes: 89 additions & 0 deletions unittest/unit/update-bcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -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': {
Expand Down Expand Up @@ -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'}}}
},
Expand Down
12 changes: 10 additions & 2 deletions update-bcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d5aaa43

Please sign in to comment.