2009-08-20 Eric Carlson <eric.carlson@apple.com>
[WebKit-https.git] / LayoutTests / media / event-attributes.html
1 <html>
2     <head>
3
4         <script src=video-test.js></script>
5         <script>
6             var ratechangeCount = 0;
7             var playingCount = 0;
8             var progressEventCount = 0;
9
10             function eventHandler()
11             {
12                 // Don't log progress event since the number and order are platform
13                 // specific.
14                 if (event.type != "progress")
15                     consoleWrite("EVENT(" + event.type + ")");
16                 switch (event.type)
17                 {
18                     case "loadend":
19                         consoleWrite("<br>*** starting playback");
20                         run("video.play()"); 
21                         break;
22                     case "playing":
23                         if (++playingCount == 1) {
24                             consoleWrite("<br>*** changing playback rate");
25                             run("video.playbackRate = 2");
26                         }
27                         break;
28                     case "ratechange":
29                         if (++ratechangeCount == 1) {
30                             consoleWrite("<br>*** setting volume");
31                             run("video.volume = 0.5");
32                         }
33                         break;
34                     case "volumechange":
35                         consoleWrite("<br>*** pausing playback");
36                         run("video.pause()");
37                         break;
38                     case "pause":
39                         consoleWrite("<br>*** seeking");
40                         run("video.currentTime = 5.6");
41                         break;
42                     case "seeked":
43                         consoleWrite("<br>*** beginning playback");
44                         run("video.play()");
45                         break;
46                     case "ended":
47                         consoleWrite("<br>*** played to end, setting 'src' to an invalid movie");
48                         run("video.src = 'content/garbage.mp4'");
49                         run("video.load()");
50                         break;
51                     case "progress":
52                         ++progressEventCount;
53                         break;
54                     case "error":
55                         testExpected('progressEventCount', 1, '>=');
56                         endTest();
57                         break;
58                     default:
59                         break;
60                 }
61             }
62
63             function start()
64             {
65                 findMediaElement();
66             }
67
68         </script>
69     </head>
70
71     <body onload="start()">
72
73         <video controls src="content/test.mp4" 
74             onabort="eventHandler()"
75             oncanplay="eventHandler()"
76             oncanplaythrough="eventHandler()"
77             ondurationchange="eventHandler()"
78             onemptied="eventHandler()"
79             onended="eventHandler()"
80             onerror="eventHandler()"
81             onload="eventHandler()"
82             onloadeddata="eventHandler()"
83             onloadedmetadata="eventHandler()"
84             onloadstart="eventHandler()"
85             onloadend="eventHandler()"
86             onpause="eventHandler()"
87             onplay="eventHandler()"
88             onplaying="eventHandler()"
89             onprogress="eventHandler()"
90             onratechange="eventHandler()"
91             onseeked="eventHandler()"
92             onseeking="eventHandler()"
93             onstalled="eventHandler()"
94             onsuspend="eventHandler()"
95             onvolumechange="eventHandler()"
96             onwaiting="eventHandler()"
97             >
98         </video>
99
100     </body>
101 </html>