| 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 MediaStreamAudioSourceNode API."); | |
| 17 | |
| 18 var context = 0; | |
| 19 | |
| 20 function error() { | |
| 21 testFailed('Stream generation failed.'); | |
| 22 finishJSTest(); | |
| 23 } | |
| 24 | |
| 25 function getUserMedia(dictionary, callback) { | |
| 26 try { | |
| 27 navigator.webkitGetUserMedia(dictionary, callback, error); | |
| 28 } catch (e) { | |
| 29 testFailed('webkitGetUserMedia threw exception :' + e); | |
| 30 finishJSTest(); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 function gotStream(stream) { | |
| 35 s = stream; | |
| 36 testPassed('{audio:true} generated stream'); | |
| 37 shouldBe('s.getAudioTracks().length', '1'); | |
| 38 shouldBe('s.getVideoTracks().length', '0'); | |
| 39 | |
| 40 context = new AudioContext(); | |
| 41 | |
| 42 // Create an AudioNode from the stream. | |
| 43 var mediaStreamSource = context.createMediaStreamSource(stream); | |
| 44 | |
| 45 // Check number of inputs and outputs. | |
| 46 if (mediaStreamSource.numberOfInputs == 0) | |
| 47 testPassed("Source AudioNode has no inputs."); | |
| 48 else | |
| 49 testFailed("Source AudioNode should not have inputs."); | |
| 50 | |
| 51 if (mediaStreamSource.numberOfOutputs == 1) | |
| 52 testPassed("Source AudioNode has one output."); | |
| 53 else | |
| 54 testFailed("Source AudioNode should have one output."); | |
| 55 | |
| 56 // Try calling connect() method with illegal values. | |
| 57 | |
| 58 try { | |
| 59 mediaStreamSource.connect(0, 0, 0); | |
| 60 testFailed("connect() exception should be thrown for illegal destination
AudioNode."); | |
| 61 } catch(e) { | |
| 62 testPassed("connect() exception thrown for illegal destination AudioNode
."); | |
| 63 } | |
| 64 | |
| 65 try { | |
| 66 mediaStreamSource.connect(context.destination, 5, 0); | |
| 67 testFailed("connect() exception should be thrown for illegal output inde
x."); | |
| 68 } catch(e) { | |
| 69 testPassed("connect() exception thrown for illegal output index."); | |
| 70 } | |
| 71 | |
| 72 try { | |
| 73 mediaStreamSource.connect(context.destination, 0, 5); | |
| 74 testFailed("connect() exception should be thrown for illegal input index
."); | |
| 75 } catch(e) { | |
| 76 testPassed("connect() exception thrown for illegal input index."); | |
| 77 } | |
| 78 | |
| 79 // Try calling connect() with proper values. | |
| 80 try { | |
| 81 mediaStreamSource.connect(context.destination, 0, 0); | |
| 82 testPassed("mediaStreamSource.connect(context.destination) succeeded."); | |
| 83 } catch(e) { | |
| 84 testFailed("mediaStreamSource.connect(context.destination) failed."); | |
| 85 } | |
| 86 | |
| 87 finishJSTest(); | |
| 88 } | |
| 89 | |
| 90 getUserMedia({audio:true}, gotStream); | |
| 91 window.jsTestIsAsync = true; | |
| 92 window.successfullyParsed = true; | |
| 93 | |
| 94 </script> | |
| 95 | |
| 96 </body> | |
| 97 </html> | |
| OLD | NEW |