blob: 6e3c9e9b37bfd3459b91a3cfabad9fe1d8bdc662 [file] [log] [blame]
<!DOCTYPE html>
<title>media controls cast button</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script>
<script src="media-controls.js"></script>
<video width="100" height="200" controls></video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
video.src = findMediaFile("video", "content/test");
video.onloadedmetadata = t.step_func_done(function() {
// Pretend we have a cast device
internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
// Video should not have a cast button since the video is too narrow
var button = castButton(video);
assert_equals(button.style.display, "none", "button should not be visible with no cast devices");
// It should, however, have an overlay cast button instead
button = overlayCastButton(video);
var rect = button.getBoundingClientRect();
var videoRect = video.getBoundingClientRect();
assert_greater_than_equal(rect.top, videoRect.top, "button should be at top left of video");
assert_greater_than_equal(rect.left, videoRect.left, "button should be at top left of video");
assert_less_than_equal(rect.bottom, videoRect.top + videoRect.height / 2, "button should be at top left of video");
assert_less_than_equal(rect.right, videoRect.left + videoRect.width / 2, "button should be at top left of video");
});
function castButton(element) {
var controlID = "-internal-media-controls-cast-button";
var button = mediaControlsElement(internals.shadowRoot(element).firstChild, controlID);
if (!button)
throw "Failed to find cast button";
return button;
}
function overlayCastButton(element) {
var controlID = "-internal-media-controls-overlay-cast-button";
var button = mediaControlsElement(internals.shadowRoot(element).firstChild, controlID);
if (!button)
throw "Failed to find cast button";
return button;
}
});
</script>