blob: 4c56661d26af445055db7079f76c36d3c05cebd7 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Don't unmute video when a tab becomes visible unless it was muted when the tab was hidden</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
let audioTrack;
let videoTrack;
promise_test((t) => {
if (window.testRunner)
testRunner.setUserMediaPermission(true);
if (!window.internals)
return Promise.reject("this test needs internals API");
return navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then((stream) => {
audioTrack = stream.getAudioTracks()[0];
videoTrack = stream.getVideoTracks()[0];
assert_false(audioTrack.muted, "audio track is active");
assert_false(videoTrack.muted, "video track is active");
})
.then(() => {
test(() => {
if (window.internals)
window.internals.setPageVisibility(false);
assert_false(audioTrack.muted, "audio track is active");
assert_true(videoTrack.muted, "video track is muted");
}, "Hide page, only video should be muted");
})
.then(() => {
test(() => {
if (window.internals)
window.internals.setPageVisibility(true);
assert_false(audioTrack.muted, "audio track is active");
assert_false(videoTrack.muted, "video track is active");
}, "Show page, video and audio should be unmuted");
})
.then(() => {
test(() => {
if (window.internals) {
window.internals.setPageVisibility(false);
window.internals.setPageMuted("capturedevices");
}
assert_true(audioTrack.muted, "audio track is muted");
assert_true(videoTrack.muted, "video track is muted");
}, "Hide and mute page, video and audio should be muted");
})
.then(() => {
test(() => {
if (window.internals)
window.internals.setPageVisibility(true);
assert_true(audioTrack.muted, "audio track is muted");
assert_true(videoTrack.muted, "video track is muted");
}, "Show page, video and audio should remain muted");
})
}, "Setup stream");
</script>
</body>
</html>