2 <script src=../../resources/testharness.js
></script>
3 <script src=../../resources/testharnessreport.js
></script>
5 // This test verifies that MediaRecorder can be created with different Media
6 // Stream Track combinations: 1 Video Track only, 1 Audio Track only and finally
7 // a Media Stream with both a Video and an Audio Track. Note that recording is
8 // _not_ started in this test, see MediaRecorder-basic-video.html for it.
10 function makeAsyncTest(constraints
, verifyStream
, message
) {
11 return async_test(function(test
) {
13 var gotStream
= test
.step_func(function(stream
) {
17 recorder
= new MediaRecorder(stream
);
19 assert_unreached('Exception while creating MediaRecorder: ' + e
);
21 assert_equals(recorder
.state
, "inactive");
25 var onError
= test
.step_func(function() {
26 assert_unreached('Error creating MediaRecorder.');
30 navigator
.webkitGetUserMedia(constraints
, gotStream
, onError
);
32 assert_unreached('Exception launching getUserMedia(): ' + e
);
37 function verifyVideoOnlyStream(stream
) {
38 assert_equals(stream
.getAudioTracks().length
, 0);
39 assert_equals(stream
.getVideoTracks().length
, 1);
40 assert_equals(stream
.getVideoTracks()[0].readyState
, 'live');
42 function verifyAudioOnlyStream(stream
) {
43 assert_equals(stream
.getAudioTracks().length
, 1);
44 assert_equals(stream
.getVideoTracks().length
, 0);
45 assert_equals(stream
.getAudioTracks()[0].readyState
, 'live');
47 function verifyAudioVideoStream(stream
) {
48 assert_equals(stream
.getAudioTracks().length
, 1);
49 assert_equals(stream
.getVideoTracks().length
, 1);
50 assert_equals(stream
.getVideoTracks()[0].readyState
, 'live');
51 assert_equals(stream
.getAudioTracks()[0].readyState
, 'live');
54 // Note: webkitGetUserMedia() must be called with at least video or audio true.
55 makeAsyncTest({video
:true}, verifyVideoOnlyStream
, 'Video only MediaRecorder');
56 makeAsyncTest({audio
:true}, verifyAudioOnlyStream
, 'Audio only MediaRecorder');
57 makeAsyncTest({audio
:true, video
:true}, verifyAudioVideoStream
, 'Video and Audio MediaRecorder');