OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>media controls cast button</title> |
| 5 <script src="../resources/testharness.js"></script> |
| 6 <script src="../resources/testharnessreport.js"></script> |
| 7 <script src="media-file.js"></script> |
| 8 <script src="media-controls.js"></script> |
| 9 <script src="video-test.js"></script> |
| 10 </head> |
| 11 <body> |
| 12 <video></video> |
| 13 <script> |
| 14 async_test(function(t) |
| 15 { |
| 16 findMediaElement(); |
| 17 video.src = findMediaFile("video", "content/test"); |
| 18 mediaElement.addEventListener("loadedmetadata", function() |
| 19 { |
| 20 // Should not have a cast button by default |
| 21 button = mediaControlsButton(video, "overlay-cast-button"); |
| 22 assert_equals(button.style.display, "none", "button should not b
e visible with no cast devices"); |
| 23 |
| 24 // Pretend we have a cast device |
| 25 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true)
; |
| 26 // Now should have cast button |
| 27 assert_false(("display" in button.style) && (button.style.displa
y == "none"), "button should exist"); |
| 28 dimensions = mediaControlsButtonDimensions(video, "overlay-cast-
button"); |
| 29 assert_not_equals(dimensions[0], 0, "button should exist"); |
| 30 assert_not_equals(dimensions[1], 0, "button should exist"); |
| 31 |
| 32 // Check position, should be in the top left corner of the video |
| 33 rect = button.getBoundingClientRect(); |
| 34 videoRect = video.getBoundingClientRect(); |
| 35 assert_greater_than_equal(rect.top, videoRect.top, "button shoul
d be at top left of video"); |
| 36 assert_greater_than_equal(rect.left, videoRect.left, "button sho
uld be at top left of video"); |
| 37 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.he
ight / 2, "button should be at top left of video"); |
| 38 assert_less_than_equal(rect.right, videoRect.left + videoRect.wi
dth / 2, "button should be at top left of video"); |
| 39 |
| 40 // Remove cast device - cast button should go away |
| 41 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false
); |
| 42 assert_equals(button.style.display, "none", "button should not b
e visible after cast device goes away"); |
| 43 t.done(); |
| 44 }) |
| 45 }); |
| 46 </script> |
| 47 </body> |
| 48 </html> |
OLD | NEW |