content/media/test/test_load_source.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_load_source.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=534571
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 534571</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +  <script type="text/javascript" src="manifest.js"></script>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534571">Mozilla Bug 534571</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +  
    1.20 +</div>
    1.21 +<pre id="test">
    1.22 +<script type="application/javascript">
    1.23 +
    1.24 +/** Test for Bug 534571 **/
    1.25 +
    1.26 +// Test that when we load a video from a source child and then change the
    1.27 +// source's src attribute and load again, that the subsequent loads work.
    1.28 +
    1.29 +var v = null;
    1.30 +var s = null;
    1.31 +
    1.32 +function finish(event) {
    1.33 +  ok(true, "Should have played both videos");
    1.34 +  SimpleTest.finish();
    1.35 +}
    1.36 +
    1.37 +var first = null;
    1.38 +var second = null;
    1.39 +
    1.40 +function ended(event) {
    1.41 +  s.type = second.type;
    1.42 +  s.src = second.name;
    1.43 +  v.removeEventListener("ended", ended, false);
    1.44 +  v.addEventListener("ended", finish, false);
    1.45 +  v.load();
    1.46 +}
    1.47 +
    1.48 +// Find 2 videos we can play.
    1.49 +v = document.createElement('video');
    1.50 +for (var i=0; i<gPlayTests.length; i++) {
    1.51 +  if (!v.canPlayType(gPlayTests[i].type))
    1.52 +    continue;
    1.53 +  if (!first) {
    1.54 +    first = gPlayTests[i];
    1.55 +  } else if (!second) {
    1.56 +    second = gPlayTests[i];
    1.57 +    break;
    1.58 +  }
    1.59 +}
    1.60 +
    1.61 +if (first && second) {
    1.62 +  s = document.createElement('source');
    1.63 +  s.type = first.type;
    1.64 +  s.src = first.name;
    1.65 +  v.appendChild(s);
    1.66 +  v.autoplay = true;
    1.67 +  v.addEventListener("ended", ended, false);
    1.68 +  document.body.appendChild(v);
    1.69 +  SimpleTest.waitForExplicitFinish();
    1.70 +} else {
    1.71 +  todo(false, "Need at least two media of supported types for this test!");
    1.72 +}
    1.73 +
    1.74 +
    1.75 +
    1.76 +</script>
    1.77 +</pre>
    1.78 +</body>
    1.79 +</html>

mercurial