gecko-dev/dom/media/test/test_dormant_playback.html

83 строки
1.7 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>Media test: Test resuming from dormant does not emit seek related events</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script class="testbody" type="text/javascript">
var gNeedInit = false;
var gLoadedEvent = false;
var gSeekEvent = false;
var v1 = null;
function startVideoPlayback() {
v1.play()
}
function setVideoVisible() {
document.body.appendChild(v1);
setTimeout(startVideoPlayback, 0);
}
function checkResult() {
ok(!gLoadedEvent, "loadedmetadata event should not happen");
ok(!gSeekEvent, "seek event should not happen");
SimpleTest.finish();
}
function loadedMetadata(e) {
if (gNeedInit) {
v1.currentTime = 0;
return;
}
gLoadedEvent = true;
}
function playbackEnded(e) {
checkResult();
}
function seekEnded(e) {
if (gNeedInit) {
gNeedInit = false;
gLoadedEvent = false;
gSeekEvent = false;
document.body.removeChild(v1);
setTimeout(setVideoVisible, 0);
return;
}
gSeekEvent = true;
}
function seeking(e) {
gSeekEvent = true;
}
function runTest() {
gNeedInit = true;
v1 = document.createElement('video');
document.body.appendChild(v1);
v1.preload = "metadata";
v1.src = "gizmo.mp4"
v1.addEventListener("loadedmetadata", loadedMetadata, false);
v1.addEventListener("ended", playbackEnded, false);
v1.addEventListener("seeked", seekEnded, false);
v1.addEventListener("seeking", seeking, false);
}
addLoadEvent(runTest);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>