Turn tests at media/modern-media-controls/playback-support back on
[WebKit-https.git] / LayoutTests / media / modern-media-controls / playback-support / playback-support-button-click.html
1 <script src="../../../resources/js-test-pre.js"></script>
2 <script src="../resources/media-controls-loader.js" type="text/javascript"></script>
3 <script src="../resources/media-controls-utils.js" type="text/javascript"></script>
4 <body>
5 <style type="text/css" media="screen">
6
7     video, #host {
8         position: absolute;
9         top: 0;
10         left: 0;
11         width: 320px;
12         height: 240px;
13     }
14     
15 </style>
16 <video src="../../content/test.mp4" controls autoplay></video>
17 <div id="host"></div>
18 <script type="text/javascript">
19
20 window.jsTestIsAsync = true;
21
22 description("Testing the <code>PlaybackSupport</code> behavior by clicking on the play/pause button.");
23
24 const host = document.querySelector("div#host");
25 const media = document.querySelector("video");
26 const mediaController = createControls(host, media, null);
27
28 let numberOfPlayEvents = 0;
29 media.addEventListener("play", function() {
30     numberOfPlayEvents++;
31
32     debug("Media is playing");
33     shouldBeTrue("mediaController.controls.playPauseButton.playing");
34
35     if (numberOfPlayEvents === 1)
36         clickPlayPauseButton();
37     else {
38         debug("");
39         host.remove();
40         media.remove();
41         finishJSTest();
42     }
43 });
44
45 media.addEventListener("pause", function() {
46     debug("Media is paused");
47     shouldBeFalse("mediaController.controls.playPauseButton.playing");
48
49     clickPlayPauseButton();
50 });
51
52 function clickPlayPauseButton()
53 {
54     debug("");
55     debug("Pressing on the play/pause button");
56     window.requestAnimationFrame(() => pressOnElement(mediaController.controls.playPauseButton.element));
57 }
58 </script>
59 <script src="../../../resources/js-test-post.js"></script>
60 </body>