Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/media/video-controls-overflow-menu-updates-appropriately.html

Issue 2539023002: Media Controls: Use events to update controls for closed captions. (Closed)
Patch Set: zqzhang review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Overflow menu updates properly.</title> 2 <title>Overflow menu updates properly.</title>
3 <script src="../resources/testharness.js"></script> 3 <script src='../resources/testharness.js'></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src='../resources/testharnessreport.js'></script>
5 <script src="../../media-resources/media-controls.js"></script> 5 <script src='../../media-resources/media-controls.js'></script>
6 <script src="../../media-resources/media-file.js"></script> 6 <script src='../../media-resources/media-file.js'></script>
7 <script src="../../media-resources/overflow-menu.js"></script> 7 <script src='../../media-resources/overflow-menu.js'></script>
8 8
9 <!--Padding ensures the overflow menu is visible for the tests. --> 9 <!--Padding ensures the overflow menu is visible for the tests. -->
10 <body style="padding-top: 200px; padding-left: 100px"> 10 <body style='padding-top: 200px; padding-left: 100px'>
11 <video controls></video> 11 <video controls></video>
12 <script> 12 <script>
13 async_test(function(t) { 13 async_test(t => {
14 assert_true('internals' in window, 'window.internals must be available');
15
14 // Set up video 16 // Set up video
15 var video = document.querySelector("video"); 17 var video = document.querySelector('video');
16 video.src = findMediaFile("video", "resources/test"); 18 video.src = findMediaFile('video', 'resources/test');
17 video.setAttribute("width", "60"); 19 video.setAttribute('width', '60');
18 // Add captions 20 // Add captions
19 var trackElement = document.createElement("track"); 21 var trackElement = document.createElement('track');
20 video.appendChild(trackElement); 22 video.appendChild(trackElement);
21 // Pretend we have a cast device 23 // Pretend we have a cast device
22 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true); 24 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
23 25
24 video.onloadeddata = t.step_func_done(function() { 26 video.onloadeddata = t.step_func(_ => {
25 var overflowList = getOverflowList(video); 27 var overflowList = getOverflowList(video);
26 28
27 // Remove cast device and ensure the overflow menu updates as expected 29 // Remove cast device and ensure the overflow menu updates as expected
28 // Cast option in overflow should no longer be visible, but the other 30 // Cast option in overflow should no longer be visible, but the other
29 // options should all be. 31 // options should all be.
30 var buttonsWithoutCast = overflowButtonsCSS; 32 var buttonsWithoutCast = overflowButtonsCSS;
31 buttonsWithoutCast[OverflowMenuButtons.CAST] = undefined; 33 buttonsWithoutCast[OverflowMenuButtons.CAST] = undefined;
32 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false); 34 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false);
33 35
34 var children = overflowList.children; 36 var children = overflowList.children;
35 // Ensure that all of the buttons are visible in the right order 37 // Ensure that all of the buttons are visible in the right order
36 for (var i = 0; i < children.length; i++) { 38 for (var i = 0; i < children.length; i++) {
37 var child = children[i]; 39 var child = children[i];
38 if (buttonsWithoutCast[i]) { 40 if (buttonsWithoutCast[i])
39 assert_not_equals(getComputedStyle(child).display, "none"); 41 assert_not_equals(getComputedStyle(child).display, 'none');
40 } else { 42 else
41 assert_equals(getComputedStyle(child).display, "none"); 43 assert_equals(getComputedStyle(child).display, 'none');
42 }
43 } 44 }
44 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true); 45 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
45 assert_not_equals(getComputedStyle(children[OverflowMenuButtons.CAST]).displ ay, "none"); 46 assert_not_equals(getComputedStyle(children[OverflowMenuButtons.CAST]).displ ay, 'none');
46 47
47 // Removing closed captions hides button in overflow menu 48 // Removing closed captions hides button in overflow menu
48 assert_not_equals(getComputedStyle(children[OverflowMenuButtons.CLOSED_CAPTI ONS]).display, "none"); 49 assert_not_equals(getComputedStyle(children[OverflowMenuButtons.CLOSED_CAPTI ONS]).display, 'none');
49 video.removeChild(trackElement); 50 video.removeChild(trackElement);
50 assert_equals(getComputedStyle(children[OverflowMenuButtons.CLOSED_CAPTIONS] ).display, "none"); 51
52 // The controls are updated asynchronously.
53 setTimeout(t.step_func_done(_ => {
foolip 2016/12/02 11:29:17 TIL that setTimeout.length==1, but is the default
mlamouri (slow - plz ping) 2016/12/05 15:17:56 As far as I know, setTimeout default value is 0.
54 assert_equals(getComputedStyle(children[OverflowMenuButtons.CLOSED_CAPTION S]).display, 'none');
55 }));
51 }); 56 });
52 }); 57 });
53 </script> 58 </script>
54 </body> 59 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698