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
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=495145
-->
<head>
<title>Bug 495145 - pausing while ended shouldn't cause problems</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=495145">Mozilla Bug 495145</a>
<pre id="test">
<script class="testbody" type="text/javascript">
//longer timeout for slow platforms
if (isSlowPlatform()) {
SimpleTest.requestLongerTimeout(1.5);
}
var manager = new MediaTestManager;
function start(e) {
e.target.play();
}
function ended1(e) {
var v = e.target;
if (v._finished)
return;
++v._endCount;
if (v._endCount == 2) {
ok(true, "Playing after pause while ended works for " + v._name);
v._finished = true;
v.removeEventListener("loadedmetadata", start, false);
v.removeEventListener("ended", ended1, false);
removeNodeAndSource(v);
manager.finished(v.token);
return;
}
v.pause();
v.play();
}
function ended2(e) {
var v = e.target;
if (v._finished)
return;
v.pause();
v.currentTime = 0;
}
function seeked2(e) {
var v = e.target;
if (v._finished)
return;
ok(v.paused, "Paused after seek after pause while ended for " + v._name);
v._finished = true;
v.removeEventListener("loadedmetadata", start, false);
v.removeEventListener("ended", ended2, false);
v.removeEventListener("seeked", seeked2, false);
removeNodeAndSource(v);
manager.finished(v.token);
}
function createVideo(test, x, token) {
var v = document.createElement('video');
v.preload = "metadata";
v.token = token;
manager.started(token);
v.src = test.name;
v._name = test.name + "#" + x;
v._endCount = 0;
v._finished = false;
v.addEventListener("loadedmetadata", start, false);
v.addEventListener("ended", x == 1 ? ended1 : ended2, false);
if (x == 2)
v.addEventListener("seeked", seeked2, false);
document.body.appendChild(v);
}
function startTest(test, token) {
createVideo(test, 1, token + "a");
createVideo(test, 2, token + "b");
}
manager.runTests(gSmallTests, startTest);
</script>
</pre>
</body>
</html>
|