blob: c68281d2ce87c159760f00dc5e38da3094213dce [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>
<style type="text/css" media="screen">
video, #host {
position: absolute;
top: 0;
left: 0;
width: 320px;
height: 240px;
}
</style>
<video src="../../content/test.mp4" controls autoplay></video>
<div id="host"></div>
<script type="text/javascript">
window.jsTestIsAsync = true;
description("Testing the <code>PlaybackSupport</code> behavior by clicking on the play/pause button.");
const host = document.querySelector("div#host");
const media = document.querySelector("video");
const mediaController = createControls(host, media, null);
let numberOfPlayEvents = 0;
media.addEventListener("play", function() {
numberOfPlayEvents++;
debug("Media is playing");
shouldBeTrue("mediaController.controls.playPauseButton.playing");
if (numberOfPlayEvents === 1)
clickPlayPauseButton();
else {
debug("");
host.remove();
media.remove();
finishJSTest();
}
});
media.addEventListener("pause", function() {
debug("Media is paused");
shouldBeFalse("mediaController.controls.playPauseButton.playing");
clickPlayPauseButton();
});
function clickPlayPauseButton()
{
debug("");
debug("Pressing on the play/pause button");
window.requestAnimationFrame(() => pressOnElement(mediaController.controls.playPauseButton.element));
}
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>