| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>media controls cast button</title> | |
| 3 <script src="../resources/testharness.js"></script> | |
| 4 <script src="../resources/testharnessreport.js"></script> | |
| 5 <script src="media-file.js"></script> | |
| 6 <script src="media-controls.js"></script> | |
| 7 <video controls width="500"></video> | |
| 8 <script> | |
| 9 async_test(function(t) { | |
| 10 var video = document.querySelector("video"); | |
| 11 video.src = findMediaFile("video", "content/test"); | |
| 12 | |
| 13 video.onloadedmetadata = t.step_func_done(function() { | |
| 14 // Should not have a cast button by default | |
| 15 var button = castButton(video); | |
| 16 assert_equals(button.style.display, "none", "button should not be visibl
e with no cast devices"); | |
| 17 | |
| 18 // Pretend we have a cast device | |
| 19 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true); | |
| 20 | |
| 21 // Now should have cast button | |
| 22 assert_false(("display" in button.style) && (button.style.display == "no
ne"), "button should exist"); | |
| 23 var buttonBoundingRect = button.getBoundingClientRect(); | |
| 24 var dimensions = new Array(buttonBoundingRect.width, buttonBoundingRect.
height); | |
| 25 assert_not_equals(dimensions[0], 0, "button should exist"); | |
| 26 assert_not_equals(dimensions[1], 0, "button should exist"); | |
| 27 | |
| 28 // Check its position is to the right of the timeline | |
| 29 // (can't test against volume control or closed caption button, since th
ese don't always exist) | |
| 30 var x = buttonBoundingRect.left + buttonBoundingRect.width / 2; | |
| 31 var timelinePosition = mediaControlsButtonCoordinates(video, "timeline")
; | |
| 32 assert_greater_than(x, timelinePosition[0], "button should be to right o
f timeline"); | |
| 33 | |
| 34 // Check that we don't have an overlay cast button | |
| 35 var overlayButton = overlayCastButton(video); | |
| 36 assert_equals(overlayButton.style.display, "none", "Overlay button shoul
d not be visible with controls"); | |
| 37 | |
| 38 // And to the right of the fullscreen button | |
| 39 var fullscreenPosition = mediaControlsButtonCoordinates(video, "fullscre
en-button"); | |
| 40 assert_greater_than(x, fullscreenPosition[0], "button should be to right
of fullscreen button"); | |
| 41 | |
| 42 // Remove cast device - cast button should go away | |
| 43 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false); | |
| 44 assert_equals(button.style.display, "none", "button should not be visibl
e after cast device goes away"); | |
| 45 }); | |
| 46 }); | |
| 47 </script> | |
| OLD | NEW |