| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <html> | 3 <html> |
| 4 <head> | 4 <head> |
| 5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
| 8 </head> | 9 </head> |
| 9 | 10 |
| 10 <body> | 11 <body> |
| 11 <div id="description"></div> | 12 <script> |
| 12 <div id="console"></div> | 13 let audit = Audit.createTaskRunner(); |
| 13 | 14 |
| 14 <script> | 15 audit.define( |
| 15 description("Basic tests for MediaElementAudioSourceNode API."); | 16 { |
| 17 label: 'test', |
| 18 description: 'Basic tests for MediaElementAudioSourceNode API' |
| 19 }, |
| 20 (task, should) => { |
| 16 | 21 |
| 17 var context = 0; | 22 let context = new AudioContext(); |
| 18 var audioElement = 0; | |
| 19 var audioNode = 0; | |
| 20 | 23 |
| 21 function runTest() { | 24 let audioElement = new Audio(); |
| 22 window.jsTestIsAsync = true; | 25 let mediaSource = context.createMediaElementSource(audioElement); |
| 26 let audioNode = mediaSource; |
| 23 | 27 |
| 24 context = new AudioContext(); | 28 // Check number of inputs and outputs. |
| 29 should(audioNode.numberOfInputs, 'audioNode.numberOfInputs').beEqualTo(0); |
| 30 should(audioNode.numberOfOutputs, 'audioNode.numberOfOutputs') |
| 31 .beEqualTo(1); |
| 25 | 32 |
| 26 audioElement = new Audio(); | 33 // Try calling connect() method with illegal values: illegal destination, |
| 27 mediaSource = context.createMediaElementSource(audioElement); | 34 // illegal output index, and illegal input index. |
| 28 audioNode = mediaSource; | 35 should(() => audioNode.connect(0, 0, 0), 'audioNode.connect(0, 0, 0)') |
| 36 .throw('TypeError'); |
| 37 should( |
| 38 () => audioNode.connect(context.destination, 5, 0), |
| 39 'audioNode.connect(context.destination, 5, 0)') |
| 40 .throw('IndexSizeError'); |
| 41 should( |
| 42 () => audioNode.connect(context.destination, 0, 5), |
| 43 'audioNode.connect(context.destination, 0, 5)') |
| 44 .throw('IndexSizeError'); |
| 29 | 45 |
| 30 // Check number of inputs and outputs. | 46 // Try calling connect() with proper values. |
| 31 shouldBeEqualToNumber("audioNode.numberOfInputs", 0); | 47 should( |
| 32 shouldBeEqualToNumber("audioNode.numberOfOutputs", 1); | 48 () => audioNode.connect(context.destination, 0, 0), |
| 49 'audioNode.connect(context.destination, 0, 0)') |
| 50 .notThrow(); |
| 33 | 51 |
| 34 // Try calling connect() method with illegal values: illegal destination, il
legal output index, | 52 // Try creating another MediaElementAudioSourceNode using the same audio |
| 35 // and illegal input index. | 53 // element. |
| 36 shouldThrow("audioNode.connect(0, 0, 0)"); | 54 should( |
| 37 shouldThrow("audioNode.connect(context.destination, 5, 0)"); | 55 () => context.createMediaElementSource(audioElement), |
| 38 shouldThrow("audioNode.connect(context.destination, 0, 5)"); | 56 'context.createMediaElementSource(audioElement)') |
| 57 .throw(); |
| 39 | 58 |
| 40 // Try calling connect() with proper values. | 59 task.done(); |
| 41 shouldNotThrow("audioNode.connect(context.destination, 0, 0)"); | 60 }); |
| 42 | |
| 43 // Try creating another MediaElementAudioSourceNode using the same audio ele
ment. | |
| 44 shouldThrow("context.createMediaElementSource(audioElement)"); | |
| 45 | 61 |
| 46 finishJSTest(); | 62 audit.run(); |
| 47 } | |
| 48 | |
| 49 runTest(); | |
| 50 | 63 |
| 51 </script> | 64 </script> |
| 52 | 65 |
| 53 </body> | 66 </body> |
| 54 </html> | 67 </html> |
| OLD | NEW |