DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
<!DOCTYPE HTML>
<html>
<head>
<head>
  <title>Test playback of media files that should play OK</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>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">

var manager = new MediaTestManager;
var manager = new MediaTestManager;

function startTest(test, token) {
  var video = document.createElement('video');
  video.preload = "metadata";
  video.token = token;
  video.token = token;
  video.prevTime = 0;
  video.seenEnded = false;
  video.seenSuspend = false;

  var handler = {
    "ontimeout": function() {
      Log(token, "timed out: ended=" + video.seenEnded + ", suspend=" + video.seenSuspend);
      Log(token, "timed out: ended=" + video.seenEnded + ", suspend=" + video.seenSuspend);
    }
  };
  manager.started(token, handler);

  video.src = test.name;
  video.name = test.name;
  video.name = test.name;

  var check = function(t, v) { return function() {
    is(t.name, v.name, t.name + ": Name should match #1");
    checkMetadata(t.name, v, t);
  }}(test, video);

  var noLoad = function(t, v) { return function() {
  var noLoad = function(t, v) { return function() {
    ok(false, t.name + " should not fire 'load' event");
  }}(test, video);

  var noError = function(t, v) { return function() {
    ok(false, t.name + " should not fire 'error' event " + v.error.message);
    ok(false, t.name + " should not fire 'error' event " + v.error.message);
  }}(test, video);

  var finish = function() {
    video.finished = true;
    video.removeEventListener("timeupdate", timeUpdate);
    video.removeEventListener("timeupdate", timeUpdate);
    removeNodeAndSource(video);
    manager.finished(video.token);
  }

  // We should get "ended" and "suspend" events to finish the test.
  // We should get "ended" and "suspend" events to finish the test.
  var mayFinish = function() {
    if (video.seenEnded && video.seenSuspend) {
      finish();
    }
    }
  }

  var checkEnded = function(t, v) { return function() {
    is(t.name, v.name, t.name + ": Name should match #2");
    checkMetadata(t.name, v, test);
    checkMetadata(t.name, v, test);
    is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState");
    ok(v.ended, t.name + " checking playback has ended");
    ok(!v.finished, t.name + " shouldn't be finished");
    ok(!v.seenEnded, t.name + " shouldn't be ended");


    v.seenEnded = true;
    mayFinish();
  }}(test, video);


  var checkSuspended = function(t, v) { return function() {
    if (v.seenSuspend) {
      return;
    }
    is(t.name, v.name, t.name + ": Name should match #3");
    is(t.name, v.name, t.name + ": Name should match #3");

    v.seenSuspend = true;
    mayFinish();
  }}(test, video);


  var timeUpdate = function(t, v) { return function() {
    if (v.prevTime > v.currentTime) {
      ok(false, t.name + " time should run forwards: p=" +
                v.prevTime + " c=" + v.currentTime);
    }
    }
    v.prevTime = v.currentTime;
  }}(test, video);

  video.addEventListener("load", noLoad);
  video.addEventListener("error", noError);
  video.addEventListener("error", noError);
  video.addEventListener("loadedmetadata", check);
  video.addEventListener("timeupdate", timeUpdate);

  // We should get "ended" and "suspend" events for every resource
  video.addEventListener("ended", checkEnded);
  video.addEventListener("ended", checkEnded);
  video.addEventListener("suspend", checkSuspended);

  document.body.appendChild(video);
  video.play();
  video.play();
}

manager.runTests(gPlayTests, startTest);

</script>
</script>
</pre>
</body>
</html>