OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src=../../resources/testharness.js></script> |
| 3 <script src=../../resources/testharnessreport.js></script> |
| 4 <script> |
| 5 |
| 6 // These tests add or remove a Track from the MediaStream associated to a |
| 7 // MediaRecorder, expecting an Error Event in that case. |
| 8 var makeAsyncTest = function(value, expected) { |
| 9 async_test(function() { |
| 10 var recorder; |
| 11 |
| 12 const onUnexpectedError = this.step_func(function() { |
| 13 assert_unreached('Error creating MediaStream.'); |
| 14 }); |
| 15 |
| 16 const recorderOnExpectedErrorEvent = this.step_func_done(function(event)
{ |
| 17 assert_equals("inactive", recorder.state); |
| 18 }); |
| 19 |
| 20 const gotStreamAndStartMediaRecorder = this.step_func(function(stream) { |
| 21 assert_equals(stream.getTracks().length, 2); |
| 22 |
| 23 try { |
| 24 recorder = new MediaRecorder(stream); |
| 25 } catch (e) { |
| 26 assert_unreached('Exception while creating MediaRecorder: ' + e)
; |
| 27 } |
| 28 recorder.start() |
| 29 assert_equals("recording", recorder.state); |
| 30 |
| 31 recorder.onerror = recorderOnExpectedErrorEvent; |
| 32 }); |
| 33 |
| 34 const getStreamAndAddTrack = this.step_func(function(stream) { |
| 35 gotStreamAndStartMediaRecorder(stream); |
| 36 stream.addTrack(stream.getTracks()[1].clone()); |
| 37 }); |
| 38 |
| 39 const getStreamAndRemoveTrack = this.step_func(function(stream) { |
| 40 gotStreamAndStartMediaRecorder(stream); |
| 41 stream.removeTrack(stream.getTracks()[1]); |
| 42 }); |
| 43 |
| 44 try { |
| 45 if (value['action'] === "add") { |
| 46 navigator.webkitGetUserMedia({video:true, audio:true}, getStream
AndAddTrack, onUnexpectedError); |
| 47 } else if (value['action'] === "remove") { |
| 48 navigator.webkitGetUserMedia({video:true, audio:true}, getStream
AndRemoveTrack, onUnexpectedError); |
| 49 } else { |
| 50 assert_unreached('Unknown action ' + value['action']); |
| 51 } |
| 52 } catch(e) { |
| 53 assert_unreached('Exception launching getUserMedia(): ' + e); |
| 54 } |
| 55 |
| 56 }); |
| 57 }; |
| 58 |
| 59 |
| 60 generate_tests(makeAsyncTest, [["add-track", {action : "add"}], |
| 61 ["remove-track", {action : "remove"}]]); |
| 62 |
| 63 </script> |
OLD | NEW |