| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <title>Test that video play, pause and enterfullscreen does not work unl
ess a user gesture is involved in playing a video</title> | 3 <title>Test that video play does not work unless a user gesture is invol
ved in playing a video</title> |
| 4 <script src=media-controls.js></script> | 4 <script src=media-controls.js></script> |
| 5 <script src=media-file.js></script> | 5 <script src=media-file.js></script> |
| 6 <script src=video-test.js></script> | 6 <script src=video-test.js></script> |
| 7 <script> | 7 <script> |
| 8 var userGestureInitiated = 0; | 8 var userGestureInitiated = 0; |
| 9 if (window.internals) | 9 if (window.internals) |
| 10 window.internals.settings.setMediaPlaybackRequiresUserGesture(tr
ue); | 10 window.internals.settings.setMediaPlaybackRequiresUserGesture(tr
ue); |
| 11 | 11 |
| 12 function click() | 12 function click() |
| 13 { | 13 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 34 if (userGestureInitiated == 0) { | 34 if (userGestureInitiated == 0) { |
| 35 failTest("Should not play without user gesture."); | 35 failTest("Should not play without user gesture."); |
| 36 } else { | 36 } else { |
| 37 run("video.pause()"); | 37 run("video.pause()"); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 function pause() | 41 function pause() |
| 42 { | 42 { |
| 43 testExpected("video.paused", true); | 43 testExpected("video.paused", true); |
| 44 // Now video.webkitEnterFullScreen() should no longer throw any
exception. | |
| 45 // However, the video element may not always enter fullscreen. F
or example, | |
| 46 // chromium uses fullscreen API which still requires user gestur
e | |
| 47 try { | |
| 48 run("video.webkitEnterFullScreen()"); | |
| 49 } catch(ex) { | |
| 50 failTest("video.webkitEnterFullScreen() still requires user
gesture."); | |
| 51 } | |
| 52 endTest(); | 44 endTest(); |
| 53 } | 45 } |
| 54 | 46 |
| 55 function canplaythrough() | 47 function canplaythrough() |
| 56 { | 48 { |
| 57 consoleWrite(""); | 49 consoleWrite(""); |
| 58 consoleWrite("* No user gesture initiated"); | 50 consoleWrite("* No user gesture initiated"); |
| 59 run("video.play()"); | 51 run("video.play()"); |
| 60 testDOMException("video.webkitEnterFullScreen()", "DOMException.
INVALID_STATE_ERR"); | |
| 61 testExpected("video.paused", true); | 52 testExpected("video.paused", true); |
| 62 consoleWrite(""); | 53 consoleWrite(""); |
| 63 | 54 |
| 64 consoleWrite("* User gesture initiated"); | 55 consoleWrite("* User gesture initiated"); |
| 65 click(); | 56 click(); |
| 66 } | 57 } |
| 67 | 58 |
| 68 function start() | 59 function start() |
| 69 { | 60 { |
| 70 findMediaElement(); | 61 findMediaElement(); |
| 71 waitForEvent('canplaythrough', canplaythrough); | 62 waitForEvent('canplaythrough', canplaythrough); |
| 72 waitForEvent('playing', playing); | 63 waitForEvent('playing', playing); |
| 73 waitForEvent('pause', pause); | 64 waitForEvent('pause', pause); |
| 74 video.src = findMediaFile("video", "content/test"); | 65 video.src = findMediaFile("video", "content/test"); |
| 75 } | 66 } |
| 76 </script> | 67 </script> |
| 77 </head> | 68 </head> |
| 78 | 69 |
| 79 <body onload="start()"> | 70 <body onload="start()"> |
| 80 <p>Test that video play(), pause() and webkitEnterFullScreen() should not wo
rk unless a user clicked on the play button.</p> | 71 <p>Test that video play() does not work unless a user clicked on the play bu
tton.</p> |
| 81 <video controls></video> | 72 <video controls></video> |
| 82 </body> | 73 </body> |
| 83 </html> | 74 </html> |
| OLD | NEW |