gecko/content/media/video/test/test_play.html
Matthew Gregan fc66ef3b4b Bug 478684 - test_play.html fails intermittently
--HG--
extra : rebase_source : d84a07bc61144b7ab88e217bf9e5b815d273fb88
2009-02-18 17:16:18 +13:00

49 lines
1.2 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Media test: play() method</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<video id="v" onerror="event.stopPropagation();"></video>
<script>
SimpleTest.waitForExplicitFinish();
var v = document.getElementById("v");
var tokens = {
0: ["play"],
"play": ["canplay"],
"canplay": ["playing"],
"playing": ["canplay", "canplaythrough"],
"canplaythrough": ["canplay", "canplaythrough"]
};
var state = 0;
function gotPlayEvent(event) {
ok(tokens[state].indexOf(event.type) >= 0, "Check expected event got " + event.type + " at " + state);
state = event.type;
}
["play", "canplay", "playing", "canplaythrough"].forEach(function (e) {
v.addEventListener(e, gotPlayEvent, false);
});
function ended() {
is(state, "canplaythrough", "Last event should be canplaythrough");
SimpleTest.finish();
}
v.addEventListener("ended", ended, false);
v.src = "320x240.ogv";
v.load();
v.play();
</script>
</pre>
</body>
</html>