2010-10-14 17:13:29 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Media test: play() method</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
<script type="text/javascript" src="manifest.js"></script>
|
|
|
|
</head>
|
|
|
|
<body contenteditable="true">
|
|
|
|
<pre id="test">
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
var manager = new MediaTestManager;
|
|
|
|
|
|
|
|
var tokens = {
|
|
|
|
0: ["canplay"],
|
2011-03-29 22:37:42 -07:00
|
|
|
"canplay": ["canplay", "canplaythrough"],
|
2010-10-14 17:13:29 -07:00
|
|
|
"canplaythrough": ["canplay", "canplaythrough"]
|
|
|
|
};
|
|
|
|
|
2014-09-11 15:25:00 -07:00
|
|
|
var eventList = ["play", "canplay", "playing", "canplaythrough", "ended"];
|
|
|
|
|
2010-10-14 17:13:29 -07:00
|
|
|
function gotPlayEvent(event) {
|
|
|
|
var v = event.target;
|
|
|
|
ok(tokens[v._state].indexOf(event.type) >= 0,
|
2014-09-11 15:25:00 -07:00
|
|
|
"Check expected event got " + uneval(event.type) +
|
|
|
|
" at " + uneval(v._state) + " for " + v._name);
|
2010-10-14 17:13:29 -07:00
|
|
|
v._state = event.type;
|
2014-08-10 20:03:50 -07:00
|
|
|
if (event.type == 'canplaythrough') {
|
2014-09-11 15:25:00 -07:00
|
|
|
// Remove all event listeners to avoid running tests after finishing test case.
|
|
|
|
eventList.forEach(function (e) {
|
|
|
|
v.removeEventListener(e, gotPlayEvent, false);
|
|
|
|
});
|
2014-08-10 20:03:50 -07:00
|
|
|
v.pause();
|
|
|
|
goToNext(v);
|
|
|
|
}
|
2010-10-14 17:13:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function goToNext(v) {
|
|
|
|
v.parentNode.removeChild(v);
|
|
|
|
manager.finished(v.token);
|
|
|
|
}
|
|
|
|
|
|
|
|
function initTest(test, token) {
|
|
|
|
var v = document.createElement('video');
|
2013-07-31 00:35:44 -07:00
|
|
|
v.preload = "metadata";
|
2010-10-14 17:13:29 -07:00
|
|
|
v.token = token;
|
|
|
|
manager.started(token);
|
|
|
|
v._state = 0;
|
2014-09-11 15:25:00 -07:00
|
|
|
|
|
|
|
eventList.forEach(function (e) {
|
2010-10-14 17:13:29 -07:00
|
|
|
v.addEventListener(e, gotPlayEvent, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
v.src = test.name;
|
2014-09-11 15:25:00 -07:00
|
|
|
v._name = test.name;
|
2010-10-14 17:13:29 -07:00
|
|
|
v.autoplay = true;
|
|
|
|
document.body.appendChild(v); // Causes load.
|
|
|
|
}
|
|
|
|
|
|
|
|
manager.runTests(gSmallTests, initTest);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|