summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_streams_element_capture_playback.html
blob: ce083069ef09b6fa5e5a8f738e6dc144cf71a0f3 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test that capturing a stream doesn't stop the underlying element from firing events</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<audio id="a"></audio>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();

var a = document.getElementById('a');
var validTimeUpdate = false;

function startTest() {
  a.src = "big.wav";
  var context = new AudioContext();
  var node = context.createMediaElementSource(a);
  node.connect(context.destination);
  a.addEventListener("timeupdate", function() {
    if (a.currentTime > 0.0 && a.currentTime < 5.0 && !validTimeUpdate) {
      validTimeUpdate = true;
      ok(true, "Received reasonable currentTime in a timeupdate");
      SimpleTest.finish();
    }
  });
  a.addEventListener("ended", function() {
    if (!validTimeUpdate) {
      ok(false, "Received reasonable currentTime in a timeupdate");
      SimpleTest.finish();
    }
  });
  a.play();
}

if (a.canPlayType("audio/wave")) {
  startTest();
} else {
  todo(false, "No playable audio");
}
</script>
</pre>
</body>
</html>