summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_bug465498.html
blob: 77bc68e71abdb0e505f5b72211c33c941ecce864 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE HTML>
<html>
<head>
  <title>Media test: Bug 465498 - Seeking after playback ended</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>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=465498">Mozilla Bug 465498</a>
<pre id="test">
<script class="testbody" type="text/javascript">

var manager = new MediaTestManager;

function startTest(e) {
  var v = e.target;
  info(v._name + " loadedmetadata");
  e.target.play();
}

function playbackEnded(e) {
  var v = e.target;
  info(v._name + " ended");
  if (v._finished)
    return;
  ok(v.currentTime >= v.duration - 0.1 && v.currentTime <= v.duration + 0.1,
     "Checking currentTime at end: " + v.currentTime + " for " + v._name);
  ok(v.ended, "Checking playback has ended for " + v._name);
  v.pause();
  v.currentTime = 0;
  ok(!v.ended, "Checking ended is no longer true for " + v._name);
  v._seeked = true;
}

function seekEnded(e) {
  var v = e.target;
  info(v._name + " seeked");
  if (v._finished)
    return;
  ok(v.currentTime == 0, "Checking currentTime after seek: " +
     v.currentTime  + " for " + v._name);
  ok(!v.ended, "Checking ended is false for " + v._name);
  v._finished = true;
  removeNodeAndSource(v);
  manager.finished(v.token);
}

function seeking(e) {
  var v = e.target;
  info(v._name + " seeking");
}

function initTest(test, token) {
  var type = getMajorMimeType(test.type);
  var v = document.createElement(type);
  if (!v.canPlayType(test.type))
    return;
  v.preload = "metadata";
  v.token = token;
  manager.started(token);
  v._name = test.name;

  var s = document.createElement("source");
  s.type = test.type;
  s.src = test.name;
  v.appendChild(s);

  v._seeked = false;
  v._finished = false;
  v.addEventListener("loadedmetadata", startTest, false);
  v.addEventListener("ended", playbackEnded, false);
  v.addEventListener("seeked", seekEnded, false);
  v.addEventListener("seeking", seeking, false);
  document.body.appendChild(v);
}

manager.runTests(gSmallTests, initTest);

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