Skip to content

Commit

Permalink
Remove flag data for default-enabled features
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 1, 2022
1 parent 416b1b5 commit eefeb11
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 2 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
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 eefeb11

Please sign in to comment.