summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/widgets/test_videocontrols_clickToPlay_ariaLabel.html
blob: a78735839482ce11ad22163c02b472da6f8ec85e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE HTML>
<html>
<head>
    <title>Video controls test - clickToPlayAriaLabel</title>
    <script src="/tests/SimpleTest/SimpleTest.js"></script>
    <script src="/tests/SimpleTest/EventUtils.js"></script>
    <script type="text/javascript" src="head.js"></script>
    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div id="content">
        <video controls preload="auto" width="480" height="320"></video>
</div>

<pre id="test">
<script clas="testbody" type="application/javascript">
        SimpleTest.waitForExplicitFinish();

        const videoElems = [...document.getElementsByTagName("video")];
        const testCases = [];

        function testUI(video) {
          const clickToPlay = getElementWithinVideo(video, "clickToPlay");
          ok(!!clickToPlay.getAttribute("aria-label"), "clickToPlay has aria-label attribute");
        };

        videoElems.forEach(video => {
          testCases.push(() => new Promise(resolve => {
            SimpleTest.executeSoon(async () => {
              const { widget } = SpecialPowers.wrap(window)
                .windowGlobalChild.getActor("UAWidgets")
                .widgets.get(video);
              await widget.impl.Utils.l10n.translateRoots();
              testUI(video);
              resolve();
            });
          }));
        });

        function executeTasks(tasks) {
          return tasks.reduce((promise, task) => promise.then(task), Promise.resolve());
        }

        function start() {
          executeTasks(testCases).then(SimpleTest.finish);
        }

        function loadevent() {
          SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, start);
        }

        window.addEventListener("load", loadevent);
</script>
</pre>
</body>
</html>