OLD | NEW |
1 <!doctype html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Test that the overlay play button respects the controls attribute.</title
> |
3 <head> | 3 <script src="../resources/testharness.js"></script> |
4 <title>Test that the overlay play button respects the controls attribute
</title> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src="media-controls.js"></script> | 5 <script src="media-file.js"></script> |
6 <script src="media-file.js"></script> | 6 <script src="media-controls.js"></script> |
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 7 <body> |
8 (Please avoid writing new tests using video-test.js) --> | 8 <script> |
9 <script src="video-test.js"></script> | 9 async_test(function(t) { |
10 <script> | 10 internals.settings.setMediaControlsOverlayPlayButtonEnabled(true); |
11 function start() | |
12 { | |
13 window.internals.settings.setMediaControlsOverlayPlayButtonEnabl
ed(true); | |
14 | 11 |
15 // Add element dynamically, since otherwise the controls are cre
ated, but | 12 // Add video dynamically, since otherwise the controls are created, but |
16 // hidden, before the setting is set, causing the setting to be
ignored. | 13 // hidden, before the setting is set, causing the setting to be ignored. |
17 addVideoElement(); | 14 var video = document.createElement("video"); |
| 15 document.body.appendChild(video); |
18 | 16 |
19 findMediaElement(); | 17 video.controls = true; |
| 18 var button = mediaControlsButton(video, "overlay-play-button") |
| 19 assert_equals(getComputedStyle(button).display, "flex"); |
20 | 20 |
21 video.controls = true; | 21 var watcher = new EventWatcher(t, video, ["loadeddata", "play", "pause"]); |
| 22 watcher.wait_for("loadeddata").then(t.step_func(function() { |
| 23 video.play(); |
| 24 return watcher.wait_for("play"); |
| 25 })).then(t.step_func(function() { |
| 26 assert_equals(getComputedStyle(button).display, "none"); |
| 27 video.pause(); |
| 28 return watcher.wait_for("pause"); |
| 29 })).then(t.step_func(function() { |
| 30 assert_equals(getComputedStyle(button).display, "flex"); |
| 31 video.controls = false; |
| 32 assert_equals(getComputedStyle(button).display, "none"); |
| 33 video.play(); |
| 34 return watcher.wait_for("play"); |
| 35 })).then(t.step_func(function() { |
| 36 assert_equals(getComputedStyle(button).display, "none"); |
| 37 video.pause(); |
| 38 return watcher.wait_for("pause"); |
| 39 })).then(t.step_func_done(function() { |
| 40 assert_equals(getComputedStyle(button).display, "none"); |
| 41 video.controls = true; |
| 42 assert_equals(getComputedStyle(button).display, "flex"); |
| 43 })); |
22 | 44 |
23 button = mediaControlsButton(video, 'overlay-play-button') | 45 video.src = findMediaFile("video", "content/test"); |
24 testExpected('getComputedStyle(button).display', 'flex'); | 46 }); |
25 | 47 </script> |
26 waitForEventOnce('loadeddata', loadeddata); | |
27 video.src = findMediaFile('video', 'content/test'); | |
28 } | |
29 | |
30 function addVideoElement() { | |
31 element = document.createElement('video'); | |
32 document.body.appendChild(element); | |
33 } | |
34 | |
35 function loadeddata() | |
36 { | |
37 waitForEventOnce('play', play1); | |
38 run('video.play()'); | |
39 } | |
40 | |
41 function play1() | |
42 { | |
43 testExpected('getComputedStyle(button).display', 'none'); | |
44 | |
45 waitForEventOnce('pause', pause1); | |
46 run('video.pause()'); | |
47 } | |
48 | |
49 function pause1() | |
50 { | |
51 testExpected('getComputedStyle(button).display', 'flex'); | |
52 | |
53 video.controls = false; | |
54 testExpected('getComputedStyle(button).display', 'none'); | |
55 | |
56 waitForEventOnce('play', play2); | |
57 run('video.play()'); | |
58 } | |
59 | |
60 function play2() | |
61 { | |
62 testExpected('getComputedStyle(button).display', 'none'); | |
63 | |
64 waitForEventOnce('pause', pause2); | |
65 run('video.pause()'); | |
66 } | |
67 | |
68 function pause2() | |
69 { | |
70 testExpected('getComputedStyle(button).display', 'none'); | |
71 | |
72 video.controls = true; | |
73 testExpected('getComputedStyle(button).display', 'flex'); | |
74 | |
75 endTest(); | |
76 } | |
77 </script> | |
78 </head> | |
79 <body onload="start()"> | |
80 <p>Test that the overlay play button respects the controls attribute</p> | |
81 </body> | |
82 </html> | |
OLD | NEW |