| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title> |
| 5 mediaelementaudiosourcenode.html |
| 6 </title> |
| 7 <script src="../../resources/testharness.js"></script> |
| 8 <script src="../../resources/testharnessreport.js"></script> |
| 9 <script src="../resources/audit-util.js"></script> |
| 10 <script src="../resources/audit.js"></script> |
| 11 </head> |
| 12 <body> |
| 13 <script id="layout-test-code"> |
| 14 let audit = Audit.createTaskRunner(); |
| 2 | 15 |
| 3 <html> | 16 audit.define( |
| 4 <head> | 17 { |
| 5 <script src="../../resources/testharness.js"></script> | 18 label: 'test', |
| 6 <script src="../../resources/testharnessreport.js"></script> | 19 description: 'Basic tests for MediaElementAudioSourceNode API' |
| 7 <script src="../resources/audit-util.js"></script> | 20 }, |
| 8 <script src="../resources/audit.js"></script> | 21 (task, should) => { |
| 9 </head> | |
| 10 | 22 |
| 11 <body> | 23 let context = new AudioContext(); |
| 12 <script> | |
| 13 let audit = Audit.createTaskRunner(); | |
| 14 | 24 |
| 15 audit.define( | 25 let audioElement = new Audio(); |
| 16 { | 26 let mediaSource = context.createMediaElementSource(audioElement); |
| 17 label: 'test', | 27 let audioNode = mediaSource; |
| 18 description: 'Basic tests for MediaElementAudioSourceNode API' | |
| 19 }, | |
| 20 (task, should) => { | |
| 21 | 28 |
| 22 let context = new AudioContext(); | 29 // Check number of inputs and outputs. |
| 30 should(audioNode.numberOfInputs, 'audioNode.numberOfInputs') |
| 31 .beEqualTo(0); |
| 32 should(audioNode.numberOfOutputs, 'audioNode.numberOfOutputs') |
| 33 .beEqualTo(1); |
| 23 | 34 |
| 24 let audioElement = new Audio(); | 35 // Try calling connect() method with illegal values: illegal |
| 25 let mediaSource = context.createMediaElementSource(audioElement); | 36 // destination, illegal output index, and illegal input index. |
| 26 let audioNode = mediaSource; | 37 should( |
| 38 () => audioNode.connect(0, 0, 0), 'audioNode.connect(0, 0, 0)') |
| 39 .throw('TypeError'); |
| 40 should( |
| 41 () => audioNode.connect(context.destination, 5, 0), |
| 42 'audioNode.connect(context.destination, 5, 0)') |
| 43 .throw('IndexSizeError'); |
| 44 should( |
| 45 () => audioNode.connect(context.destination, 0, 5), |
| 46 'audioNode.connect(context.destination, 0, 5)') |
| 47 .throw('IndexSizeError'); |
| 27 | 48 |
| 28 // Check number of inputs and outputs. | 49 // Verify same object is returned. |
| 29 should(audioNode.numberOfInputs, 'audioNode.numberOfInputs').beEqualTo(0); | 50 let element = mediaSource.mediaElement; |
| 30 should(audioNode.numberOfOutputs, 'audioNode.numberOfOutputs') | 51 should( |
| 31 .beEqualTo(1); | 52 element instanceof HTMLMediaElement, |
| 53 'mediaSource.mediaElement instanceof HTMLMediaElement') |
| 54 .beTrue(); |
| 55 should( |
| 56 mediaSource.mediaElement === element, |
| 57 'mediaSource.mediaElement is same object') |
| 58 .beTrue(); |
| 32 | 59 |
| 33 // Try calling connect() method with illegal values: illegal destination, | 60 // Try calling connect() with proper values. |
| 34 // illegal output index, and illegal input index. | 61 should( |
| 35 should(() => audioNode.connect(0, 0, 0), 'audioNode.connect(0, 0, 0)') | 62 () => audioNode.connect(context.destination, 0, 0), |
| 36 .throw('TypeError'); | 63 'audioNode.connect(context.destination, 0, 0)') |
| 37 should( | 64 .notThrow(); |
| 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'); | |
| 45 | 65 |
| 46 // Verify same object is returned. | 66 // Try creating another MediaElementAudioSourceNode using the same |
| 47 let element = mediaSource.mediaElement; | 67 // audio element. |
| 48 should(element instanceof HTMLMediaElement, | 68 should( |
| 49 'mediaSource.mediaElement instanceof HTMLMediaElement') | 69 () => context.createMediaElementSource(audioElement), |
| 50 .beTrue(); | 70 'context.createMediaElementSource(audioElement)') |
| 51 should(mediaSource.mediaElement === element, | 71 .throw(); |
| 52 'mediaSource.mediaElement is same object') | |
| 53 .beTrue(); | |
| 54 | 72 |
| 55 // Try calling connect() with proper values. | 73 task.done(); |
| 56 should( | 74 }); |
| 57 () => audioNode.connect(context.destination, 0, 0), | |
| 58 'audioNode.connect(context.destination, 0, 0)') | |
| 59 .notThrow(); | |
| 60 | 75 |
| 61 // Try creating another MediaElementAudioSourceNode using the same audio | 76 audit.run(); |
| 62 // element. | 77 </script> |
| 63 should( | 78 </body> |
| 64 () => context.createMediaElementSource(audioElement), | |
| 65 'context.createMediaElementSource(audioElement)') | |
| 66 .throw(); | |
| 67 | |
| 68 task.done(); | |
| 69 }); | |
| 70 | |
| 71 audit.run(); | |
| 72 | |
| 73 </script> | |
| 74 | |
| 75 </body> | |
| 76 </html> | 79 </html> |
| OLD | NEW |