[Modern Media Controls] Media Controller: skip back support
[WebKit-https.git] / LayoutTests / http / tests / media / modern-media-controls / skip-back-support / skip-back-support-button-click.html
1 <script src="../../../../../resources/js-test-pre.js"></script>
2 <script src="/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
3 <script src="/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
4 <script src="/modern-media-controls/controls/layout-item.js" type="text/javascript"></script>
5 <script src="/modern-media-controls/controls/button.js" type="text/javascript"></script>
6 <script src="/modern-media-controls/controls/buttons-container.js" type="text/javascript"></script>
7 <script src="/modern-media-controls/controls/icon-service.js" type="text/javascript"></script>
8 <script src="/modern-media-controls/controls/start-button.js" type="text/javascript"></script>
9 <script src="/modern-media-controls/controls/icon-button.js" type="text/javascript"></script>
10 <script src="/modern-media-controls/controls/play-pause-button.js" type="text/javascript"></script>
11 <script src="/modern-media-controls/controls/skip-back-button.js" type="text/javascript"></script>
12 <script src="/modern-media-controls/controls/airplay-button.js" type="text/javascript"></script>
13 <script src="/modern-media-controls/controls/pip-button.js" type="text/javascript"></script>
14 <script src="/modern-media-controls/controls/fullscreen-button.js" type="text/javascript"></script>
15 <script src="/modern-media-controls/controls/mute-button.js" type="text/javascript"></script>
16 <script src="/modern-media-controls/controls/tracks-button.js" type="text/javascript"></script>
17 <script src="/modern-media-controls/controls/slider.js" type="text/javascript"></script>
18 <script src="/modern-media-controls/controls/volume-slider.js" type="text/javascript"></script>
19 <script src="/modern-media-controls/controls/scrubber.js" type="text/javascript"></script>
20 <script src="/modern-media-controls/controls/time-label.js" type="text/javascript"></script>
21 <script src="/modern-media-controls/controls/time-control.js" type="text/javascript"></script>
22 <script src="/modern-media-controls/controls/placard.js" type="text/javascript"></script>
23 <script src="/modern-media-controls/controls/airplay-placard.js" type="text/javascript"></script>
24 <script src="/modern-media-controls/controls/pip-placard.js" type="text/javascript"></script>
25 <script src="/modern-media-controls/controls/media-controls.js" type="text/javascript"></script>
26 <script src="/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
27 <script src="/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
28 <script src="/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
29 <script src="/modern-media-controls/media/mute-support.js" type="text/javascript"></script>
30 <script src="/modern-media-controls/media/skip-back-support.js" type="text/javascript"></script>
31 <script src="/modern-media-controls/media/start-support.js" type="text/javascript"></script>
32 <script src="/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
33 <script src="/modern-media-controls/main.js" type="text/javascript"></script>
34 <body>
35 <video src="../../resources/hls/generate-vod.php?duration=8000" style="width: 320px; height: 240px;"></video>
36 <div id="shadow"></div>
37 <script type="text/javascript">
38
39 window.jsTestIsAsync = true;
40
41 description("Testing the <code>SkipBackSupport</code> behavior by clicking on the mute button.");
42
43 iconService.directoryPath = "/modern-media-controls/images";
44
45 const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
46 const media = document.querySelector("video");
47 const mediaController = createControls(shadowRoot, media, null);
48
49 media.addEventListener("canplaythrough", event => {
50     media.currentTime = 50;
51     clickSkipBackButton();
52 });
53
54 let numberOfEvents = 0;
55 media.addEventListener("seeked", function() {
56     debug("");
57     debug("seeked event was dispatched");
58
59     numberOfEvents++;
60
61     if (numberOfEvents == 1) {
62         shouldBe("media.currentTime", "20");
63         clickSkipBackButton();
64     } else if (numberOfEvents == 2) {
65         shouldBeCloseTo("media.currentTime", 0, 0.1);
66         debug("");
67         shadowRoot.host.remove();
68         media.remove();
69         finishJSTest();
70     }
71 });
72
73 function clickSkipBackButton()
74 {
75     debug("");
76     debug("Dispatching click event to the skip back button");
77     mediaController.controls.skipBackButton.element.click();
78 }
79
80 </script>
81 <script src="../../../../../resources/js-test-post.js"></script>
82 </body>