Index: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-MediaStream-modifications-events.html |
diff --git a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-MediaStream-modifications-events.html b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-MediaStream-modifications-events.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1dd01eee439a51b0962a7b6d192aa62f2ecbf1f9 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-MediaStream-modifications-events.html |
@@ -0,0 +1,63 @@ |
+<!DOCTYPE html> |
+<script src=../../resources/testharness.js></script> |
+<script src=../../resources/testharnessreport.js></script> |
+<script> |
+ |
+// These tests add or remove a Track from the MediaStream associated to a |
+// MediaRecorder, expecting an Error Event in that case. |
+var makeAsyncTest = function(value, expected) { |
+ async_test(function() { |
+ var recorder; |
+ |
+ const onUnexpectedError = this.step_func(function() { |
+ assert_unreached('Error creating MediaStream.'); |
+ }); |
+ |
+ const recorderOnExpectedErrorEvent = this.step_func_done(function(event) { |
+ assert_equals("inactive", recorder.state); |
+ }); |
+ |
+ const gotStreamAndStartMediaRecorder = this.step_func(function(stream) { |
+ assert_equals(stream.getTracks().length, 2); |
+ |
+ try { |
+ recorder = new MediaRecorder(stream); |
+ } catch (e) { |
+ assert_unreached('Exception while creating MediaRecorder: ' + e); |
+ } |
+ recorder.start() |
+ assert_equals("recording", recorder.state); |
+ |
+ recorder.onerror = recorderOnExpectedErrorEvent; |
+ }); |
+ |
+ const getStreamAndAddTrack = this.step_func(function(stream) { |
+ gotStreamAndStartMediaRecorder(stream); |
+ stream.addTrack(stream.getTracks()[1].clone()); |
+ }); |
+ |
+ const getStreamAndRemoveTrack = this.step_func(function(stream) { |
+ gotStreamAndStartMediaRecorder(stream); |
+ stream.removeTrack(stream.getTracks()[1]); |
+ }); |
+ |
+ try { |
+ if (value['action'] === "add") { |
+ navigator.webkitGetUserMedia({video:true, audio:true}, getStreamAndAddTrack, onUnexpectedError); |
+ } else if (value['action'] === "remove") { |
+ navigator.webkitGetUserMedia({video:true, audio:true}, getStreamAndRemoveTrack, onUnexpectedError); |
+ } else { |
+ assert_unreached('Unknown action ' + value['action']); |
+ } |
+ } catch(e) { |
+ assert_unreached('Exception launching getUserMedia(): ' + e); |
+ } |
+ |
+ }); |
+}; |
+ |
+ |
+generate_tests(makeAsyncTest, [["add-track", {action : "add"}], |
+ ["remove-track", {action : "remove"}]]); |
+ |
+</script> |