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>
12 <video width=
"100" controls
></video>
14 function castButton(element
)
16 var controlID
= "-internal-media-controls-cast-button";
17 var button
= mediaControlsElement(window
.internals
.shadowRoot(element
).firstChild
, controlID
);
19 throw "Failed to find cast button";
22 function overlayCastButton(element
)
24 var controlID
= "-internal-media-controls-overlay-cast-button";
25 var button
= mediaControlsElement(window
.internals
.shadowRoot(element
).firstChild
, controlID
);
27 throw "Failed to find cast button";
30 function castButtonDimensions(element
)
32 var button
= castButton(element
);
33 var buttonBoundingRect
= button
.getBoundingClientRect();
34 return new Array(buttonBoundingRect
.width
, buttonBoundingRect
.height
);
36 function castButtonCoordinates(element
, id
)
38 var button
= castButton(element
);
39 var buttonBoundingRect
= button
.getBoundingClientRect();
40 var x
= buttonBoundingRect
.left
+ buttonBoundingRect
.width
/ 2;
41 var y
= buttonBoundingRect
.top
+ buttonBoundingRect
.height
/ 2;
42 return new Array(x
, y
);
44 async_test(function(t
)
47 video
.src
= findMediaFile("video", "content/test");
48 mediaElement
.addEventListener("loadedmetadata", function()
50 // Pretend we have a cast device
51 internals
.mediaPlayerRemoteRouteAvailabilityChanged(video
, true);
53 // Video should not have a cast button since the video is too narrow
54 button
= castButton(video
);
55 assert_equals(button
.style
.display
, "none", "button should not be visible with no cast devices");
57 // It should, however, have an overlay cast button instead
58 button
= overlayCastButton(video
);
59 rect
= button
.getBoundingClientRect();
60 videoRect
= video
.getBoundingClientRect();
61 assert_greater_than_equal(rect
.top
, videoRect
.top
, "button should be at top left of video");
62 assert_greater_than_equal(rect
.left
, videoRect
.left
, "button should be at top left of video");
63 assert_less_than_equal(rect
.bottom
, videoRect
.top
+ videoRect
.height
/ 2, "button should be at top left of video");
64 assert_less_than_equal(rect
.right
, videoRect
.left
+ videoRect
.width
/ 2, "button should be at top left of video");