blob: 810cc3f706425be4caf86d2877dc8f25c5117eea [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>playlist-inherits-user-gesture</title>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
async function runTest() {
consoleWrite("** Start first video with user gesture.")
if (window.internals)
run('window.internals.settings.setVideoPlaybackRequiresUserGesture(true);');
run('video1 = document.createElement("video")');
run('video1.src = findMediaFile("video", "content/test")');
video1.controls = 1;
run('document.body.appendChild(video1)');
if (window.internals)
testExpected("window.internals.pageMediaState().includes('HasUserInteractedWithMediaElement')", false);
runWithKeyDown(() => {
run('video1.play()');
});
if (window.internals)
testExpected("window.internals.pageMediaState().includes('HasUserInteractedWithMediaElement')", true)
await waitFor(video1, 'playing');
run('video1.currentTime = video1.duration - 0.2');
await waitFor(video1, 'ended');
consoleWrite("<br>** Start second video without user gesture but within inheritance window, should succeed.")
run('video2 = document.createElement("video")');
run('video2.src = findMediaFile("video", "content/test")');
video2.controls = 1;
run('document.body.appendChild(video2)');
await shouldResolve(video2.play());
run('video2.currentTime = video2.duration - 0.2');
await waitFor(video2, 'ended');
consoleWrite("<br>** Start third video without user gesture but after inheritance window, should fail.")
await sleepFor(1200);
run('video3 = document.createElement("video")');
run('video3.src = findMediaFile("video", "content/test")');
video3.controls = 1;
run('document.body.appendChild(video3)');
await shouldReject(video3.play());
endTest();
}
</script>
</head>
<body onload="runTest()">
</body>
</html>