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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-controls-hidden-audio.html

Issue 2477203002: Media Controls: delegate 'volumechange' and 'focusin' handling to an EventListener. (Closed)
Patch Set: add comment Created 4 years, 1 month 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>Test that hiding volume / mute button works as expected.</title> 2 <title>Test that hiding volume / mute button works as expected.</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-controls.js"></script> 5 <script src="media-controls.js"></script>
6 <script src="media-file.js"></script> 6 <script src="media-file.js"></script>
7 <video controls></video> 7 <video controls></video>
8 <script> 8 <script>
9 async_test(function(t) { 9 async_test(function(t) {
10 var video = document.querySelector("video"); 10 var video = document.querySelector("video");
11 11
12 video.oncanplaythrough = t.step_func_done(function() { 12 video.oncanplaythrough = t.step_func(function() {
13 // Request non-hidden audio controls. 13 // Request non-hidden audio controls.
14 internals.settings.setPreferHiddenVolumeControls(false); 14 internals.settings.setPreferHiddenVolumeControls(false);
15 video.muted = false; 15 video.muted = false;
16 muteButton = mediaControlsButton(video, "mute-button"); 16 muteButton = mediaControlsButton(video, "mute-button");
17 volumeSlider = mediaControlsButton(video, "volume-slider"); 17 volumeSlider = mediaControlsButton(video, "volume-slider");
18 18
19 // Make sure that both are visible. 19 // Make sure that both are visible.
20 assert_not_equals(getComputedStyle(muteButton).display, "none"); 20 assert_not_equals(getComputedStyle(muteButton).display, "none");
21 assert_not_equals(getComputedStyle(volumeSlider).display, "none"); 21 assert_not_equals(getComputedStyle(volumeSlider).display, "none");
22 22
23 // Switch to muted video. Both should still be visible. 23 video.onvolumechange = t.step_func(_ => {
24 video.muted = true; 24 assert_not_equals(getComputedStyle(muteButton).display, "none");
25 assert_not_equals(getComputedStyle(muteButton).display, "none"); 25 assert_not_equals(getComputedStyle(volumeSlider).display, "none");
26 assert_not_equals(getComputedStyle(volumeSlider).display, "none");
27 26
28 internals.settings.setPreferHiddenVolumeControls(true); 27 video.onvolumechange = t.step_func(_ => {
29
30 // Switch back to unmuted video.
31 video.muted = false;
32 assert_not_equals(getComputedStyle(muteButton).display, "none"); 28 assert_not_equals(getComputedStyle(muteButton).display, "none");
33 assert_equals(getComputedStyle(volumeSlider).display, "none"); 29 assert_equals(getComputedStyle(volumeSlider).display, "none");
34 30
31 video.onvolumechange = t.step_func_done(_ => {
32 assert_not_equals(getComputedStyle(muteButton).display, "none");
33 assert_equals(getComputedStyle(volumeSlider).display, "none");
34 });
35
35 // For muted video, the volume slider will hide but the mute button 36 // For muted video, the volume slider will hide but the mute button
36 // should stay, since we always have it present for media which have aud io. 37 // should stay, since we always have it present for media which have aud io.
37 video.muted = true; 38 video.muted = true;
38 assert_not_equals(getComputedStyle(muteButton).display, "none"); 39 });
39 assert_equals(getComputedStyle(volumeSlider).display, "none"); 40
41 // Switch back to unmuted video and hide volume slider.
42 internals.settings.setPreferHiddenVolumeControls(true);
43 video.muted = false;
40 }); 44 });
41 45
42 video.src = findMediaFile("video", "content/test"); 46 // Switch to muted video. Both should still be visible.
47 video.muted = true;
48 });
49
50 video.src = findMediaFile("video", "content/test");
43 }) 51 })
44 </script> 52 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698