content/media/test/test_streams_element_capture_playback.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_streams_element_capture_playback.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test that capturing a stream doesn't stop the underlying element from firing events</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.10 +  <script type="text/javascript" src="manifest.js"></script>
    1.11 +</head>
    1.12 +<body>
    1.13 +<audio id="a"></audio>
    1.14 +<pre id="test">
    1.15 +<script class="testbody" type="text/javascript">
    1.16 +SimpleTest.waitForExplicitFinish();
    1.17 +
    1.18 +var a = document.getElementById('a');
    1.19 +var validTimeUpdate = false;
    1.20 +
    1.21 +function startTest() {
    1.22 +  a.src = "big.wav";
    1.23 +  var context = new AudioContext();
    1.24 +  var node = context.createMediaElementSource(a);
    1.25 +  node.connect(context.destination);
    1.26 +  a.addEventListener("timeupdate", function() {
    1.27 +    if (a.currentTime > 0.0 && a.currentTime < 5.0 && !validTimeUpdate) {
    1.28 +      validTimeUpdate = true;
    1.29 +      ok(true, "Received reasonable currentTime in a timeupdate");
    1.30 +      SimpleTest.finish();
    1.31 +    }
    1.32 +  });
    1.33 +  a.addEventListener("ended", function() {
    1.34 +    if (!validTimeUpdate) {
    1.35 +      ok(false, "Received reasonable currentTime in a timeupdate");
    1.36 +      SimpleTest.finish();
    1.37 +    }
    1.38 +  });
    1.39 +  a.play();
    1.40 +}
    1.41 +
    1.42 +if (a.canPlayType("audio/wave")) {
    1.43 +  startTest();
    1.44 +} else {
    1.45 +  todo(false, "No playable audio");
    1.46 +}
    1.47 +</script>
    1.48 +</pre>
    1.49 +</body>
    1.50 +</html>

mercurial