blob: 0410b87a09250351c24a469dcfbebfd8b8d59b27 [file] [log] [blame]
<script src="../../../resources/js-test-pre.js"></script>
<script src="../resources/media-controls-loader.js" type="text/javascript"></script>
<body>
<video src="../../content/test.mp4" style="width: 320px; height: 240px;" controls></video>
<div id="shadow"></div>
<script type="text/javascript">
window.jsTestIsAsync = true;
description("Testing the <code>ControlsVisibilitySupport</code> behavior when the controls attribute changes.");
const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
const media = document.querySelector("video");
const mediaController = createControls(shadowRoot, media, null);
let numberOfMutations = 0;
new MutationObserver(() => {
numberOfMutations++;
if (numberOfMutations === 1) {
shouldBeFalse("mediaController.controls.visible");
debug("");
debug("Turning controls back on");
media.controls = true;
} else {
shouldBeTrue("mediaController.controls.visible");
debug("");
shadowRoot.host.remove();
media.remove();
finishJSTest();
}
}).observe(media, { attributes: true, attributeFilter: ["controls"] });
media.addEventListener("loadedmetadata", function() {
debug("");
debug("Media has loaded metadata");
shouldBecomeEqual("media.videoTracks.length", "1", () => {
shouldBeTrue("mediaController.controls.visible");
debug("");
debug("Turning controls off");
media.controls = false;
});
});
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>