5 <script src="../fast/js/resources/js-test-pre.js"></script>
6 <script src="resources/audio-testing.js"></script>
10 <div id="description"></div>
11 <div id="console"></div>
14 description("Basic tests for MediaStreamAudioSourceNode API.");
19 testFailed('Stream generation failed.');
23 function getUserMedia(dictionary, callback) {
25 navigator.webkitGetUserMedia(dictionary, callback, error);
27 testFailed('webkitGetUserMedia threw exception :' + e);
32 function gotStream(stream) {
34 testPassed('{audio:true} generated stream');
35 shouldBe('s.audioTracks.length', '1');
36 shouldBe('s.videoTracks.length', '0');
38 context = new webkitAudioContext();
40 // Create an AudioNode from the stream.
41 var mediaStreamSource = context.createMediaStreamSource(stream);
43 // Check number of inputs and outputs.
44 if (mediaStreamSource.numberOfInputs == 0)
45 testPassed("Source AudioNode has no inputs.");
47 testFailed("Source AudioNode should not have inputs.");
49 if (mediaStreamSource.numberOfOutputs == 1)
50 testPassed("Source AudioNode has one output.");
52 testFailed("Source AudioNode should have one output.");
54 // Try calling connect() method with illegal values.
57 mediaStreamSource.connect(0, 0, 0);
58 testFailed("connect() exception should be thrown for illegal destination AudioNode.");
60 testPassed("connect() exception thrown for illegal destination AudioNode.");
64 mediaStreamSource.connect(context.destination, 5, 0);
65 testFailed("connect() exception should be thrown for illegal output index.");
67 testPassed("connect() exception thrown for illegal output index.");
71 mediaStreamSource.connect(context.destination, 0, 5);
72 testFailed("connect() exception should be thrown for illegal input index.");
74 testPassed("connect() exception thrown for illegal input index.");
77 // Try calling connect() with proper values.
79 mediaStreamSource.connect(context.destination, 0, 0);
80 testPassed("mediaStreamSource.connect(context.destination) succeeded.");
82 testFailed("mediaStreamSource.connect(context.destination) failed.");
88 getUserMedia({audio:true}, gotStream);
89 window.jsTestIsAsync = true;
90 window.successfullyParsed = true;
94 <script src="../fast/js/resources/js-test-post.js"></script>