2012-09-05 03:24:34 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
2014-08-22 16:08:14 +04:00
|
|
|
<title>Media test: sniffing</title>
|
2012-09-05 03:24:34 +04:00
|
|
|
<meta charset='utf-8'>
|
|
|
|
<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>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
var manager = new MediaTestManager;
|
|
|
|
|
|
|
|
function finish_test(element) {
|
2017-01-17 13:50:25 +03:00
|
|
|
element.removeEventListener("error", onerror);
|
2014-01-17 09:58:48 +04:00
|
|
|
removeNodeAndSource(element);
|
2012-09-05 03:24:34 +04:00
|
|
|
manager.finished(element.token);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onmetadataloaded(e) {
|
|
|
|
var t = e.target;
|
2014-08-22 16:08:14 +04:00
|
|
|
++t.srcIndex;
|
|
|
|
ok(true, "The media loads when loaded via " + t.src);
|
|
|
|
if (t.srcIndex < t.srcList.length) {
|
|
|
|
t.src = t.srcList[t.srcIndex];
|
|
|
|
} else {
|
|
|
|
finish_test(t);
|
|
|
|
}
|
2012-09-05 03:24:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onerror(e) {
|
|
|
|
var t = e.target;
|
|
|
|
t.removeEventListener('error', onerror);
|
|
|
|
ok(false, "The media could not be loaded." + t.src + "\n");
|
|
|
|
finish_test(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
function startTest(test, token) {
|
|
|
|
var elemType = /^audio/.test(test.type) ? "audio" : "video";
|
|
|
|
var element = document.createElement(elemType);
|
|
|
|
// This .sjs file serve the media file without Content-Type header, or with a
|
|
|
|
// specific Content-Type header.
|
2014-08-22 16:08:14 +04:00
|
|
|
var baseSrc = 'contentType.sjs?file=' + test.name;
|
|
|
|
element.srcList = [
|
|
|
|
baseSrc + "&nomime",
|
|
|
|
baseSrc + "&type=application/octet-stream",
|
|
|
|
baseSrc + "&type=audio/wav",
|
|
|
|
baseSrc + "&type=text/html",
|
|
|
|
baseSrc + "&type=absolute_nonsense"
|
|
|
|
];
|
|
|
|
element.srcIndex = 0;
|
|
|
|
element.src = element.srcList[element.srcIndex];
|
2012-09-05 03:24:34 +04:00
|
|
|
element.token = token;
|
|
|
|
element.controls = true;
|
|
|
|
element.preload = "metadata";
|
|
|
|
document.body.appendChild(element);
|
|
|
|
manager.started(token);
|
|
|
|
element.addEventListener("loadedmetadata", onmetadataloaded);
|
|
|
|
element.addEventListener("error", onerror);
|
|
|
|
}
|
|
|
|
|
|
|
|
manager.runTests(gSnifferTests, startTest);
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|