OLD | NEW |
1 <video controls></video> | 1 <video controls></video> |
2 <p>Test that hiding volume / mute buttons works as expected.</p> | 2 <p>Test that hiding volume / mute buttons works as expected.</p> |
3 <script src=media-file.js></script> | 3 <script src=media-file.js></script> |
4 <script src=video-test.js></script> | 4 <script src=video-test.js></script> |
5 <script src=media-controls.js></script> | 5 <script src=media-controls.js></script> |
6 <script> | 6 <script> |
7 video.src = findMediaFile("video", "content/test"); | 7 video.src = findMediaFile("video", "content/test"); |
8 run("video.load()"); | 8 run("video.load()"); |
9 waitForEvent("canplaythrough", function () { | 9 waitForEvent("canplaythrough", function () { |
10 // Enable hidden audio preferences to take effect. | 10 // Enable hidden audio preferences to take effect. |
11 run("window.internals.setAllowHiddenVolumeControls(video, true)"); | 11 run("window.internals.setAllowHiddenVolumeControls(video, true)"); |
12 // Request non-hidden audio. | 12 // Request non-hidden audio controls. |
13 run("window.internals.settings.setPreferHiddenVolumeControls(false)"); | 13 run("window.internals.settings.setPreferHiddenVolumeControls(false)"); |
14 run("video.muted = false"); | 14 run("video.muted = false"); |
15 muteButton = mediaControlsButton(video, "mute-button"); | 15 muteButton = mediaControlsButton(video, "mute-button"); |
16 volumeSlider = mediaControlsButton(video, "volume-slider"); | 16 volumeSlider = mediaControlsButton(video, "volume-slider"); |
17 | 17 |
18 // Make sure that both are visible. | 18 // Make sure that both are visible. |
19 testExpected("getComputedStyle(muteButton).display", "none", '!='); | 19 testExpected("getComputedStyle(muteButton).display", "none", '!='); |
20 testExpected("getComputedStyle(volumeSlider).display", "none", '!='); | 20 testExpected("getComputedStyle(volumeSlider).display", "none", '!='); |
21 | 21 |
22 // Switch to muted video. Both should still be visible. We then | 22 // Switch to muted video. Both should still be visible. |
23 // remind it that we'd like to allow hidden audio preferences, since | |
24 // that also resets some state. | |
25 run("video.muted = true"); | 23 run("video.muted = true"); |
26 run("window.internals.setAllowHiddenVolumeControls(video, true)"); | |
27 testExpected("getComputedStyle(muteButton).display", "none", '!='); | 24 testExpected("getComputedStyle(muteButton).display", "none", '!='); |
28 testExpected("getComputedStyle(volumeSlider).display", "none", '!='); | 25 testExpected("getComputedStyle(volumeSlider).display", "none", '!='); |
29 | 26 |
30 run("window.internals.settings.setPreferHiddenVolumeControls(true)"); | 27 run("window.internals.settings.setPreferHiddenVolumeControls(true)"); |
31 | 28 |
32 // Switch back to unmuted video. | 29 // Switch back to unmuted video. |
33 run("video.muted = false"); | 30 run("video.muted = false"); |
34 run("window.internals.setAllowHiddenVolumeControls(video, true)"); | |
35 | 31 |
36 testExpected("getComputedStyle(muteButton).display", "none", '=='); | 32 testExpected("getComputedStyle(muteButton).display", "none", '!='); |
37 testExpected("getComputedStyle(volumeSlider).display", "none", '=='); | 33 testExpected("getComputedStyle(volumeSlider).display", "none", '=='); |
38 | 34 |
39 // For muted video, the volume slider will hide but the mute | 35 // For muted video, the volume slider will hide but the mute |
40 // button should come back, to let the user unmute. | 36 // button should stay, since we always have it present for media |
| 37 // which have audio. |
41 run("video.muted = true"); | 38 run("video.muted = true"); |
42 run("window.internals.setAllowHiddenVolumeControls(video, true)"); | |
43 testExpected("getComputedStyle(muteButton).display", "none", '!='); | 39 testExpected("getComputedStyle(muteButton).display", "none", '!='); |
44 testExpected("getComputedStyle(volumeSlider).display", "none", '=='); | 40 testExpected("getComputedStyle(volumeSlider).display", "none", '=='); |
45 | 41 |
46 endTest(); | 42 endTest(); |
47 }); | 43 }); |
48 </script> | 44 </script> |
OLD | NEW |