blob: e3a084521c9be9476fd7120530290238c03eb25e [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);
let numberOfEvents = 0;
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", () => {
numberOfEvents++;
if (numberOfEvents == 1) {
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();
} else {
shouldBe("media.currentTime", "0");
container.remove();
media.remove();
finishJSTest();
}
});
// Start dragging.
eventSender.mouseMoveTo(dragStartX, centerY);
eventSender.mouseDown();
scheduler.frameDidFire = null;
};
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>