Bug 792935 - Add DASH to various Media Mochitests r=cpearce

This commit is contained in:
Steve Workman 2013-01-23 11:24:41 -08:00
parent 75320e63ef
commit a8a940298d
12 changed files with 49 additions and 18 deletions

View File

@ -17,7 +17,8 @@ var types = {
ogv: "video/ogg",
oga: "audio/ogg",
webm: "video/webm",
wav: "audio/x-wav"
wav: "audio/x-wav",
mpd: "application/dash+xml"
};
// Return file with name as per the query string with access control

View File

@ -496,6 +496,15 @@ function getPlayableAudio(candidates) {
return null;
}
// Returns the type of element that should be created for the given mimetype.
function getMajorMimeType(mimetype) {
if (/^video/.test(mimetype) || /^application\/dash\+xml/.test(mimetype)) {
return "video";
} else {
return "audio";
}
}
// Number of tests to run in parallel. Warning: Each media element requires
// at least 3 threads (4 on Linux), and on Linux each thread uses 10MB of
// virtual address space. Beware!

View File

@ -43,7 +43,7 @@ function seekEnded(e) {
}
function initTest(test, token) {
var type = /^video/.test(test.type) ? "video" : "audio";
var type = getMajorMimeType(test.type);
var v = document.createElement(type);
if (!v.canPlayType(test.type))
return;

View File

@ -41,8 +41,8 @@ function startTest(test, token) {
// TODO: Bug 568402, there's a bug in the WAV backend where we sometimes
// don't send canplaythrough events after seeking. Once that is fixed,
// we should remove this guard below so that we run this test for audio.
var isVideo = /^video/.test(test.type) ? true : false;
if (!isVideo)
var type = getMajorMimeType(test.type);
if (type != "video")
return;
var v = document.createElement('video');

View File

@ -11,7 +11,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=686942
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=448535">Mozilla Bug 686942</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=686942">Mozilla Bug 686942</a>
<pre id="test">
<script class="testbody" type="text/javascript">

View File

@ -24,6 +24,9 @@ var v1 = document.createElement("video"),
resource = getPlayableVideo(gSmallTests);
function bodyLoaded(){
// Note: For DASH, width and height would vary once the video started playing, so
// the values would not correlate with those in manifest.js. Since this test has
// no playing, this should not affect the result.
is(v1.videoWidth, resource.width, "Intrinsic width should match video width");
is(v1.videoHeight, resource.height, "Intrinsic height should match video height");
is(v2.clientWidth, 400, "clientWidth should be 400");

View File

@ -34,12 +34,13 @@ function errorHandler(evt) {
evt.target.parentNode._error++;
}
var extenstion = {
var extension = {
"audio/wav" : "wav",
"audio/x-wav": "wav",
"video/ogg" : "ogv",
"audio/ogg" : "oga",
"video/webm" : "webm"
"video/webm" : "webm",
"application/dash+xml" : "mpd"
};
function startTest(test, token) {
@ -53,7 +54,7 @@ function startTest(test, token) {
var s1 = document.createElement("source");
s1.type = test.type;
s1.src = "404." + extenstion[test.type];
s1.src = "404." + extension[test.type];
s1.addEventListener("error", errorHandler, false);
v.appendChild(s1);

View File

@ -46,7 +46,12 @@ function loadedMetadata(evt) {
// Create all media objects.
for (var i=0; i<gSmallTests.length; ++i) {
var test = gSmallTests[i];
var type = /^video/.test(test.type) ? "video" : "audio";
var type;
if (/^video/.test(test.type) || /^application\/dash\+xml/.test(test.type)) {
type = "video"
} else {
type = "audio";
}
var v = document.createElement(type);
if (!v.canPlayType(test.type)) {
continue;

View File

@ -51,7 +51,7 @@ function playing(e) {
}
function initTest(test, token) {
var type = /^video/.test(test.type) ? "video" : "audio";
var type = getMajorMimeType(test.type);
var v = document.createElement(type);
v.token = token;
manager.started(token);

View File

@ -24,10 +24,14 @@ is(a1.childNodes.length, 0, "should have no children");
function newSource(filter) {
var test = null;
var candidates = gSmallTests.filter(function(x){return filter.test(x.type);});
var e = document.createElement("source");
e.type = candidates[0].type;
e.src = candidates[0].name;
return e;
if (candidates.length > 0) {
var e = document.createElement("source");
e.type = candidates[0].type;
e.src = candidates[0].name;
return e;
} else {
return null
}
}
var audioLoaded = false;
@ -53,6 +57,9 @@ v1.addEventListener('loadeddata', loaded, false);
a1.addEventListener('loadeddata', loaded, false);
var videoSource = newSource(/^video/);
if (videoSource == null) {
videoSource = newSource(/^application\/dash\+xml/);
}
if (videoSource) {
v1.appendChild(videoSource);
v1.load();
@ -72,7 +79,12 @@ if (audioSource) {
if (!audioLoaded && !videoLoaded) {
SimpleTest.waitForExplicitFinish();
} else {
todo(false, "No types supported");
if (audioLoaded) {
todo(false, "No audio types supported");
}
if (videoLoaded) {
todo(false, "No video types supported");
}
}
</script>

View File

@ -65,7 +65,7 @@ function logEvent(event) {
}
function startTest(test, token) {
var type = /^video/.test(test.type) ? "video" : "audio";
var type = getMajorMimeType(test.type);
var v = document.createElement(type);
v.token = token;
manager.started(token);

View File

@ -40,8 +40,8 @@ function loaded(e) {
}
function startTest(test, token) {
var isVideo = /^video/.test(test.type) ? true : false;
if (!isVideo)
var type = getMajorMimeType(test.type);
if (type != "video")
return;
var v = document.createElement('video');