The autoplay setting was binary and its default blocked all media, including muted video, leaving sites that rely on muted autoplay visibly broken. Replace it with a tri-state user-agent autoplay policy (allow audio and video, block audio, or block audio and video) defaulting to allowing only inaudible media to autoplay. This is enforced through the media element's "allowed to play" check, so unmuting a muted autoplay or calling `play()` cannot slip audio past the policy; audible playback is permitted once the document has been activated by the user. The policy lives in a dedicated AutoplaySettings consulted from HTMLMediaElement instead of the Permissions Policy "allowed to use feature" check it was previously conflated with.
37 lines
1.3 KiB
HTML
37 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<!-- Pin the policy here (not via the browser setting test-web inherits) so the result is deterministic
|
|
regardless of test order on a reused WebContent process. Served over HTTP (see the .headers file)
|
|
so the file:// autoplay carve-out does not apply: under "Block Audio", muted media autoplays while
|
|
audible media does not. -->
|
|
<script>internals.setAutoplayPolicy("block-audio");</script>
|
|
<video autoplay muted id="muted" src="../../../Assets/test-webm.webm"></video>
|
|
<video autoplay id="audible" src="../../../Assets/test-webm.webm"></video>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest(done => {
|
|
const results = {};
|
|
let remaining = 2;
|
|
|
|
setTimeout(() => {
|
|
println("FAIL: timeout waiting for media to load");
|
|
done();
|
|
}, 15_000);
|
|
|
|
function watch(key, video) {
|
|
const finish = value => {
|
|
results[key] = value;
|
|
if (--remaining === 0) {
|
|
println(`muted video autoplays: ${results.muted}`);
|
|
println(`audible video autoplays: ${results.audible}`);
|
|
done();
|
|
}
|
|
};
|
|
|
|
video.addEventListener("canplaythrough", () => finish(!video.paused));
|
|
video.addEventListener("error", () => finish("error"));
|
|
}
|
|
|
|
watch("muted", document.getElementById("muted"));
|
|
watch("audible", document.getElementById("audible"));
|
|
});
|
|
</script>
|