Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-play-require-user-gesture.html
blob0e936071238ab2a2c6c1cd2d00fe44c120157d38
1 <html>
2 <head>
3 <title>Test that video play does not work unless a user gesture is involved in playing a video</title>
4 <script src=media-controls.js></script>
5 <script src=media-file.js></script>
6 <script src=video-test.js></script>
7 <script>
8 var userGestureInitiated = 0;
9 if (window.internals)
10 window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
12 function click()
14 if (window.eventSender) {
15 var playCoords;
16 try {
17 playCoords = mediaControlsButtonCoordinates(video, "play-button");
18 } catch (exception) {
19 failTest(exception.description);
20 return;
22 var x = playCoords[0];
23 var y = playCoords[1];
25 userGestureInitiated = 1;
26 eventSender.mouseMoveTo(x, y);
27 eventSender.mouseDown();
28 eventSender.mouseUp();
32 function playing()
34 if (userGestureInitiated == 0) {
35 failTest("Should not play without user gesture.");
36 } else {
37 run("video.pause()");
41 function pause()
43 testExpected("video.paused", true);
44 endTest();
47 function canplaythrough()
49 consoleWrite("");
50 consoleWrite("* No user gesture initiated");
51 run("video.play()");
52 testExpected("video.paused", true);
53 consoleWrite("");
55 consoleWrite("* User gesture initiated");
56 click();
59 function start()
61 findMediaElement();
62 waitForEvent('canplaythrough', canplaythrough);
63 waitForEvent('playing', playing);
64 waitForEvent('pause', pause);
65 video.src = findMediaFile("video", "content/test");
67 </script>
68 </head>
70 <body onload="start()">
71 <p>Test that video play() does not work unless a user clicked on the play button.</p>
72 <video controls></video>
73 </body>
74 </html>