summaryrefslogtreecommitdiff
path: root/dom/media/test/test_bug1242338.html
blob: c404d7b1dbf31d9995a0580f7de54ae125dc1aa0 (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
61
62
63
64
65
66
<!DOCTYPE HTML>
<html>
<head>
  <title>Test Bug 1242338</title>
  <script type="text/javascript" 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>
<pre id="test">
<script class="testbody" type="text/javascript">

var manager = new MediaTestManager;

function startTest(test, token) {
  var video = document.createElement('video');
  video.preload = "metadata";
  video.token = token;

  var handler = {
    "ontimeout": function() {
      Log(token, "timed out");
    }
  };
  manager.started(token, handler);

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

  function finish() {
    video.finished = true;
    video.removeEventListener("loadedmetadata", onLoadedmetadata, false);
    video.removeEventListener("ended", onEnded, false);
    removeNodeAndSource(video);
    manager.finished(video.token);
  }

  function onLoadedmetadata() {
    // seek to the media's duration
    var duration = video.duration;
    console.log("onloadedmetadata(), duration = " + duration);
    video.currentTime = duration;
  }

  function onEnded() {
    ok(video.ended, test.name + " checking playback has ended");
    ok(!video.finished, test.name + " shouldn't be finished");
    ok(!video.seenEnded, test.name + " shouldn't be ended");
    video.seenEnded = true;

    ok(true, "Seeking to the duration triggers ended event");
    finish();
  }

  video.addEventListener("loadedmetadata", onLoadedmetadata, false);
  video.addEventListener("ended", onEnded, false);

  document.body.appendChild(video);
}

manager.runTests(gSeekTests, startTest);

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