2010-08-19 15:50:37 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=548523
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 548523</title>
|
|
|
|
<script type="application/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>
|
|
|
|
<script type="text/javascript" src="use_large_cache.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=548523">Mozilla Bug 548523</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- <button onClick="SimpleTest.finish();">Finish</button> -->
|
|
|
|
<div>Tests complete: <span id="log" style="font-size: small;"></span></div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 548523 **/
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
var manager = new MediaTestManager;
|
|
|
|
|
|
|
|
manager.onFinished = function() {
|
|
|
|
is(gotLoadEvent, true, "Should not have delayed the load event indefinitely");
|
|
|
|
};
|
2010-08-19 15:50:37 -07:00
|
|
|
|
|
|
|
var test = getPlayableVideo(gSeekTests);
|
2011-11-24 18:06:22 -08:00
|
|
|
var baseName = test.name;
|
2010-08-26 19:11:46 -07:00
|
|
|
var gTest = test;
|
2010-08-19 15:50:37 -07:00
|
|
|
var bogusSrc = "bogus.duh";
|
|
|
|
var bogusType = "video/bogus";
|
|
|
|
var gotLoadEvent = false;
|
|
|
|
var finished = false;
|
|
|
|
|
|
|
|
addLoadEvent(function() {gotLoadEvent=true;});
|
|
|
|
|
|
|
|
function log(m) {
|
|
|
|
var l = document.getElementById("log");
|
|
|
|
l.innerHTML += m;
|
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
function maybeFinish(v, n) {
|
2011-11-29 14:01:14 -08:00
|
|
|
if (v._finished) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
v._finished = true;
|
2010-08-19 15:50:37 -07:00
|
|
|
log(n + ",");
|
2010-09-02 17:03:03 -07:00
|
|
|
if (v.parentNode) {
|
|
|
|
v.parentNode.removeChild(v);
|
|
|
|
}
|
2010-08-26 19:11:46 -07:00
|
|
|
manager.finished(v.token);
|
2010-08-19 15:50:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function filename(uri) {
|
|
|
|
return uri.substr(uri.lastIndexOf("/")+1);
|
|
|
|
}
|
|
|
|
|
2011-11-29 14:01:14 -08:00
|
|
|
// Every test must have a setup(v) function, and must call maybeFinish() when test is complete.
|
2010-08-19 15:50:37 -07:00
|
|
|
var tests = [
|
|
|
|
{
|
|
|
|
// 1. Add preload:none video with src to document. Load should halt at NETWORK_IDLE and HAVE_NOTHING,
|
|
|
|
// after receiving a suspend event. Should not receive loaded events until after we call load().
|
|
|
|
// Note the suspend event is explictly sent by our "stop the load" code, but other tests can't rely
|
|
|
|
// on it for the preload:metadata case, as there can be multiple suspend events when loading metadata.
|
|
|
|
suspend:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(1) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, false, "(1) Must not get loadedmetadata.");
|
|
|
|
is(v.readyState, v.HAVE_NOTHING, "(1) ReadyState must be HAVE_NOTHING");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(1) NetworkState must be NETWORK_IDLE");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 1);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("suspend", this.suspend, false);
|
|
|
|
v.src = test.name;
|
|
|
|
document.body.appendChild(v); // Causes implicit load, which will be halted due to preload:none.
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 2. Add preload:metadata video with src to document. Should halt with NETWORK_IDLE, HAVE_CURRENT_DATA
|
|
|
|
// after suspend event and after loadedmetadata.
|
|
|
|
loadeddata:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(2) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, true, "(2) Must get loadedmetadata.");
|
|
|
|
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(2) ReadyState must be >= HAVE_CURRENT_DATA");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(2) NetworkState must be NETWORK_IDLE");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 2);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "metadata";
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadeddata", this.loadeddata, false);
|
|
|
|
v.src = test.name;
|
|
|
|
document.body.appendChild(v); // Causes implicit load, which will be halted after
|
|
|
|
// metadata due to preload:metadata.
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 3. Add preload:auto to document. Should receive canplaythrough eventually.
|
|
|
|
canplaythrough:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(3) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, true, "(3) Must get loadedmetadata.");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 3);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "auto";
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("canplaythrough", this.canplaythrough, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 4. Add preload:none video to document. Call play(), should load then play through.
|
|
|
|
suspend:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
2011-11-24 18:06:22 -08:00
|
|
|
if (v._gotSuspend) {
|
2010-08-19 15:50:37 -07:00
|
|
|
return; // We can receive multiple suspend events, like the one after download completes.
|
2011-11-24 18:06:22 -08:00
|
|
|
}
|
2010-08-19 15:50:37 -07:00
|
|
|
v._gotSuspend = true;
|
|
|
|
is(v._gotLoadStart, true, "(4) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, false, "(4) Must not get loadedmetadata.");
|
|
|
|
is(v.readyState, v.HAVE_NOTHING, "(4) ReadyState must be HAVE_NOTHING");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(4) NetworkState must be NETWORK_IDLE");
|
|
|
|
v.play(); // Should load and play through.
|
|
|
|
},
|
|
|
|
|
|
|
|
ended:
|
|
|
|
function(e) {
|
|
|
|
ok(true, "(4) Got playback ended");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(e.target, 4);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v._gotSuspend = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("suspend", this.suspend, false);
|
|
|
|
v.addEventListener("ended", this.ended, false);
|
|
|
|
v.src = test.name;
|
|
|
|
document.body.appendChild(v);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 5. preload:none video without resource, add to document, will implicitly start a
|
|
|
|
// preload:none load. Add a src, it shouldn't load.
|
|
|
|
suspend:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(5) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, false, "(5) Must not get loadedmetadata.");
|
|
|
|
is(v.readyState, v.HAVE_NOTHING, "(5) ReadyState must be HAVE_NOTHING");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(5) NetworkState must be NETWORK_IDLE");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 5);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("suspend", this.suspend, false);
|
|
|
|
document.body.appendChild(v); // Causes implicit load, which will be halted due to no resource.
|
|
|
|
v.src = test.name; // Load should start, and halt at preload:none.
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 6. preload:none video without resource, add to document, will implicitly start a
|
|
|
|
// preload:none load. Add a source, it shouldn't load.
|
|
|
|
suspend:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(6) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, false, "(6) Must not get loadedmetadata.");
|
|
|
|
is(v.readyState, v.HAVE_NOTHING, "(6) ReadyState must be HAVE_NOTHING");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(6) NetworkState must be NETWORK_IDLE");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 6);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("suspend", this.suspend, false);
|
|
|
|
document.body.appendChild(v); // Causes implicit load, which will be halted due to no resource.
|
|
|
|
var s = document.createElement("source");
|
|
|
|
s.src = test.name;
|
|
|
|
s.type = test.type;
|
|
|
|
v.appendChild(s); // Load should start, and halt at preload:none.
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 7. create a preload:none document with multiple sources, the first of which is invalid.
|
|
|
|
// Add to document, then play. It should load and play through the second source.
|
|
|
|
suspend:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
if (v._gotSuspend)
|
|
|
|
return; // We can receive multiple suspend events, like the one after download completes.
|
|
|
|
v._gotSuspend = true;
|
|
|
|
is(v._gotLoadStart, true, "(7) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, false, "(7) Must not get loadedmetadata.");
|
|
|
|
is(v.readyState, v.HAVE_NOTHING, "(7) ReadyState must be HAVE_NOTHING");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(7) NetworkState must be NETWORK_IDLE");
|
|
|
|
v.play(); // Should load and play through.
|
|
|
|
},
|
|
|
|
|
|
|
|
ended:
|
|
|
|
function(e) {
|
|
|
|
ok(true, "(7) Got playback ended");
|
2010-08-26 19:11:46 -07:00
|
|
|
var v = e.target;
|
2010-09-02 17:03:03 -07:00
|
|
|
is(v._gotErrorEvent, true, "(7) Should get error event from first source load failure");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 7);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
2010-09-02 17:03:03 -07:00
|
|
|
v._gotErrorEvent = false;
|
2010-08-19 15:50:37 -07:00
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("suspend", this.suspend, false);
|
|
|
|
v.addEventListener("ended", this.ended, false);
|
|
|
|
var s1 = document.createElement("source");
|
|
|
|
s1.src = "not-a-real-file.404"
|
|
|
|
s1.type = test.type;
|
2010-11-04 17:44:33 -07:00
|
|
|
s1.addEventListener("error", function(e){v._gotErrorEvent = true;}, false);
|
2010-08-19 15:50:37 -07:00
|
|
|
v.appendChild(s1);
|
|
|
|
var s2 = document.createElement("source");
|
|
|
|
s2.src = test.name;
|
|
|
|
s2.type = test.type;
|
|
|
|
v.appendChild(s2);
|
|
|
|
document.body.appendChild(v); // Causes implicit load, which will be halt at preload:none on the second resource.
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 8. Change preload value from none to metadata should cause metadata to be loaded.
|
|
|
|
loadeddata:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadedMetaData, true, "(8) Must get loadedmetadata.");
|
|
|
|
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(8) ReadyState must be >= HAVE_CURRENT_DATA on suspend.");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(8) NetworkState must be NETWORK_IDLE when load is halted");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 8);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.addEventListener("loadstart", function(e){v.preload = "metadata";}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadeddata", this.loadeddata, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
},
|
2010-08-19 15:50:37 -07:00
|
|
|
/*{
|
2010-08-19 15:50:37 -07:00
|
|
|
// 9. Change preload value from metadata to auto should cause entire media to be loaded.
|
2010-08-19 15:50:37 -07:00
|
|
|
// For some reason we don't always receive the canplaythrough event, particuarly on this test.
|
|
|
|
// We've disabled this test until bug 568402 is fixed.
|
2010-08-19 15:50:37 -07:00
|
|
|
canplaythrough:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(9) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, true, "(9) Must get loadedmetadata.");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 9);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "metadata";
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadeddata", function(){v.preload = "auto"}, false);
|
|
|
|
v.addEventListener("canplaythrough", this.canplaythrough, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
2010-08-19 15:50:37 -07:00
|
|
|
},*/
|
2010-08-19 15:50:37 -07:00
|
|
|
{
|
|
|
|
// 10. Change preload value from none to auto should cause entire media to be loaded.
|
|
|
|
canplaythrough:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadedMetaData, true, "(10) Must get loadedmetadata.");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 10);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.addEventListener("loadstart", function(e){v.preload = "auto";}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("canplaythrough", this.canplaythrough, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 11. Change preload value from none to metadata should cause metadata to load.
|
|
|
|
loadeddata:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadedMetaData, true, "(11) Must get loadedmetadata.");
|
|
|
|
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(11) ReadyState must be >= HAVE_CURRENT_DATA.");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(11) NetworkState must be NETWORK_IDLE.");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 11);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.addEventListener("loadstart", function(e){v.preload = "metadata";}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadeddata", this.loadeddata, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 12. Change preload value from auto to metadata after load started,
|
|
|
|
// should still do full load, should not halt after metadata only.
|
|
|
|
canplaythrough:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadedMetaData, true, "(12) Must get loadedmetadata.");
|
|
|
|
is(v._gotLoadStart, true, "(12) Must get loadstart.");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 12);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "auto";
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("canplaythrough", this.canplaythrough, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
v.preload = "metadata";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2012-02-19 13:02:08 -08:00
|
|
|
// 13. Change preload value from auto to none after specifying a src
|
|
|
|
// should load according to preload none, no buffering should have taken place
|
|
|
|
suspend:
|
2010-08-19 15:50:37 -07:00
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(13) Must get loadstart.");
|
2012-02-19 13:02:08 -08:00
|
|
|
is(v._gotLoadedMetaData, false, "(13) Must not get loadedmetadata.");
|
|
|
|
is(v.readyState, v.HAVE_NOTHING, "(13) ReadyState must be HAVE_NOTHING");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(13) NetworkState must be NETWORK_IDLE");
|
2010-08-26 19:11:46 -07:00
|
|
|
maybeFinish(v, 13);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
2012-02-19 13:02:08 -08:00
|
|
|
v.preload = "auto";
|
|
|
|
v.src = test.name;
|
2010-08-19 15:50:37 -07:00
|
|
|
v.preload = "none";
|
2012-02-19 13:02:08 -08:00
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("suspend", this.suspend, false);
|
|
|
|
document.body.appendChild(v); // Causes implicit load, should load according to preload none
|
|
|
|
var s = document.createElement("source");
|
|
|
|
}
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// 14. Add preload:metadata video with src to document. Play(), should play through.
|
|
|
|
loadeddata:
|
|
|
|
function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v._gotLoadStart, true, "(14) Must get loadstart.");
|
|
|
|
is(v._gotLoadedMetaData, true, "(14) Must get loadedmetadata.");
|
|
|
|
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(14) ReadyState must be >= HAVE_CURRENT_DATA");
|
|
|
|
is(v.networkState, v.NETWORK_IDLE, "(14) NetworkState must be NETWORK_IDLE");
|
|
|
|
v.play();
|
|
|
|
},
|
|
|
|
|
|
|
|
ended:
|
|
|
|
function(e) {
|
|
|
|
ok(true, "(14) Got playback ended");
|
2010-08-26 19:11:46 -07:00
|
|
|
var v = e.target;
|
|
|
|
maybeFinish(v, 14);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "metadata";
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("ended", this.ended, false);
|
|
|
|
v.addEventListener("loadeddata", this.loadeddata, false);
|
|
|
|
v.src = test.name;
|
|
|
|
document.body.appendChild(v); // Causes implicit load, which will be halted after
|
|
|
|
// metadata due to preload:metadata.
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 15. Autoplay should override preload:none.
|
|
|
|
ended:
|
|
|
|
function(e) {
|
|
|
|
ok(true, "(15) Got playback ended.");
|
2010-08-26 19:11:46 -07:00
|
|
|
var v = e.target;
|
|
|
|
maybeFinish(v, 15);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v._gotLoadStart = false;
|
|
|
|
v._gotLoadedMetaData = false;
|
|
|
|
v.preload = "none";
|
|
|
|
v.autoplay = true;
|
|
|
|
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}, false);
|
|
|
|
v.addEventListener("loadedmetadata", function(e){v._gotLoadedMetaData = true;}, false);
|
|
|
|
v.addEventListener("ended", this.ended, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 16. Autoplay should override preload:metadata.
|
|
|
|
ended:
|
|
|
|
function(e) {
|
|
|
|
ok(true, "(16) Got playback ended.");
|
2010-08-26 19:11:46 -07:00
|
|
|
var v = e.target;
|
|
|
|
maybeFinish(v, 16);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v.preload = "metadata";
|
|
|
|
v.autoplay = true;
|
|
|
|
v.addEventListener("ended", this.ended, false);
|
2010-09-02 17:03:03 -07:00
|
|
|
v.src = test.name; // Causes implicit load.
|
|
|
|
document.body.appendChild(v);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// 17. On a preload:none video, adding autoplay should disable preload none, i.e. don't break autoplay!
|
|
|
|
ended:
|
|
|
|
function(e) {
|
|
|
|
ok(true, "(17) Got playback ended.");
|
2010-08-26 19:11:46 -07:00
|
|
|
var v = e.target;
|
|
|
|
maybeFinish(v, 17);
|
2010-08-19 15:50:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v.addEventListener("ended", this.ended, false);
|
|
|
|
v.preload = "none";
|
|
|
|
document.body.appendChild(v); // Causes implicit load, which will be halted due to preload:none.
|
|
|
|
v.autoplay = true;
|
|
|
|
v.src = test.name;
|
|
|
|
},
|
|
|
|
},
|
2010-10-16 11:41:53 -07:00
|
|
|
{
|
|
|
|
// 18. On a preload='none' video, call play() before load algorithms's sync
|
|
|
|
// has run, the play() call should override preload='none'.
|
|
|
|
ended:
|
|
|
|
function(e) {
|
|
|
|
ok(true, "(18) Got playback ended.");
|
|
|
|
var v = e.target;
|
|
|
|
maybeFinish(v, 18);
|
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
v.addEventListener("ended", this.ended, false);
|
|
|
|
v.preload = "none";
|
|
|
|
v.src = test.name; // Schedules async section to continue load algorithm.
|
|
|
|
document.body.appendChild(v);
|
|
|
|
v.play(); // Should cause preload:none to be overridden.
|
|
|
|
},
|
2012-02-19 13:02:08 -08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// 19. Set preload='auto' on first video source then switching preload='none' and swapping the video source to another.
|
|
|
|
// The second video should not start playing as it's preload state has been changed to 'none' from 'auto'
|
|
|
|
loadedmetadata: function(e) {
|
|
|
|
var v = e.target;
|
|
|
|
is(v.preload === "auto", true, "(19) preload is initially auto");
|
|
|
|
setTimeout(function() {
|
|
|
|
// set preload state to none and switch video sources
|
|
|
|
v.preload="none";
|
|
|
|
v.src = test.name + "?asdf";
|
|
|
|
setTimeout(function() {
|
|
|
|
is(v.readyState === 0, true, "(19) no buffering has taken place");
|
|
|
|
maybeFinish(v, 19);
|
|
|
|
}, 2000);
|
|
|
|
}, 2000);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setup:
|
|
|
|
function(v) {
|
|
|
|
var that = this;
|
|
|
|
v.preload = "auto";
|
|
|
|
v.src = test.name;
|
|
|
|
// add a listener for when the video has loaded, so we know preload auto has worked
|
|
|
|
v.addEventListener( "loadedmetadata", this.loadedmetadata, false);
|
|
|
|
document.body.appendChild(v);
|
2010-10-16 11:41:53 -07:00
|
|
|
}
|
2012-02-19 13:02:08 -08:00
|
|
|
}
|
2010-08-19 15:50:37 -07:00
|
|
|
];
|
|
|
|
|
2011-11-24 18:06:22 -08:00
|
|
|
var iterationCount = 0;
|
2010-08-26 19:11:46 -07:00
|
|
|
function startTest(test, token) {
|
2011-11-24 18:06:22 -08:00
|
|
|
if (test == tests[0]) {
|
|
|
|
++iterationCount;
|
|
|
|
}
|
|
|
|
if (iterationCount == 2) {
|
|
|
|
// Do this series of tests on logically different resources
|
|
|
|
test.name = baseName + "?" + Math.floor(Math.random()*100000);
|
|
|
|
}
|
2010-08-26 19:11:46 -07:00
|
|
|
var v = document.createElement("video");
|
|
|
|
v.token = token;
|
|
|
|
test.setup(v);
|
|
|
|
manager.started(token);
|
2010-08-19 15:50:37 -07:00
|
|
|
}
|
|
|
|
|
2011-11-24 18:06:22 -08:00
|
|
|
var twiceTests = tests.concat(tests);
|
|
|
|
manager.runTests(twiceTests, startTest);
|
2010-08-19 15:50:37 -07:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|