summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/widgets/test_videocontrols_audio.html
blob: 5c095df430d3fe60f2e90f6c9a0ec265da71c6dd (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
57
58
59
60
<!DOCTYPE HTML>
<html>
<head>
  <title>Video controls with Audio file test</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>

<div id="content">
  <video id="video" controls preload="metadata"></video>
</div>

<pre id="test">
<script class="testbody" type="application/javascript">

  const InspectorUtils = SpecialPowers.InspectorUtils;

  function findElementByAttribute(element, aName, aValue) {
    if (!("getAttribute" in element)) {
      return false;
    }
    if (element.getAttribute(aName) === aValue) {
      return element;
    }
    let children =
      InspectorUtils.getChildrenForNode(element, true);
    for (let child of children) {
      var result = findElementByAttribute(child, aName, aValue);
      if (result) {
        return result;
      }
    }
    return false;
  }

  function loadedmetadata(event) {
    SimpleTest.executeSoon(function() {
      var controlBar = findElementByAttribute(video, "class", "controlBar");
      is(controlBar.getAttribute("fullscreen-unavailable"), "true", "Fullscreen button is hidden");
      SimpleTest.finish();
    });
  }

  var video = document.getElementById("video");

  SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, startTest);
  function startTest() {
    // Kick off test once audio has loaded.
    video.addEventListener("loadedmetadata", loadedmetadata);
    video.src = "audio.ogg";
  }

  SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>