Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 2 additions & 6 deletions api/GPUAdapter.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "127"
},
"chrome_android": "mirror",
"edge": "mirror",
"firefox": {
"version_added": "141",
Expand Down Expand Up @@ -437,9 +435,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "133"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down
20 changes: 5 additions & 15 deletions api/GPUCommandEncoder.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "121"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -227,9 +225,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "125"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -268,9 +264,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "123"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -310,9 +304,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "121"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -467,9 +459,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "137"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down
24 changes: 6 additions & 18 deletions api/GPUDevice.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "137"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -716,9 +714,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "135"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -816,9 +812,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "121"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -974,9 +968,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "130"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -1277,9 +1269,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "130"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -1899,9 +1889,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "121"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down
4 changes: 1 addition & 3 deletions api/GPUQuerySet.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "121"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down
8 changes: 2 additions & 6 deletions api/GPUSupportedFeatures.json
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "142"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down Expand Up @@ -904,9 +902,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "142"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down
4 changes: 1 addition & 3 deletions api/GPUTexture.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@
"partial_implementation": true,
"notes": "Supported on ChromeOS, macOS, and Windows only."
},
"chrome_android": {
"version_added": "132"
},
"chrome_android": "mirror",
"deno": {
"version_added": false
},
Expand Down
69 changes: 68 additions & 1 deletion scripts/build/mirror.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,44 @@ import { BrowserName } from '../../types/types.js';
import bcd from '../../index.js';
import { InternalSupportBlock } from '../../types/index.js';

import mirrorSupport from './mirror.js';
import mirrorSupport, { isOSLimitation } from './mirror.js';

describe('mirror', () => {
describe('isOSLimitation', () => {
it('returns true for OS limitation notes', () => {
assert.equal(
isOSLimitation('Supported on ChromeOS, macOS, and Windows only.'),
true,
);
assert.equal(
isOSLimitation('Supported on Linux and Windows only.'),
true,
);
assert.equal(isOSLimitation('Supported on macOS only.'), true);
assert.equal(isOSLimitation('Not supported on Windows.'), true);
assert.equal(isOSLimitation('Not yet supported on macOS.'), true);
});

it('returns false for non-OS-limitation notes', () => {
assert.equal(
isOSLimitation('This feature requires a flag to be enabled.'),
false,
);
assert.equal(
isOSLimitation('Before version 70, this method always returned true.'),
false,
);
assert.equal(
isOSLimitation('Firefox 73 added support for this thing.'),
false,
);
});

it('returns false for empty string', () => {
assert.equal(isOSLimitation(''), false);
});
});

describe('default export', () => {
describe('version numbers match expected values', () => {
const mappings: {
Expand Down Expand Up @@ -189,6 +224,38 @@ describe('mirror', () => {
notes: 'This feature is only supported in ChromeOS, macOS and Linux.',
});
});

it('OS-specific partial_implementation and notes are not mirrored', () => {
const support = {
chrome: {
version_added: '134',
partial_implementation: true,
notes: 'Supported on ChromeOS, macOS, and Windows only.',
},
};

const mirrored = mirrorSupport('chrome_android', support);
assert.deepEqual(mirrored, {
version_added: '134',
});
});

it('Non-OS-specific partial_implementation and notes are still mirrored', () => {
const support = {
chrome: {
version_added: '70',
partial_implementation: true,
notes: 'This feature is incomplete and may not work as expected.',
},
};

const mirrored = mirrorSupport('chrome_android', support);
assert.deepEqual(mirrored, {
version_added: '70',
partial_implementation: true,
notes: 'This feature is incomplete and may not work as expected.',
});
});
});

describe('Validations', () => {
Expand Down
53 changes: 52 additions & 1 deletion scripts/build/mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,33 @@ const { browsers } = bcd;
type Notes = string | [string, string, ...string[]] | null;

/**
* Check if a note indicates OS-specific limitations.
* @param notes A single notes string from a support statement
* @returns True if the notes indicate OS-specific limitations
*/
export const isOSLimitation = (notes: string): boolean => {
const words = notes
.split(/\s+/)
.map((word) => word.toLowerCase().replace(/[,.;:!?]$/g, '')); // Remove trailing punctuation

if (words.length === 0) {
return false;
}

const os = ['chromeos', 'linux', 'macos', 'windows'];
const expectedWords = ['supported', 'on', 'only', 'not', 'yet', 'and'];

let hasOSKeyword = false;
for (const word of words) {
if (os.includes(word)) {
hasOSKeyword = true;
} else if (!expectedWords.includes(word)) {
return false;
}
}

return hasOSKeyword;
};
Comment thread
ddbeck marked this conversation as resolved.

const matchingSafariVersions = new Map([
['1', '1'],
Expand Down Expand Up @@ -215,6 +241,30 @@ export const bumpSupport = (

const newData: SimpleSupportStatement = copyStatement(sourceData);

if (
browsers[sourceBrowser].type === 'desktop' &&
browsers[destination].type === 'mobile' &&
sourceData.partial_implementation
) {
const notes = Array.isArray(sourceData.notes)
? sourceData.notes
: sourceData.notes
? [sourceData.notes]
: [];
const [firstNote, secondNote, ...otherNotes] = notes.filter(
(notes) => !isOSLimitation(notes),
);
if (!firstNote) {
// Ignore OS limitation.
delete newData.partial_implementation;
delete newData.notes;
} else if (!secondNote) {
newData.notes = firstNote;
} else {
newData.notes = [firstNote, secondNote, ...otherNotes];
}
}

if (!browsers[destination].accepts_flags && newData.flags) {
// Remove flag data if the target browser doesn't accept flags
return { version_added: false };
Expand Down Expand Up @@ -254,7 +304,8 @@ export const bumpSupport = (
return { version_added: false };
}

if (sourceData.notes) {
// Only process notes if they weren't already removed (e.g., for OS-specific limitations)
if (sourceData.notes && newData.notes !== undefined) {
const sourceBrowserName =
sourceBrowser === 'chrome'
? '(Google )?Chrome'
Expand Down