OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
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> | |
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(tr
ue); | |
11 | |
12 function click() | |
13 { | |
14 if (window.eventSender) { | |
15 var playCoords; | |
16 try { | |
17 playCoords = mediaControlsButtonCoordinates(video, "play
-button"); | |
18 } catch (exception) { | |
19 failTest(exception.description); | |
20 return; | |
21 } | |
22 var x = playCoords[0]; | |
23 var y = playCoords[1]; | |
24 | |
25 userGestureInitiated = 1; | |
26 eventSender.mouseMoveTo(x, y); | |
27 eventSender.mouseDown(); | |
28 eventSender.mouseUp(); | |
29 } | |
30 } | |
31 | |
32 function playing() | |
33 { | |
34 if (userGestureInitiated == 0) { | |
35 failTest("Should not play without user gesture."); | |
36 } else { | |
37 run("video.pause()"); | |
38 } | |
39 } | |
40 | |
41 function pause() | |
42 { | |
43 testExpected("video.paused", true); | |
44 endTest(); | |
45 } | |
46 | |
47 function canplaythrough() | |
48 { | |
49 consoleWrite(""); | |
50 consoleWrite("* No user gesture initiated"); | |
51 run("video.play()"); | |
52 testExpected("video.paused", true); | |
53 consoleWrite(""); | |
54 | |
55 consoleWrite("* User gesture initiated"); | |
56 click(); | |
57 } | |
58 | |
59 function start() | |
60 { | |
61 findMediaElement(); | |
62 waitForEvent('canplaythrough', canplaythrough); | |
63 waitForEvent('playing', playing); | |
64 waitForEvent('pause', pause); | |
65 video.src = findMediaFile("video", "content/test"); | |
66 } | |
67 </script> | |
68 </head> | |
69 | |
70 <body onload="start()"> | |
71 <p>Test that video play() does not work unless a user clicked on the play bu
tton.</p> | |
72 <video controls></video> | |
73 </body> | |
74 </html> | |
OLD | NEW |