| OLD | NEW |
| 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> |
| OLD | NEW |