blob: fd33c05922ad22f0423bffb5b2e78e99306d0b91 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>restricted-audio-playback-with-document-gesture</title>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
function runTest()
{
next();
}
function next() {
if (!tests.length) {
endTest()
return;
}
mediaElement = document.createElement('audio');
if (window.internals)
internals.setMediaElementRestrictions(mediaElement, "RequireUserGestureForAudioRateChange");
var nextTest = tests.shift();
consoleWrite('');
run("mediaElement.src = findMediaFile('audio', 'content/test')");
waitForEvent('canplaythrough', event => { runWithKeyDown(nextTest) });
}
var tests = [
function() {
consoleWrite('Test > 1s in single step');
consoleWrite('setTimeout 1, 1.1s');
setTimeout(() => {
run("shouldReject(mediaElement.play()).then(next, next)");
}, 1100);
},
function() {
consoleWrite('Test > 1s in multiple steps');
consoleWrite('setTimeout 1, 0.6s');
setTimeout(() => {
consoleWrite('setTimeout 1, 0.6s');
setTimeout(() => {
run("shouldReject(mediaElement.play()).then(next, next)");
}, 600);
}, 600);
},
function() {
consoleWrite('Test < 1s total.')
consoleWrite('setTimeout 1, 0.1s');
setTimeout(() => {
consoleWrite('setTimeout 2, 0.1s');
setTimeout(() => {
consoleWrite('setTimeout 3, 0.1s');
setTimeout(() => {
consoleWrite('setTimeout 4, 0.1s');
setTimeout(() => {
consoleWrite('setTimeout 5, 0.1s');
setTimeout(() => {
run("shouldResolve(mediaElement.play()).then(next, next)");
}, 100);
}, 100);
}, 100);
}, 100);
}, 100);
},
];
</script>
</head>
<body onload="runTest()">
<p>Test that, when RequireUserGestureForAudioRateChange is set along with MediaUserGestureInheritsForDocument,
nested setTimeout() calls of less than 1s will not block play() from succeeding.</p>
</body>
</html>