Chromium Code Reviews| Index: content/test/data/media/video_audio_element_capture_test.html |
| diff --git a/content/test/data/media/video_audio_element_capture_test.html b/content/test/data/media/video_audio_element_capture_test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7375e677487752c28e87e2c11e1ceca7f5a8977b |
| --- /dev/null |
| +++ b/content/test/data/media/video_audio_element_capture_test.html |
| @@ -0,0 +1,53 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<title>Media Capture from DOM Elements (video/audio) Browser Test</title> |
| +</head> |
| +<body> |
| + <div> Capture and playback from video/audio elements.</div> |
| + <video id="video"></video> |
| + <audio id="audio"></audio> |
| +</body> |
| +<script type="text/javascript" src="webrtc_test_utilities.js"></script> |
| +<script> |
| + |
| +'use strict'; |
| + |
| +const NUMBER_OF_RECORDED_EVENTS = 100; |
| + |
| +function testCaptureFromMediaElement(filename, |
| + has_video, |
| + has_audio, |
| + use_audio_tag) { |
| + const element = use_audio_tag ? document.getElementById('audio') |
| + : document.getElementById('video'); |
| + assertTrue(element, 'Error resolving tag'); |
| + |
| + element.src = filename; |
| + element.onerror = function(e) { |
| + failTest("error playing back [" + filename + "] " + e); |
| + } |
| + |
| + var recorded_events = 0; |
| + element.onloadedmetadata = function() { |
| + const stream = element.captureStream(); |
| + assertTrue(stream, 'Error creating MediaStream'); |
| + assertEquals(has_video, stream.getVideoTracks().length); |
| + assertEquals(has_audio, stream.getAudioTracks().length); |
| + |
| + const recorder = new MediaRecorder(stream); |
| + assertTrue(recorder, 'Error creating recorder out of the MediaStream'); |
| + |
| + recorder.ondataavailable = function(event) { |
| + if (recorded_events++ > NUMBER_OF_RECORDED_EVENTS) |
|
tommi (sloooow) - chröme
2016/06/29 07:52:37
nit: as is, due to using postfix, the condition is
mcasas
2016/06/29 18:22:24
Done.
Also renamed to NUMBER_OF_EVENTS_TO_RECORD
|
| + reportTestSuccess(); |
| + }; |
| + |
| + recorder.start(); |
| + element.play(); |
| + }; |
| +} |
| + |
| +</script> |
| +</body> |
| +</html> |