2009-05-17 19:00:44 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=479863
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 479863</title>
|
|
|
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
<script type="application/javascript" src="use_large_cache.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=479863">Mozilla Bug 479863</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2010-11-04 17:44:33 -07:00
|
|
|
<video id='v1'></video>
|
|
|
|
<video id='v2' preload="auto"></video>
|
|
|
|
<video id='v3' autoplay></video>
|
|
|
|
<video id='v4'></video>
|
|
|
|
<video id='v5'></video>
|
|
|
|
<video id='v6'></video>
|
2009-05-17 19:03:37 -07:00
|
|
|
|
|
|
|
<pre id="test">
|
2009-05-17 19:00:44 -07:00
|
|
|
<script type="application/javascript">
|
2010-08-19 15:50:37 -07:00
|
|
|
function is() {}
|
|
|
|
|
2009-10-09 04:48:33 -07:00
|
|
|
var suspendCount = {};
|
|
|
|
var expectedSuspendCount = {v1:2, v2:1, v3:1, v4:2, v5:2, v6:2};
|
|
|
|
var totalSuspendCount = 0;
|
|
|
|
for (var i = 0; i < expectedSuspendCount.length; ++i) {
|
|
|
|
totalSuspendCount += expectedSuspendCount[i];
|
2009-05-17 19:00:44 -07:00
|
|
|
}
|
2009-05-17 19:03:37 -07:00
|
|
|
|
|
|
|
function suspended(event) {
|
2009-05-18 16:06:10 -07:00
|
|
|
// If the element suspends the download, it should not then be able to
|
|
|
|
// complete it, so we should be stuck in NETWORK_IDLE even though this
|
2009-10-09 04:48:33 -07:00
|
|
|
// event handler could run a long time after the actual suspend.
|
|
|
|
var expectedState = event.type == "load" ? event.target.NETWORK_LOADED
|
|
|
|
: event.target.NETWORK_IDLE;
|
|
|
|
|
|
|
|
is(event.target.networkState, expectedState,
|
2009-05-18 16:06:10 -07:00
|
|
|
event.target.id + " suspended networkState");
|
2009-10-09 04:48:33 -07:00
|
|
|
suspendCount[event.target.id]++;
|
|
|
|
|
|
|
|
--totalSuspendCount;
|
|
|
|
if (totalSuspendCount == 0) {
|
|
|
|
// We're done.
|
|
|
|
for (var i = 1; i <= 6; ++i) {
|
|
|
|
var id = "v" + i;
|
|
|
|
is(suspendCount[id], expectedSuspendCount[id], "Suspend count for " + id);
|
|
|
|
}
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (suspendCount[event.target.id] > 1)
|
|
|
|
return;
|
|
|
|
|
2009-05-17 19:00:44 -07:00
|
|
|
if (event.target.id == "v1") {
|
2010-08-19 15:50:37 -07:00
|
|
|
event.target.preload = "auto";
|
2009-05-17 19:00:44 -07:00
|
|
|
} else if (event.target.id == "v4") {
|
|
|
|
event.target.play();
|
|
|
|
} else if (event.target.id == "v5") {
|
|
|
|
event.target.currentTime = 0.1;
|
|
|
|
} else if (event.target.id == "v6") {
|
|
|
|
event.target.autoplay = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-17 19:03:37 -07:00
|
|
|
var key = Math.random();
|
2009-10-09 04:48:33 -07:00
|
|
|
for (var i = 1; i <= 6; ++i) {
|
2009-05-17 19:03:37 -07:00
|
|
|
var id = "v" + i;
|
|
|
|
var v = document.getElementById(id);
|
2009-10-09 04:48:33 -07:00
|
|
|
suspendCount[id] = 0;
|
2009-05-17 19:03:37 -07:00
|
|
|
v.addEventListener("suspend", suspended, false);
|
2009-10-09 04:48:33 -07:00
|
|
|
// Treat "load" as "suspend" for now, it means the same thing: we
|
|
|
|
// stopped the download.
|
|
|
|
v.addEventListener("load", suspended, false);
|
2009-05-17 19:03:37 -07:00
|
|
|
v.src = "seek.ogv?key=" + key + "&id=" + id;
|
|
|
|
}
|
2009-05-17 19:00:44 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|