| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 | |
| 3 <html> | |
| 4 <head> | |
| 5 <script src="../resources/js-test.js"></script> | |
| 6 <script src="resources/compatibility.js"></script> | |
| 7 <script src="resources/audit-util.js"></script> | |
| 8 <script src="resources/audio-testing.js"></script> | |
| 9 </head> | |
| 10 | |
| 11 <body> | |
| 12 <div id="description"></div> | |
| 13 <div id="console"></div> | |
| 14 | |
| 15 <script> | |
| 16 description("Basic tests for AudioNode API."); | |
| 17 | |
| 18 var context = 0; | |
| 19 var context2 = 0; | |
| 20 var context3 = 0; | |
| 21 | |
| 22 function runTest() { | |
| 23 if (window.testRunner) { | |
| 24 testRunner.dumpAsText(); | |
| 25 testRunner.waitUntilDone(); | |
| 26 } | |
| 27 | |
| 28 window.jsTestIsAsync = true; | |
| 29 | |
| 30 context = new AudioContext(); | |
| 31 window.audioNode = context.createBufferSource(); | |
| 32 | |
| 33 // Check input and output numbers of AudioSourceNode. | |
| 34 if (audioNode.numberOfInputs === 0) | |
| 35 testPassed("Source AudioNode has no inputs."); | |
| 36 else | |
| 37 testFailed("Source AudioNode should not have inputs."); | |
| 38 | |
| 39 if (audioNode.numberOfOutputs === 1) | |
| 40 testPassed("Source AudioNode has one output."); | |
| 41 else | |
| 42 testFailed("Source AudioNode should have one output."); | |
| 43 | |
| 44 // Check input and output numbers of AudioDestinationNode | |
| 45 if (context.destination.numberOfInputs === 1) | |
| 46 testPassed("Destination AudioNode has one input."); | |
| 47 else | |
| 48 testFailed("Destination AudioNode should have one input."); | |
| 49 | |
| 50 if (context.destination.numberOfOutputs === 0) | |
| 51 testPassed("Destination AudioNode has no outputs."); | |
| 52 else | |
| 53 testFailed("Destination AudioNode should have no outputs."); | |
| 54 | |
| 55 // Try calling connect() method with illegal values. | |
| 56 shouldThrow('audioNode.connect(0, 0, 0)'); | |
| 57 shouldThrow('audioNode.connect(null, 0, 0)'); | |
| 58 shouldThrow('audioNode.connect(context.destination, 5, 0)'); | |
| 59 shouldThrow('audioNode.connect(context.destination, 0, 5)'); | |
| 60 | |
| 61 shouldNotThrow('audioNode.connect(context.destination, 0, 0)'); | |
| 62 | |
| 63 // Create a new context and try to connect the other context's node to this
one. | |
| 64 try { | |
| 65 context2 = new AudioContext(); | |
| 66 window.audioNode.connect(context2.destination); | |
| 67 testFailed("exception should be thrown when connecting to other context'
s node."); | |
| 68 } catch(e) { | |
| 69 testPassed("exception thrown when connecting to other context's node."); | |
| 70 } | |
| 71 | |
| 72 // 3-arg AudioContext doesn't create an offline context anymore. | |
| 73 shouldNotThrow("context3 = new AudioContext(1, 44100, 44100)"); | |
| 74 if (context3 instanceof OfflineAudioContext) | |
| 75 testFailed("context3 should not be an OfflineAudioContext"); | |
| 76 else | |
| 77 testPassed("context3 is not an OfflineAudioContext"); | |
| 78 | |
| 79 // Ensure it is an EventTarget | |
| 80 try { | |
| 81 audioNode.addEventListener('testEvent', function(){ | |
| 82 testPassed("AudioNode is an EventTarget"); | |
| 83 }); | |
| 84 audioNode.dispatchEvent(new Event('testEvent')); | |
| 85 } catch(e) { | |
| 86 testFailed("exception shouldn't be thrown when testing whether audio nod
e is an event target"); | |
| 87 } | |
| 88 | |
| 89 finishJSTest(); | |
| 90 } | |
| 91 | |
| 92 runTest(); | |
| 93 | |
| 94 </script> | |
| 95 | |
| 96 </body> | |
| 97 </html> | |
| OLD | NEW |