summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_seek_nosrc.html
blob: 56461007bdd9f3935102326a45f3e2c2d2cda9c1 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>Media test: seek tests</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>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

var SEEK_TIME = 3.5;
var seekStarted = false;
var seekCompleted = false;
var metadata = false;

var v = document.createElement('video');
document.body.appendChild(v);
SimpleTest.registerCleanupFunction(function () {
  v.remove();
});

try {
  v.currentTime = SEEK_TIME;
} catch (e) {
  ok(false, "should not fire '" + e + "' event");
}
is(v.readyState, v.HAVE_NOTHING, "readyState is HAVE_NOTHING");
ok(!v.seeking, "can't be seeking prior src defined");
is(v.currentTime, SEEK_TIME, "currentTime is default playback start position");
once(v, "seeking", function() {
  seekStarted = true;
});
once(v, "seeked", function() {
  seekCompleted = true;
});
once(v, "loadedmetadata", function() {
  metadata = true;
  ok(v.seeking, "element is seeking once readyState is HAVE_METADATA");
});
once(v, "ended", function() {
  ok(seekStarted, "seek should have started");
  ok(seekCompleted, "seek should have completed");
  ok(metadata, "loadedmetadata fired");
  ok(v.currentTime >= SEEK_TIME, "currentTime should be after seek time");
  SimpleTest.finish();
});

v.src = "seek.webm";
v.play();

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