Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Side by Side Diff: content/test/data/media/video_audio_element_capture_test.html

Issue 2104643002: MediaCaptureFromElement: add content_browsertests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Media Capture from DOM Elements (video/audio) Browser Test</title>
5 </head>
6 <body>
7 <div> Capture and playback from video/audio elements.</div>
8 <video id="video"></video>
9 <audio id="audio"></audio>
10 </body>
11 <script type="text/javascript" src="webrtc_test_utilities.js"></script>
12 <script>
13
14 'use strict';
15
16 const NUMBER_OF_RECORDED_EVENTS = 100;
17
18 function testCaptureFromMediaElement(filename,
19 has_video,
20 has_audio,
21 use_audio_tag) {
22 const element = use_audio_tag ? document.getElementById('audio')
23 : document.getElementById('video');
24 assertTrue(element, 'Error resolving tag');
25
26 element.src = filename;
27 element.onerror = function(e) {
28 failTest("error playing back [" + filename + "] " + e);
29 }
30
31 var recorded_events = 0;
32 element.onloadedmetadata = function() {
33 const stream = element.captureStream();
34 assertTrue(stream, 'Error creating MediaStream');
35 assertEquals(has_video, stream.getVideoTracks().length);
36 assertEquals(has_audio, stream.getAudioTracks().length);
37
38 const recorder = new MediaRecorder(stream);
39 assertTrue(recorder, 'Error creating recorder out of the MediaStream');
40
41 recorder.ondataavailable = function(event) {
42 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
43 reportTestSuccess();
44 };
45
46 recorder.start();
47 element.play();
48 };
49 }
50
51 </script>
52 </body>
53 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698