Bug 462116 - Need tests for <video> controls; (no review)
[wine-gecko.git] / toolkit / content / tests / widgets / test_videocontrols.html
blob93c526a8184112cee332a8b57b5f9301d3aeac69
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Video controls test</title>
5 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
7 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9 </head>
10 <body>
11 <p id="display"></p>
13 <div id="content">
14 <video width="320" height="240" id="video" src="video.ogg" controls></video>
15 </div>
17 <pre id="test">
18 <script class="testbody" type="text/javascript">
20 var testnum = 1;
21 var video = document.getElementById("video");
23 function runTest(event) {
24 ok(true, "----- test #" + testnum + " -----");
26 switch (testnum) {
27 case 1:
28 // Check initial state upon load
29 is(event.type, "load", "checking event type");
30 is(video.paused, true, "checking video play state");
31 is(video.muted, false, "checking video mute state");
33 // Let the fadein happen
34 synthesizeMouse(video, 12, 228, { type : "mouseover" });
35 setTimeout(runTest, 0, { type: "setTimeout" });
36 break;
38 case 2:
39 is(event.type, "setTimeout", "checking event type");
40 // Click the play button
41 synthesizeMouse(video, 12, 228, { });
42 break;
44 case 3:
45 is(event.type, "play", "checking event type");
46 is(video.paused, false, "checking video play state");
47 is(video.muted, false, "checking video mute state");
49 // Click the pause button
50 synthesizeMouse(video, 12, 228, { });
51 break;
53 case 4:
54 is(event.type, "pause", "checking event type");
55 is(video.paused, true, "checking video play state");
56 is(video.muted, false, "checking video mute state");
58 // Click the mute button
59 // XXX volume event is sent synchronously, so do this in a timeout
60 setTimeout("synthesizeMouse(video, 308, 228, { });", 0);
61 break;
63 case 5:
64 is(event.type, "volumechange", "checking event type");
65 is(video.paused, true, "checking video play state");
66 is(video.muted, true, "checking video mute state");
68 // Click the unmute button
69 // XXX volume event is sent synchronously, so do this in a timeout
70 setTimeout("synthesizeMouse(video, 308, 228, { });", 0);
71 break;
73 case 6:
74 is(event.type, "volumechange", "checking event type");
75 is(video.paused, true, "checking video play state");
76 is(video.muted, false, "checking video mute state");
78 SimpleTest.finish();
79 break;
81 default:
82 throw "unexpected test #" + testnum + " w/ event " + event.name;
85 testnum++;
88 window.onload = runTest;
89 video.addEventListener("play", runTest, false);
90 video.addEventListener("pause", runTest, false);
91 video.addEventListener("volumechange", runTest, false);
93 SimpleTest.waitForExplicitFinish();
95 </script>
96 </pre>
97 </body>
98 </html>