Bug 1128357 patch 3: test for video playback with dormant r=cpearce

This commit is contained in:
Sotaro Ikeda 2015-03-04 17:34:17 -08:00
parent bb4f18fdee
commit f3c7c9db0e
2 changed files with 84 additions and 0 deletions

View File

@ -364,6 +364,8 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
[test_defaultMuted.html]
[test_delay_load.html]
skip-if = buildapp == 'b2g' && toolkit != 'gonk' # bug 1082984
[test_dormant_playback.html]
skip-if = (os == 'win' && os_version == '5.1') || (os != 'win' && toolkit != 'gonk')
[test_eme_access_control.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
[test_eme_canvas_blocked.html]

View File

@ -0,0 +1,82 @@
<!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>