Skip to content

Commit f7d88c6

Browse files
chcunninghammoz-wptsync-bot
authored andcommitted
Bug 1686465 [wpt PR 27135] - Implement AudioDecoder.isConfigSupported(), a=testonly
Automatic update from web-platform-tests Implement AudioDecoder.isConfigSupported() API and motivations described here: w3c/webcodecs#98 Spec PR here: w3c/webcodecs#120 Bug: 1141707 Test: new layout tests Change-Id: I3a0f3cbc2bb64a86dcefdc454d6b03e72d3f36bd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622421 Reviewed-by: Thomas Guilbert <[email protected]> Commit-Queue: Chrome Cunningham <[email protected]> Cr-Commit-Position: refs/heads/master@{#842153} -- wpt-commits: 87bcad098015a7b983d29b13d2e64f33b93fbc85 wpt-pr: 27135
1 parent 1dcef98 commit f7d88c6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

testing/web-platform/tests/webcodecs/audio-decoder.any.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,55 @@ function getFakeChunk() {
1515
});
1616
}
1717

18+
const invalidConfigs = [
19+
{
20+
comment: 'Emtpy codec',
21+
config: {codec: ''},
22+
},
23+
{
24+
comment: 'Unrecognized codec',
25+
config: {codec: 'bogus'},
26+
},
27+
{
28+
comment: 'Video codec',
29+
config: {codec: 'vp8'},
30+
},
31+
{
32+
comment: 'Ambiguous codec',
33+
config: {codec: 'vp9'},
34+
},
35+
{
36+
comment: 'Codec with MIME type',
37+
config: {codec: 'audio/webm; codecs="opus"'},
38+
},
39+
];
40+
41+
invalidConfigs.forEach(entry => {
42+
promise_test(t => {
43+
return promise_rejects_js(t, TypeError, AudioDecoder.isConfigSupported(entry.config));
44+
}, 'Test that AudioDecoder.isConfigSupported() rejects invalid config:' + entry.comment);
45+
});
46+
47+
48+
invalidConfigs.forEach(entry => {
49+
async_test(t => {
50+
let codec = new AudioDecoder(getDefaultCodecInit(t));
51+
assert_throws_js(TypeError, () => { codec.configure(entry.config); });
52+
t.done();
53+
}, 'Test that AudioDecoder.configure() rejects invalid config:' + entry.comment);
54+
});
55+
56+
promise_test(t => {
57+
return AudioDecoder.isConfigSupported({
58+
codec: 'opus',
59+
sampleRate: 48000,
60+
numberOfChannels: 2,
61+
// Opus header extradata.
62+
description: new Uint8Array([0x4f, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64,
63+
0x01, 0x02, 0x38, 0x01, 0x80, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00])
64+
});
65+
}, 'Test AudioDecoder.isConfigSupported() with a valid config');
66+
1867
promise_test(t => {
1968
// AudioDecoderInit lacks required fields.
2069
assert_throws_js(TypeError, () => { new AudioDecoder({}); });

0 commit comments

Comments
 (0)