blob: 061ee0b15faa3b35f572c2dfb98695b8a061d02c [file] [log] [blame]
<script src="../../../resources/js-test-pre.js"></script>
<script src="../resources/media-controls-loader.js" type="text/javascript"></script>
<script src="../resources/media-controls-utils.js" type="text/javascript"></script>
<body>
<audio src="../../content/test.mp4" style="width: 600px; height: 50px;" controls></audio>
<div id="container"></div>
<script type="text/javascript">
window.jsTestIsAsync = true;
description("Testing the <code>&lt;audio></code> controls buttons.");
const shadowRoot = document.querySelector("#container");
const media = document.querySelector("audio");
const mediaController = createControls(shadowRoot, media, null);
media.addEventListener("canplay", makeAirPlayAvailable);
function makeAirPlayAvailable()
{
debug("Making AirPlay routes available.");
media.addEventListener("webkitplaybacktargetavailabilitychanged", playbackTargetAvailabilityChangedOnce, true);
window.internals.setMockMediaPlaybackTargetPickerEnabled(true);
}
function playbackTargetAvailabilityChangedOnce(event)
{
media.removeEventListener('webkitplaybacktargetavailabilitychanged', playbackTargetAvailabilityChangedOnce, true);
media.addEventListener('webkitplaybacktargetavailabilitychanged', playbackTargetAvailabilityChangedAgain, true);
window.internals.setMockMediaPlaybackTargetPickerState('Sleepy TV', 'DeviceAvailable');
}
function playbackTargetAvailabilityChangedAgain(event)
{
// setMockMediaPlaybackTargetPickerState happens asynchronously in WK2 and a
// "webkitplaybacktargetavailabilitychanged" is always sent when an event listener
// is added, so we may get a "not available" event first.
if (event.availability == 'not-available')
return;
debug("AirPlay routes became available.");
media.removeEventListener('webkitplaybacktargetavailabilitychanged', playbackTargetAvailabilityChangedAgain, true);
shouldBe("mediaController.controls.rightContainer.children.length", "2");
shouldBe("mediaController.controls.rightContainer.children[0]", "mediaController.controls.muteButton");
shouldBe("mediaController.controls.rightContainer.children[1]", "mediaController.controls.airplayButton");
mediaController.controls.bottomControlsBar.element.setAttribute("id", "audio-controls");
shouldBeEqualToString("accessibilityController.accessibleElementById('audio-controls').description", "AXDescription: Audio Controls");
debug("");
shadowRoot.remove();
media.remove();
finishJSTest();
}
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>