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

Remove flag data for default-enabled features #2297

Merged
merged 2 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'}]},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this 0> is kind of weird :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0> should not be appearing in output values, hmm...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub's "review" interface is obscuring the context a bit, so it may not be clear that this particular test is for the inferSupportStatements function. That may include 0> in its return value, but it may not be what you mean by "output," at least not from the perspective of someone using the update-bcd script.

The update function, on the other hand, contains a handful of statements intended to remove 0>. This patch exercises this replacement; disabling that code causes the test for the update function to fail (specifically for the UnflaggedInterface and UnprefixedInterface added here).

'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