| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Test video control element visibility when play by touch.</title> |
| 3 <style> | 3 <script src="../resources/testharness.js"></script> |
| 4 #no-video-media { | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 width: 320px; | 5 <script src="media-file.js"></script> |
| 6 height: 240px; | 6 <script src="media-controls.js"></script> |
| 7 } | 7 <video controls loop></video> |
| 8 </style> | |
| 9 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | |
| 10 (Please avoid writing new tests using video-test.js) --> | |
| 11 <script src=video-test.js></script> | |
| 12 <script src=media-file.js></script> | |
| 13 <script src=media-controls.js></script> | |
| 14 <script> | 8 <script> |
| 9 async_test(function(t) { |
| 10 var video = document.querySelector("video"); |
| 15 | 11 |
| 16 var controls; | 12 video.oncanplaythrough = t.step_func(function() { |
| 13 var controls = mediaControlsButton(video, "panel"); |
| 17 | 14 |
| 18 function dispatchActivateEvent(target) { | 15 assert_true(video.paused); |
| 19 // Create a DOMActivate event and dispatch it | |
| 20 var event = document.createEvent('UIEvents'); | |
| 21 event.initUIEvent('DOMActivate', true, true, window, 1) | |
| 22 target.dispatchEvent(event); | |
| 23 } | |
| 24 | 16 |
| 17 // Click the play button. |
| 18 var playCoords = mediaControlsButtonCoordinates(video, "play-button"); |
| 19 var clickX = playCoords[0]; |
| 20 var clickY = playCoords[1]; |
| 21 eventSender.gestureTap(clickX, clickY); |
| 22 eventSender.gestureTapDown(clickX, clickY); |
| 25 | 23 |
| 26 function runTest() | 24 // Create a DOMActivate event and dispatch it. |
| 27 { | 25 var event = document.createEvent("UIEvents"); |
| 28 video = document.getElementById("no-video-media"); | 26 event.initUIEvent("DOMActivate", true, true, window, 1); |
| 29 controls = mediaControlsButton(video, "panel"); | 27 controls.dispatchEvent(event); |
| 30 | 28 |
| 31 testExpected("video.paused", true); | 29 assert_false(video.paused); |
| 32 if (!window.testRunner) | |
| 33 return; | |
| 34 | 30 |
| 35 // Click the play button. | 31 runAfterHideMediaControlsTimerFired(t.step_func_done(function() { |
| 36 var playCoords = mediaControlsButtonCoordinates(video, "play-button"); | 32 assert_equals(getComputedStyle(controls).opacity, "0"); |
| 37 var clickX = playCoords[0]; | 33 }), video); |
| 38 var clickY = playCoords[1]; | 34 }); |
| 39 eventSender.gestureTap(clickX, clickY); | |
| 40 eventSender.gestureTapDown(clickX, clickY); | |
| 41 dispatchActivateEvent(controls); | |
| 42 | 35 |
| 43 testExpected("video.paused", false); | 36 video.src = findMediaFile("video", "content/test"); |
| 44 | 37 }); |
| 45 runAfterHideMediaControlsTimerFired(function() | 38 </script> |
| 46 { | |
| 47 testExpected("getComputedStyle(controls).opacity", 0); | |
| 48 | |
| 49 consoleWrite(""); | |
| 50 endTest(); | |
| 51 }, video); | |
| 52 } | |
| 53 </script> | |
| 54 <body> | |
| 55 <p>Test video control element visibility when play by touch.</p> | |
| 56 <p>This test only runs in DRT!</p> | |
| 57 | |
| 58 <video id="no-video-media" controls loop oncanplaythrough="runTest()"></vide
o> | |
| 59 <script> | |
| 60 setSrcById("no-video-media", findMediaFile("video", "content/test")); | |
| 61 </script> | |
| 62 </body> | |
| 63 </html> | |
| OLD | NEW |