OLD | NEW |
---|---|
1 <!-- Used by media_basic_playback to verify basic playback. --> | 1 <!-- Used by media_basic_playback to verify basic playback. --> |
2 <!DOCTYPE html> | 2 <!DOCTYPE html> |
3 <html lang="en-US"> | 3 <html lang="en-US"> |
4 <head> | 4 <head> |
5 <title>Basic Media Playback Test</title> | 5 <title>Basic Media Playback Test</title> |
6 </head> | 6 </head> |
7 | 7 |
8 <body> | 8 <body> |
9 <video autoplay preload controls></video> | 9 <video autoplay preload controls></video> |
10 </body> | 10 </body> |
11 | 11 |
12 <script type="text/javascript" src="utils.js"></script> | 12 <script type="text/javascript" src="utils.js"></script> |
13 <script type="text/javascript"> | 13 <script type="text/javascript"> |
14 var video = document.querySelector('video'); | 14 var video = document.querySelector('video'); |
15 | 15 |
16 // Used to keep track of events. | 16 // Used to keep track of events. |
17 var events = []; | 17 var events = []; |
Ami GONE FROM CHROMIUM
2012/01/31 20:26:16
Init unnecessary since startTest() does it anyway.
DaleCurtis
2012/01/31 22:31:55
Done.
| |
18 | 18 |
19 // List of events to log. | |
Ami GONE FROM CHROMIUM
2012/01/31 20:26:16
I worry this will be flaky b/c it's overly specifi
DaleCurtis
2012/01/31 22:31:55
Discussed offline. Events in this list are those w
| |
20 var eventsToLog = [ | |
21 'abort', 'emptied', 'error', 'playing', 'stalled', 'suspend', | |
Ami GONE FROM CHROMIUM
2012/01/31 20:26:16
2-space indent
DaleCurtis
2012/01/31 22:31:55
Done.
| |
22 'waiting']; | |
23 | |
19 function logEvent(evt) { | 24 function logEvent(evt) { |
20 events.push(evt.type); | 25 events.push(evt.type); |
21 } | 26 } |
22 | 27 |
28 for(var i = 0; i < eventsToLog.length; i++) | |
29 video.addEventListener(eventsToLog[i], logEvent, false); | |
30 | |
23 video.addEventListener('ended', function(event) { | 31 video.addEventListener('ended', function(event) { |
24 firstEndedEvent = events.indexOf('ended') < 0; | 32 firstEndedEvent = events.indexOf('ended') < 0; |
25 logEvent(event); | 33 logEvent(event); |
26 | 34 |
27 // At the end of the first playback, seek near end and replay. | 35 // At the end of the first playback, seek near end and replay. |
28 if (firstEndedEvent) { | 36 if (firstEndedEvent) { |
29 video.currentTime = 0.8 * video.duration; | 37 video.currentTime = 0.8 * video.duration; |
30 video.play(); | |
31 } else { | 38 } else { |
32 // PyAuto has trouble with arrays, so convert to string. | |
33 events = events.join(','); | |
34 | |
35 // Notify PyAuto that we've completed testing. Send test of currentTime | 39 // Notify PyAuto that we've completed testing. Send test of currentTime |
36 // at the same time for efficiency. | 40 // at the same time for efficiency. |
37 window.domAutomationController.send( | 41 window.domAutomationController.send( |
38 video.currentTime == video.duration); | 42 video.currentTime == video.duration); |
39 } | 43 } |
40 }, false); | 44 }, false); |
41 | 45 |
42 video.addEventListener('playing', logEvent, false); | 46 video.addEventListener('seeked', function(event) { |
43 video.addEventListener('error', logEvent, false); | 47 logEvent(event); |
44 video.addEventListener('abort', logEvent, false); | 48 video.play(); |
45 video.addEventListener('seeked', logEvent, false); | 49 }, false); |
46 | 50 |
47 // Retrieve video file name from URL query parameters. See utils.js. | 51 function startTest(media) { |
48 video.src = '../' + QueryString.media; | 52 events = []; |
49 video.play(); | 53 video.src = '../' + media; |
54 } | |
50 </script> | 55 </script> |
51 </html> | 56 </html> |
OLD | NEW |