| <script src="../../../resources/js-test-pre.js"></script> |
| <script src="../resources/media-controls-loader.js" type="text/javascript"></script> |
| <body> |
| <style type="text/css" media="screen"> |
| |
| video, #host { |
| position: absolute; |
| top: 0; |
| left: 0; |
| width: 800px; |
| 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>VolumeSupport</code> behavior when clicking the volume slider."); |
| |
| const container = document.querySelector("div#host"); |
| const media = document.querySelector("video"); |
| const mediaController = createControls(container, media, null); |
| |
| let numberOfFrames = 0; |
| scheduler.frameDidFire = function() { |
| const muteButtonElement = mediaController.controls.muteButton.element; |
| const muteButtonBounds = muteButtonElement.getBoundingClientRect(); |
| |
| if (media.paused || muteButtonBounds.width === 0) |
| return; |
| |
| numberOfFrames++; |
| |
| if (numberOfFrames == 1) { |
| // Controls are now visible, let's hover over the mute button to make the volume control visible. |
| eventSender.mouseMoveTo(muteButtonBounds.left + muteButtonBounds.width / 2, muteButtonBounds.top + muteButtonBounds.height / 2); |
| } else if (numberOfFrames == 2) { |
| // Volume slider is visible, let's click in the middle of it. |
| const volumeSliderBounds = mediaController.controls.volumeSlider.element.getBoundingClientRect(); |
| eventSender.mouseMoveTo(volumeSliderBounds.left + volumeSliderBounds.width / 2, volumeSliderBounds.top + volumeSliderBounds.height / 2); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| |
| // Ensure the volume slider remains visible. |
| shouldBeTrue("mediaController.controls.volumeSlider.parent.visible"); |
| |
| scheduler.frameDidFire = null; |
| } |
| }; |
| |
| // First, ensure controls are shown. |
| mediaController.controls.showsStartButton = false; |
| |
| media.addEventListener("volumechange", () => { |
| // Because the slider has a 9pt-wide knob and tests are ran at 1x, we can't get 0.5 here, and instead get 0.51 since |
| // the slider will only increment on whole pixels. |
| shouldBe("media.volume", "0.51"); |
| container.remove(); |
| media.remove(); |
| finishJSTest(); |
| }); |
| |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |