@@ -15,6 +15,55 @@ function getFakeChunk() {
15
15
} ) ;
16
16
}
17
17
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
+
18
67
promise_test ( t => {
19
68
// AudioDecoderInit lacks required fields.
20
69
assert_throws_js ( TypeError , ( ) => { new AudioDecoder ( { } ) ; } ) ;
0 commit comments