Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html |
| diff --git a/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html b/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html |
| index 61054e29ec5053069a7ad53004f729152b791116..bb4ff8961c72f923cbe709d990eda1c33328bcaa 100644 |
| --- a/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html |
| +++ b/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html |
| @@ -10,35 +10,57 @@ async_test(function(t) { |
| var video = document.querySelector("video"); |
| video.src = findMediaFile("video", "content/test"); |
| - video.onloadedmetadata = t.step_func_done(function() { |
| + video.onloadedmetadata = t.step_func(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"); |
| + assert_false(isVisible(castButton(video)), "button should not be visible"); |
| // It should not have an overlay cast button too. Instead, the button |
| // should appear in the overflow menu. Tested somewhere else. |
| - button = overlayCastButton(video); |
| - assert_equals(button.style.display, "none", "button should not be visible"); |
| - }); |
| + assert_false(isVisible(overlayCastButton(video)), "button should not be visible"); |
| - 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; |
| - } |
| + // Make video wider |
|
mlamouri (slow - plz ping)
2017/02/14 09:58:05
Here and below, most of these comments are simply
steimel
2017/02/14 17:31:01
Done.
|
| + video.width = 500; |
| + |
| + // Delay to give a chance for style to update |
| + setTimeout(t.step_func(function() { |
| + |
| + // Video should now have a cast button since the video is wide enough |
| + assert_true(isVisible(castButton(video)), "button should be visible"); |
| + |
| + // Make video thinner |
| + video.width = 100; |
| + |
| + // Delay to give a chance for style to update |
| + setTimeout(t.step_func(function() { |
|
mlamouri (slow - plz ping)
2017/02/14 09:58:05
You probably want `testRunner.layoutAndPaintAsyncT
steimel
2017/02/14 17:31:01
Done.
|
| + |
| + // Video should no longer have a cast button since the video is too thin |
| + assert_false(isVisible(castButton(video)), "button should not be visible"); |
| + |
| + // Pretend we no longer have a cast device |
| + internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false); |
| + |
| + // Make video wider |
| + video.width = 500; |
| + |
| + // Delay to give a chance for style to update |
| + setTimeout(t.step_func_done(function() { |
| + |
| + // Video should still have no cast button since we have no cast device |
| + assert_false(isVisible(castButton(video)), "button should not be visible"); |
| + |
| + }), 0); |
| + }), 0); |
| + }), 0); |
| + }); |
| - function overlayCastButton(element) { |
| - var controlID = "-internal-media-controls-overlay-cast-button"; |
| - return mediaControlsElement(internals.shadowRoot(element).firstChild, controlID); |
| - return button |
| - if (!button) |
| - throw "Failed to find cast button"; |
| - return button; |
| + function isVisible(button) { |
| + var computedStyle = getComputedStyle(button); |
| + return computedStyle.display !== "none" && |
| + computedStyle.display !== "hidden" && |
| + computedStyle.visibility === "visible"; |
| } |
| }); |
| </script> |