blob: 8047a641f342ae0e30609c8c19b11074b76a047c [file] [log] [blame]
<!DOCTYPE html>
<title>Moving media element to other document to bypass autoplay</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<script>
function createAndMoveVideo() {
var v = document.implementation.createHTMLDocument().createElement('video');
v.src = 'content/test.ogv';
document.body.appendChild(v);
return v;
}
test(function() {
assert_true(window.internals != null, 'This test only works with internals exposed present');
}, 'internals are exposed');
async_test(function(t) {
window.internals.settings.setAutoplayPolicy('no-user-gesture-required');
var v = createAndMoveVideo();
assert_true(v.paused, 'Video should be paused before calling play()');
v.play().then(
t.step_func_done(),
t.step_func_done(function() {
assert_unreached('Video should autoplay when gesture not required');
}));
}, 'Test that video should autoplay without gesture requirement');
async_test(function(t) {
window.internals.settings.setAutoplayPolicy('user-gesture-required');
var v = createAndMoveVideo();
assert_true(v.paused, 'Video should be paused before calling play()');
v.play().then(
t.step_func_done(function() {
assert_unreached('Video should not autoplay when gesture required');
}),
t.step_func_done());
}, 'Test that video should not autoplay when gesture required');
</script>
</body>