2008-12-02 09:47:44 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Video controls test</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
2008-12-02 09:47:44 -08:00
|
|
|
<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">
|
2010-08-19 15:50:37 -07:00
|
|
|
<video width="320" height="240" id="video" src="video.ogg" controls mozNoDynamicControls preload="auto"></video>
|
2008-12-02 09:47:44 -08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<pre id="test">
|
2009-05-19 02:42:29 -07:00
|
|
|
<script type="text/javascript" src="use_large_cache.js"></script>
|
2008-12-02 09:47:44 -08:00
|
|
|
<script class="testbody" type="text/javascript">
|
2009-03-31 17:52:56 -07:00
|
|
|
|
2009-02-07 13:43:43 -08:00
|
|
|
/*
|
|
|
|
* Positions of the UI elements, relative to the upper-left corner of the
|
|
|
|
* <video> box.
|
|
|
|
*/
|
|
|
|
const videoWidth = 320;
|
|
|
|
const videoHeight = 240;
|
|
|
|
const videoDuration = 3.8329999446868896;
|
|
|
|
|
|
|
|
const playButtonWidth = 28;
|
|
|
|
const playButtonHeight = 28;
|
|
|
|
const muteButtonWidth = 33;
|
|
|
|
const muteButtonHeight = 28;
|
2009-04-23 00:33:35 -07:00
|
|
|
const durationWidth = 34;
|
|
|
|
const scrubberWidth = videoWidth - playButtonWidth - muteButtonWidth - durationWidth;
|
2009-02-07 13:43:43 -08:00
|
|
|
const scrubberHeight = 28;
|
|
|
|
|
|
|
|
// Play button is on the bottom-left
|
|
|
|
const playButtonCenterX = 0 + Math.round(playButtonWidth / 2);
|
|
|
|
const playButtonCenterY = videoHeight - Math.round(playButtonHeight / 2);
|
|
|
|
// Mute button is on the bottom-right
|
|
|
|
const muteButtonCenterX = videoWidth - Math.round(muteButtonWidth / 2);
|
|
|
|
const muteButtonCenterY = videoHeight - Math.round(muteButtonHeight / 2);
|
|
|
|
// Scrubber bar is between the play and mute buttons. We don't need it's
|
|
|
|
// X center, just the offset of its box.
|
|
|
|
const scrubberOffsetX = 0 + playButtonWidth;
|
|
|
|
const scrubberCenterY = videoHeight - Math.round(scrubberHeight / 2);
|
2008-12-02 09:47:44 -08:00
|
|
|
|
|
|
|
function runTest(event) {
|
|
|
|
ok(true, "----- test #" + testnum + " -----");
|
|
|
|
|
|
|
|
switch (testnum) {
|
2009-02-07 13:43:43 -08:00
|
|
|
/*
|
|
|
|
* Check operation of play/pause/mute/unmute buttons.
|
|
|
|
*/
|
2008-12-02 09:47:44 -08:00
|
|
|
case 1:
|
|
|
|
// Check initial state upon load
|
2009-10-15 04:24:28 -07:00
|
|
|
is(event.type, "canplaythrough", "checking event type");
|
2008-12-02 09:47:44 -08:00
|
|
|
is(video.paused, true, "checking video play state");
|
|
|
|
is(video.muted, false, "checking video mute state");
|
2009-10-15 04:24:28 -07:00
|
|
|
// Don't respond to any more canplaythroughs
|
|
|
|
event.target.removeEventListener("canplaythrough", runTest, false);
|
2008-12-02 09:47:44 -08:00
|
|
|
|
2008-12-10 23:30:54 -08:00
|
|
|
// Click the play button
|
2009-02-07 13:43:43 -08:00
|
|
|
synthesizeMouse(video, playButtonCenterX, playButtonCenterY, { });
|
2008-12-02 09:47:44 -08:00
|
|
|
break;
|
|
|
|
|
2008-12-19 17:33:20 -08:00
|
|
|
case 2:
|
2008-12-02 09:47:44 -08:00
|
|
|
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
|
2009-02-07 13:43:43 -08:00
|
|
|
synthesizeMouse(video, playButtonCenterX, playButtonCenterY, { });
|
2008-12-02 09:47:44 -08:00
|
|
|
break;
|
|
|
|
|
2008-12-19 17:33:20 -08:00
|
|
|
case 3:
|
2008-12-02 09:47:44 -08:00
|
|
|
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
|
2009-02-07 13:43:43 -08:00
|
|
|
synthesizeMouse(video, muteButtonCenterX, muteButtonCenterY, { });
|
2008-12-02 09:47:44 -08:00
|
|
|
break;
|
|
|
|
|
2008-12-19 17:33:20 -08:00
|
|
|
case 4:
|
2008-12-02 09:47:44 -08:00
|
|
|
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
|
2009-02-07 13:43:43 -08:00
|
|
|
synthesizeMouse(video, muteButtonCenterX, muteButtonCenterY, { });
|
2008-12-02 09:47:44 -08:00
|
|
|
break;
|
|
|
|
|
2009-02-07 13:43:43 -08:00
|
|
|
/*
|
|
|
|
* Bug 470596: Make sure that having CSS border or padding doesn't
|
|
|
|
* break the controls (though it should move them)
|
|
|
|
*/
|
2008-12-19 17:33:20 -08:00
|
|
|
case 5:
|
2008-12-02 09:47:44 -08:00
|
|
|
is(event.type, "volumechange", "checking event type");
|
|
|
|
is(video.paused, true, "checking video play state");
|
|
|
|
is(video.muted, false, "checking video mute state");
|
|
|
|
|
2008-12-27 17:58:14 -08:00
|
|
|
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
|
2009-02-07 13:43:43 -08:00
|
|
|
synthesizeMouse(video, 100 + playButtonCenterX, 40 + playButtonCenterY, { });
|
2008-12-27 17:58:14 -08:00
|
|
|
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");
|
2009-02-07 13:43:43 -08:00
|
|
|
video.pause();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
is(event.type, "pause", "checking event type");
|
|
|
|
is(video.paused, true, "checking video play state");
|
|
|
|
is(video.muted, false, "checking video mute state");
|
2008-12-27 17:58:14 -08:00
|
|
|
|
|
|
|
// Click the mute button
|
2009-02-07 13:43:43 -08:00
|
|
|
synthesizeMouse(video, 100 + muteButtonCenterX, 40 + muteButtonCenterY, { });
|
2008-12-27 17:58:14 -08:00
|
|
|
break;
|
|
|
|
|
2009-02-07 13:43:43 -08:00
|
|
|
case 8:
|
2008-12-27 17:58:14 -08:00
|
|
|
is(event.type, "volumechange", "checking event type");
|
2009-02-07 13:43:43 -08:00
|
|
|
is(video.paused, true, "checking video play state");
|
2008-12-27 17:58:14 -08:00
|
|
|
is(video.muted, true, "checking video mute state");
|
2009-02-07 13:43:43 -08:00
|
|
|
// Clear the style set in test 5.
|
|
|
|
video.style.border = "";
|
|
|
|
video.style.borderWidth = "";
|
|
|
|
video.style.padding = "";
|
|
|
|
|
|
|
|
video.muted = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Previous tests have moved playback postion, reset it to 0.
|
|
|
|
*/
|
|
|
|
case 9:
|
|
|
|
is(event.type, "volumechange", "checking event type");
|
|
|
|
is(video.paused, true, "checking video play state");
|
|
|
|
is(video.muted, false, "checking video mute state");
|
|
|
|
ok(true, "video position is at " + video.currentTime);
|
|
|
|
video.currentTime = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
is(event.type, "seeking", "checking event type");
|
|
|
|
ok(true, "video position is at " + video.currentTime);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Drag the slider's thumb to the halfway point with the mouse.
|
|
|
|
*/
|
|
|
|
case 11:
|
|
|
|
is(event.type, "seeked", "checking event type");
|
2009-02-07 17:28:56 -08:00
|
|
|
ok(true, "video position is at " + video.currentTime);
|
|
|
|
// Bug 477434 -- sometimes we get 0.098999 here instead of 0!
|
|
|
|
// is(video.currentTime, 0.0, "checking playback position");
|
2009-02-07 13:43:43 -08:00
|
|
|
|
2009-04-23 00:33:35 -07:00
|
|
|
var beginDragX = scrubberOffsetX;
|
2009-02-07 13:43:43 -08:00
|
|
|
var endDragX = scrubberOffsetX + (scrubberWidth / 2);
|
|
|
|
synthesizeMouse(video, beginDragX, scrubberCenterY, { type: "mousedown", button: 0 });
|
|
|
|
synthesizeMouse(video, endDragX, scrubberCenterY, { type: "mousemove", button: 0 });
|
|
|
|
synthesizeMouse(video, endDragX, scrubberCenterY, { type: "mouseup", button: 0 });
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
is(event.type, "seeking", "checking event type");
|
|
|
|
ok(true, "video position is at " + video.currentTime);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Click the slider at the 1/4 point with the mouse (jump backwards)
|
|
|
|
*/
|
|
|
|
case 13:
|
|
|
|
is(event.type, "seeked", "checking event type");
|
|
|
|
ok(true, "video position is at " + video.currentTime);
|
|
|
|
var expectedTime = videoDuration / 2;
|
|
|
|
ok(Math.abs(video.currentTime - expectedTime) < 0.1, "checking expected playback position");
|
|
|
|
|
|
|
|
synthesizeMouse(video, scrubberOffsetX + (scrubberWidth / 4), scrubberCenterY, { });
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
is(event.type, "seeking", "checking event type");
|
|
|
|
ok(true, "video position is at " + video.currentTime);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
is(event.type, "seeked", "checking event type");
|
|
|
|
ok(true, "video position is at " + video.currentTime);
|
|
|
|
// The scrubber currently just jumps towards the nearest pageIncrement point, not
|
|
|
|
// precisely to the point clicked. So, expectedTime isn't (videoDuration / 4).
|
|
|
|
// We should end up at 1.733, but sometimes we end up at 1.498. I guess
|
|
|
|
// it's timing depending if the <scale> things it's click-and-hold, or a
|
|
|
|
// single click. So, just make sure we end up less that the previous
|
|
|
|
// position.
|
|
|
|
lastPosition = (videoDuration / 2) - 0.1;
|
|
|
|
ok(video.currentTime < lastPosition, "checking expected playback position");
|
2008-12-27 17:58:14 -08:00
|
|
|
|
2008-12-02 09:47:44 -08:00
|
|
|
SimpleTest.finish();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-12-19 17:33:20 -08:00
|
|
|
throw "unexpected test #" + testnum + " w/ event " + event.type;
|
2008-12-02 09:47:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
testnum++;
|
|
|
|
}
|
|
|
|
|
2008-12-19 17:33:20 -08:00
|
|
|
var testnum = 1;
|
|
|
|
var video = document.getElementById("video");
|
|
|
|
|
2009-01-29 17:45:58 -08:00
|
|
|
// Kick off test once video has loaded.
|
2009-10-15 04:24:28 -07:00
|
|
|
video.addEventListener("canplaythrough", runTest, false);
|
2008-12-19 17:33:20 -08:00
|
|
|
|
|
|
|
// Other events expected by the test.
|
2008-12-02 09:47:44 -08:00
|
|
|
video.addEventListener("play", runTest, false);
|
|
|
|
video.addEventListener("pause", runTest, false);
|
|
|
|
video.addEventListener("volumechange", runTest, false);
|
2009-02-07 13:43:43 -08:00
|
|
|
video.addEventListener("seeking", runTest, false);
|
|
|
|
video.addEventListener("seeked", runTest, false);
|
2008-12-02 09:47:44 -08:00
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|