gecko/toolkit/content/tests/widgets/test_videocontrols.html
2008-12-27 20:58:14 -05:00

121 lines
3.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Video controls test</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content">
<video width="320" height="240" id="video" src="video.ogg" controls mozNoDynamicControls></video>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
function runTest(event) {
ok(true, "----- test #" + testnum + " -----");
switch (testnum) {
case 1:
// Check initial state upon load
is(event.type, "loadeddata", "checking event type");
is(video.paused, true, "checking video play state");
is(video.muted, false, "checking video mute state");
// Click the play button
synthesizeMouse(video, 12, 228, { });
break;
case 2:
is(event.type, "play", "checking event type");
is(video.paused, false, "checking video play state");
is(video.muted, false, "checking video mute state");
// Click the pause button
synthesizeMouse(video, 12, 228, { });
break;
case 3:
is(event.type, "pause", "checking event type");
is(video.paused, true, "checking video play state");
is(video.muted, false, "checking video mute state");
// Click the mute button
// XXX volume event is sent synchronously, so do this in a timeout
setTimeout("synthesizeMouse(video, 308, 228, { });", 0);
break;
case 4:
is(event.type, "volumechange", "checking event type");
is(video.paused, true, "checking video play state");
is(video.muted, true, "checking video mute state");
// Click the unmute button
// XXX volume event is sent synchronously, so do this in a timeout
setTimeout("synthesizeMouse(video, 308, 228, { });", 0);
break;
case 5:
is(event.type, "volumechange", "checking event type");
is(video.paused, true, "checking video play state");
is(video.muted, false, "checking video mute state");
// Bug 470596: Make sure that having CSS border or padding doesn't
// break the controls (though it should move them)
video.style.border = "medium solid purple";
video.style.borderWidth = "30px 40px 50px 60px";
video.style.padding = "10px 20px 30px 40px";
// totals: top: 40px, right: 60px, bottom: 80px, left: 100px
// Click the play button
synthesizeMouse(video, 100 + 12, 40 + 228, { });
break;
case 6:
is(event.type, "play", "checking event type");
is(video.paused, false, "checking video play state");
is(video.muted, false, "checking video mute state");
// Click the mute button
// XXX volume event is sent synchronously, so do this in a timeout
setTimeout("synthesizeMouse(video, 100 + 308, 40 + 228, { });", 0);
break;
case 7:
is(event.type, "volumechange", "checking event type");
is(video.paused, false, "checking video play state");
is(video.muted, true, "checking video mute state");
SimpleTest.finish();
break;
default:
throw "unexpected test #" + testnum + " w/ event " + event.type;
}
testnum++;
}
var testnum = 1;
var video = document.getElementById("video");
// Kick off test once we've got enough to do something.
video.addEventListener("loadeddata", runTest, false);
// Other events expected by the test.
video.addEventListener("play", runTest, false);
video.addEventListener("pause", runTest, false);
video.addEventListener("volumechange", runTest, false);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>