Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / media / html / media_basic_playback.html
blob416ca832de02b612f4a6b2405ef88902c8abe23a
1 <!-- Used by media_basic_playback to verify basic playback. -->
2 <!DOCTYPE html>
3 <html lang="en-US">
4 <head>
5 <title>Basic Media Playback Test</title>
6 </head>
8 <body>
9 <video autoplay preload controls></video>
10 </body>
12 <script type="text/javascript" src="utils.js"></script>
13 <script type="text/javascript">
14 var video = document.querySelector('video');
16 // Used to keep track of events.
17 var events;
19 // List of events to log. Events in this list are those which are expected
20 // plus those which are unexpected and will have a negative impact on
21 // playback.
22 var eventsToLog = [
23 'abort', 'emptied', 'error', 'playing', 'stalled', 'suspend', 'waiting'];
25 function logEvent(evt) {
26 events.push(evt.type);
29 for(var i = 0; i < eventsToLog.length; i++)
30 video.addEventListener(eventsToLog[i], logEvent, false);
32 video.addEventListener('ended', function(event) {
33 firstEndedEvent = events.indexOf('ended') < 0;
34 logEvent(event);
36 // At the end of the first playback, seek near end and replay. 0.8 was
37 // chosen arbitrarily.
38 if (firstEndedEvent) {
39 video.currentTime = 0.8 * video.duration;
40 } else {
41 // Notify PyAuto that we've completed testing. Send test of currentTime
42 // at the same time for efficiency.
43 window.domAutomationController.send(
44 video.currentTime == video.duration);
46 }, false);
48 video.addEventListener('seeked', function(event) {
49 logEvent(event);
50 video.play();
51 }, false);
53 function startTest(media) {
54 events = [];
55 video.src = media;
57 </script>
58 </html>