| 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 <script> |
| 8 (Please avoid writing new tests using video-test.js) --> | 8 async_test(function(t) { |
| 9 <script src="video-test.js"></script> | 9 internals.settings.setMediaControlsOverlayPlayButtonEnabled(true); |
| 10 <script> | |
| 11 function start() | |
| 12 { | |
| 13 window.internals.settings.setMediaControlsOverlayPlayButtonEnabl
ed(true); | |
| 14 | 10 |
| 15 // Add element dynamically, since otherwise the controls are cre
ated, but | 11 // Add video dynamically, since otherwise the controls are created, but |
| 16 // hidden, before the setting is set, causing the setting to be
ignored. | 12 // hidden, before the setting is set, causing the setting to be ignored. |
| 17 addVideoElement(); | 13 var video = document.createElement("video"); |
| 14 document.documentElement.appendChild(video); |
| 18 | 15 |
| 19 findMediaElement(); | 16 video.controls = true; |
| 17 var button = mediaControlsButton(video, "overlay-play-button") |
| 18 assert_equals(getComputedStyle(button).display, "flex"); |
| 20 | 19 |
| 21 video.controls = true; | 20 video.onloadeddata = t.step_func(function() { |
| 21 video.onloadeddata = null; |
| 22 | 22 |
| 23 button = mediaControlsButton(video, 'overlay-play-button') | 23 video.onplay = t.step_func(function() { |
| 24 testExpected('getComputedStyle(button).display', 'flex'); | 24 play(pause1); |
| 25 }); |
| 25 | 26 |
| 26 waitForEventOnce('loadeddata', loadeddata); | 27 video.play(); |
| 27 video.src = findMediaFile('video', 'content/test'); | 28 }); |
| 28 } | |
| 29 | 29 |
| 30 function addVideoElement() { | 30 function play(pauseFunction) { |
| 31 element = document.createElement('video'); | 31 video.onplay = null; |
| 32 document.body.appendChild(element); | 32 assert_equals(getComputedStyle(button).display, "none"); |
| 33 } | |
| 34 | 33 |
| 35 function loadeddata() | 34 video.onpause = t.step_func(pauseFunction); |
| 36 { | 35 video.pause(); |
| 37 waitForEventOnce('play', play1); | 36 } |
| 38 run('video.play()'); | |
| 39 } | |
| 40 | 37 |
| 41 function play1() | 38 function pause1() { |
| 42 { | 39 video.onpause = null; |
| 43 testExpected('getComputedStyle(button).display', 'none'); | 40 assert_equals(getComputedStyle(button).display, "flex"); |
| 44 | 41 |
| 45 waitForEventOnce('pause', pause1); | 42 video.controls = false; |
| 46 run('video.pause()'); | 43 assert_equals(getComputedStyle(button).display, "none"); |
| 47 } | |
| 48 | 44 |
| 49 function pause1() | 45 video.onplay = t.step_func_done(function() { |
| 50 { | 46 play(pause2); |
| 51 testExpected('getComputedStyle(button).display', 'flex'); | 47 }); |
| 52 | 48 |
| 53 video.controls = false; | 49 video.play(); |
| 54 testExpected('getComputedStyle(button).display', 'none'); | 50 } |
| 55 | 51 |
| 56 waitForEventOnce('play', play2); | 52 function pause2() { |
| 57 run('video.play()'); | 53 video.onpause = null; |
| 58 } | 54 assert_equals(getComputedStyle(button).display, "none"); |
| 59 | 55 |
| 60 function play2() | 56 video.controls = true; |
| 61 { | 57 assert_equals(getComputedStyle(button).display, "flex"); |
| 62 testExpected('getComputedStyle(button).display', 'none'); | 58 } |
| 63 | 59 |
| 64 waitForEventOnce('pause', pause2); | 60 video.src = findMediaFile("video", "content/test"); |
| 65 run('video.pause()'); | 61 }); |
| 66 } | 62 </script> |
| 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 |