| <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, #shadow { |
| position: absolute; |
| left: 0; |
| top: 0; |
| width: 320px; |
| height: 240px; |
| } |
| |
| </style> |
| <video src="../../content/test.mp4" style="visibility: hidden;" controls autoplay></video> |
| <div id="shadow"></div> |
| <script type="text/javascript"> |
| |
| window.jsTestIsAsync = true; |
| |
| description("Testing the <code>MuteSupport</code> behavior by clicking on the mute button."); |
| |
| const host = document.querySelector("div#shadow"); |
| const media = document.querySelector("video"); |
| const mediaController = createControls(host, media, null); |
| |
| shouldBeFalse("mediaController.controls.muteButton.muted"); |
| |
| let numberOfEvents = 0; |
| media.addEventListener("volumechange", function() { |
| debug(""); |
| debug("volumechange event was dispatched"); |
| |
| numberOfEvents++; |
| |
| if (numberOfEvents == 1) { |
| shouldBeTrue("media.muted"); |
| shouldBeTrue("mediaController.controls.muteButton.muted"); |
| pressOnMuteButton(); |
| } else if (numberOfEvents == 2) { |
| shouldBeFalse("media.muted"); |
| shouldBeFalse("mediaController.controls.muteButton.muted"); |
| debug(""); |
| host.remove(); |
| media.remove(); |
| finishJSTest(); |
| } |
| }); |
| |
| function pressOnMuteButton() |
| { |
| debug(""); |
| debug("Pressing the mute button"); |
| pressOnElement(mediaController.controls.muteButton.element); |
| } |
| |
| media.addEventListener("play", event => { |
| media.pause(); |
| pressOnMuteButton(); |
| }); |
| |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |