Index: LayoutTests/media/video-play-require-user-gesture.html |
diff --git a/LayoutTests/media/video-play-require-user-gesture.html b/LayoutTests/media/video-play-require-user-gesture.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0e936071238ab2a2c6c1cd2d00fe44c120157d38 |
--- /dev/null |
+++ b/LayoutTests/media/video-play-require-user-gesture.html |
@@ -0,0 +1,74 @@ |
+<html> |
+ <head> |
+ <title>Test that video play does not work unless a user gesture is involved in playing a video</title> |
+ <script src=media-controls.js></script> |
+ <script src=media-file.js></script> |
+ <script src=video-test.js></script> |
+ <script> |
+ var userGestureInitiated = 0; |
+ if (window.internals) |
+ window.internals.settings.setMediaPlaybackRequiresUserGesture(true); |
+ |
+ function click() |
+ { |
+ if (window.eventSender) { |
+ var playCoords; |
+ try { |
+ playCoords = mediaControlsButtonCoordinates(video, "play-button"); |
+ } catch (exception) { |
+ failTest(exception.description); |
+ return; |
+ } |
+ var x = playCoords[0]; |
+ var y = playCoords[1]; |
+ |
+ userGestureInitiated = 1; |
+ eventSender.mouseMoveTo(x, y); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+ } |
+ } |
+ |
+ function playing() |
+ { |
+ if (userGestureInitiated == 0) { |
+ failTest("Should not play without user gesture."); |
+ } else { |
+ run("video.pause()"); |
+ } |
+ } |
+ |
+ function pause() |
+ { |
+ testExpected("video.paused", true); |
+ endTest(); |
+ } |
+ |
+ function canplaythrough() |
+ { |
+ consoleWrite(""); |
+ consoleWrite("* No user gesture initiated"); |
+ run("video.play()"); |
+ testExpected("video.paused", true); |
+ consoleWrite(""); |
+ |
+ consoleWrite("* User gesture initiated"); |
+ click(); |
+ } |
+ |
+ function start() |
+ { |
+ findMediaElement(); |
+ waitForEvent('canplaythrough', canplaythrough); |
+ waitForEvent('playing', playing); |
+ waitForEvent('pause', pause); |
+ video.src = findMediaFile("video", "content/test"); |
+ } |
+ </script> |
+ </head> |
+ |
+ <body onload="start()"> |
+ <p>Test that video play() does not work unless a user clicked on the play button.</p> |
+ <video controls></video> |
+ </body> |
+</html> |