blob: 845fd7c64c9e8ace537264df14d5a03245b12d22 [file] [edit]
<html>
<head>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
var playThroughCount = 0;
var videos = [];
var secondPlaying = false;
var firstPaused = false;
function logEvent(evt)
{
consoleWrite("EVENT(" + evt.type + ")");
}
function maybeFinish()
{
if (!secondPlaying || !firstPaused)
return;
testExpected("videos[0].paused", true);
testExpected("videos[1].paused", false);
consoleWrite("");
endTest();
}
function playing(evt)
{
// The second video's 'playing' is required but not logged: whether it is at
// HAVE_FUTURE_DATA when play() is called decides whether the event is queued then or
// from a later readyState change, so its order against the first video's pause varies.
if (evt.target == videos[1]) {
secondPlaying = true;
maybeFinish();
return;
}
logEvent(evt);
consoleWrite("");
consoleWrite("** Starting the second video, the first one should pause.");
run("videos[1].play()");
failTestIn(500);
}
function pause(evt)
{
logEvent(evt);
consoleWrite("");
firstPaused = true;
maybeFinish();
}
function canplaythrough(evt)
{
logEvent(evt);
if (++playThroughCount < 2)
return;
consoleWrite("<br>** Play first video...");
run("videos[0].play()");
}
function start()
{
if (!window.internals) {
failTest('This test requires window.internals.');
return;
}
videos = document.getElementsByTagName('video');
for (var i = 0; i < videos.length; ++i) {
video = videos[i];
video.addEventListener("canplaythrough", canplaythrough);
video.addEventListener('playing', playing);
video.addEventListener('pause', pause);
video.src = findMediaFile("video", "content/test");
}
run("internals.setMediaSessionRestrictions('videoaudio', 'ConcurrentPlaybackNotPermitted')");
consoleWrite("");
}
</script>
</head>
<body onload="start()">
<video controls id="one"></video>
<video controls id="two"></video>
<p>Test play() when concurrent playback not allowed.</p>
</body>
</html>