content/media/video/test/test_play.html
author L. David Baron <dbaron@dbaron.org>
Wed, 06 May 2009 13:46:04 -0700
changeset 28048 8f7b73d88f6bbedec99c6c8ef48b243ab922d05c
parent 25188 fd60f1dd129914dc2db2ba85e25e578c6c562761
permissions -rw-r--r--
Switch HTML mochitests from using MochiKit.js to packed.js. (Bug 490955) r=sayrer

<!DOCTYPE HTML>
<html>
<head>
  <title>Media test: play() method</title>
  <script type="text/javascript" src="/MochiKit/packed.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>