blob: 59587985e122a893234bd75eb615cf93cc0f3b23 [file] [log] [blame]
<!-- webkit-test-runner [ enableModernMediaControls=false ] -->
<html>
<head>
<title>Test that video play, pause and enterfullscreen does not work unless a user gesture is involved in playing a video</title>
<script src=media-controls.js></script>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
var userGestureInitiated = 0;
if (window.internals)
window.internals.settings.setAudioPlaybackRequiresUserGesture(true);
function playing()
{
if (userGestureInitiated == 0) {
failTest("Should not play without user gesture.");
} else {
run("video.pause()");
}
}
function pause()
{
testExpected("video.paused", true);
// Now video.webkitEnterFullScreen() should no longer throw any exception.
// However, the video element may not always enter fullscreen. For example,
// chromium uses fullscreen API which still requires user gesture
try {
run("video.webkitEnterFullScreen()");
} catch(ex) {
failTest("video.webkitEnterFullScreen() still requires user gesture.");
}
endTest();
}
function canplaythrough()
{
consoleWrite("");
consoleWrite("* No user gesture initiated");
run("handlePromise(video.play())");
testDOMException("video.webkitEnterFullScreen()", "DOMException.INVALID_STATE_ERR");
testExpected("video.paused", true);
consoleWrite("");
consoleWrite("* User gesture initiated");
userGestureInitiated = 1;
try {
clickPlayButton(video);
} catch (exception) {
failTest(exception.description);
return;
}
}
function start()
{
findMediaElement();
waitForEvent('canplaythrough', canplaythrough);
waitForEvent('playing', playing);
waitForEvent('pause', pause);
video.src = findMediaFile("video", "content/test");
}
</script>
</head>
<body onload="start()">
<p>Test that video play(), pause() and webkitEnterFullScreen() should not work unless a user clicked on the play button.</p>
<video controls></video>
</body>
</html>