blob: 689f8024d460ff5a8f2f9767a0413ee1de017a82 [file] [log] [blame]
<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" autoplay controls></video>
<div id="host"></div>
<script type="text/javascript">
window.jsTestIsAsync = true;
description("Testing the <code>ScrubberSupport</code> behavior when dragging the scrubber.");
const container = document.querySelector("div#host");
const media = document.querySelector("video");
const mediaController = createControls(container, media, null);
scheduler.frameDidFire = function() {
if (media.paused)
return;
const elapsed = mediaController.controls.timeControl.elapsedTimeLabel.element;
const input = mediaController.controls.timeControl.scrubber.children[1].element;
const bounds = input.getBoundingClientRect();
if (elapsed.getBoundingClientRect().width === 0 || bounds.width === 0)
return;
media.pause();
const dragStartX = bounds.left + bounds.width / 2;
const dragEndX = bounds.left - 1;
const centerY = bounds.top + bounds.height / 2;
media.addEventListener("timeupdate", () => {
shouldBeCloseTo("media.currentTime", media.duration / 2, 0.2);
const delta = dragEndX - dragStartX;
const iterations = Math.abs(delta);
for (let i = 1; i <= iterations; ++i)
eventSender.mouseMoveTo(dragStartX + i * Math.sign(delta), centerY);
eventSender.mouseUp();
shouldBecomeEqual("media.currentTime", "0", () => {
container.remove();
media.remove();
finishJSTest();
});
}, { once: true });
// Start dragging.
eventSender.mouseMoveTo(dragStartX, centerY);
eventSender.mouseDown();
scheduler.frameDidFire = null;
};
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>