2009-07-09 19:03:01 -07:00
|
|
|
// In each list of tests below, test file types that are not supported should
|
|
|
|
// be ignored. To make sure tests respect that, we include a file of type
|
|
|
|
// "bogus/duh" in each list.
|
|
|
|
|
2009-10-04 21:04:07 -07:00
|
|
|
// These are small test files, good for just seeing if something loads. We
|
|
|
|
// really only need one test file per backend here.
|
2009-07-09 19:03:01 -07:00
|
|
|
var gSmallTests = [
|
|
|
|
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
|
2010-05-30 15:02:06 -07:00
|
|
|
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.233 },
|
|
|
|
{ name:"small-shot.ogg", type:"audio/ogg", duration:0.276 },
|
|
|
|
{ name:"bogus.duh", type:"bogus/duh" }
|
|
|
|
];
|
|
|
|
|
|
|
|
// Used by test_progress to ensure we get the correct progress information
|
|
|
|
// during resource download.
|
|
|
|
var gProgressTests = [
|
|
|
|
{ name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0, size:11069 },
|
|
|
|
{ name:"big.wav", type:"audio/x-wav", duration:9.0, size:102444 },
|
|
|
|
{ name:"seek.ogv", type:"video/ogg", duration:3.966, size:285310 },
|
|
|
|
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.233, size:28942 },
|
2009-09-01 15:33:43 -07:00
|
|
|
{ name:"bogus.duh", type:"bogus/duh" }
|
2009-07-09 19:03:01 -07:00
|
|
|
];
|
2009-07-09 19:03:01 -07:00
|
|
|
|
2009-10-14 19:59:41 -07:00
|
|
|
// Used by test_mozLoadFrom. Need one test file per decoder backend, plus
|
|
|
|
// anything for testing clone-specific bugs.
|
|
|
|
var gCloneTests = gSmallTests.concat([
|
2010-01-27 04:29:26 -08:00
|
|
|
// Actual duration is ~200ms, we have Content-Duration lie about it.
|
2009-10-14 19:59:41 -07:00
|
|
|
{ name:"bug520908.ogv", type:"video/ogg", duration:9000 },
|
|
|
|
]);
|
|
|
|
|
2010-01-07 20:55:39 -08:00
|
|
|
// Used by test_play_twice. Need one test file per decoder backend, plus
|
|
|
|
// anything for testing bugs that occur when replying a played file.
|
|
|
|
var gReplayTests = gSmallTests.concat([
|
|
|
|
{ name:"bug533822.ogg", type:"audio/ogg" },
|
|
|
|
]);
|
|
|
|
|
2010-05-30 15:02:06 -07:00
|
|
|
// Used by test_paused_after_ended. Need one test file per decoder backend, plus
|
|
|
|
// anything for testing bugs that occur when replying a played file.
|
|
|
|
var gPausedAfterEndedTests = gSmallTests.concat([
|
|
|
|
{ name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0 },
|
|
|
|
{ name:"small-shot.ogg", type:"video/ogg", duration:0.276 }
|
|
|
|
]);
|
|
|
|
|
2009-10-04 21:04:07 -07:00
|
|
|
// These are files that we want to make sure we can play through. We can
|
2009-10-04 15:54:13 -07:00
|
|
|
// also check metadata. Put files of the same type together in this list so if
|
|
|
|
// something crashes we have some idea of which backend is responsible.
|
2009-10-04 21:04:07 -07:00
|
|
|
// Used by test_playback, which expects no error event and one ended event.
|
2009-07-09 19:03:01 -07:00
|
|
|
var gPlayTests = [
|
2009-07-09 19:03:02 -07:00
|
|
|
// 8-bit samples
|
|
|
|
{ name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0 },
|
|
|
|
// 8-bit samples, file is truncated
|
2009-07-09 19:03:01 -07:00
|
|
|
{ name:"r11025_u8_c1_trunc.wav", type:"audio/x-wav", duration:1.8 },
|
|
|
|
// file has trailing non-PCM data
|
|
|
|
{ name:"r11025_s16_c1_trailing.wav", type:"audio/x-wav", duration:1.0 },
|
|
|
|
// file with list chunk
|
|
|
|
{ name:"r16000_u8_c1_list.wav", type:"audio/x-wav", duration:4.2 },
|
2009-10-04 21:04:07 -07:00
|
|
|
|
2010-05-12 17:59:42 -07:00
|
|
|
// Ogg stream without eof marker
|
2010-05-30 15:02:06 -07:00
|
|
|
{ name:"bug461281.ogg", type:"application/ogg", duration:2.208 },
|
2010-05-12 17:59:42 -07:00
|
|
|
|
2009-07-09 19:03:01 -07:00
|
|
|
// oggz-chop stream
|
2010-04-01 20:03:07 -07:00
|
|
|
{ name:"bug482461.ogv", type:"video/ogg", duration:4.34 },
|
2009-08-03 23:13:40 -07:00
|
|
|
// With first frame a "duplicate" (empty) frame.
|
|
|
|
{ name:"bug500311.ogv", type:"video/ogg", duration:1.96 },
|
2009-08-03 22:20:37 -07:00
|
|
|
// Small audio file
|
2010-05-30 15:02:06 -07:00
|
|
|
{ name:"small-shot.ogg", type:"video/ogg", duration:0.276 },
|
2009-08-16 14:32:24 -07:00
|
|
|
// More audio in file than video.
|
2009-09-06 20:25:22 -07:00
|
|
|
{ name:"short-video.ogv", type:"video/ogg", duration:1.081 },
|
2009-09-14 22:53:49 -07:00
|
|
|
// First Theora data packet is zero bytes.
|
2010-05-30 15:02:06 -07:00
|
|
|
{ name:"bug504613.ogv", type:"video/ogg", duration:Number.NaN },
|
2009-09-28 17:59:00 -07:00
|
|
|
// Multiple audio streams.
|
2010-04-01 20:03:07 -07:00
|
|
|
{ name:"bug516323.ogv", type:"video/ogg", duration:4.208 },
|
|
|
|
|
2009-10-04 15:54:13 -07:00
|
|
|
// Encoded with vorbis beta1, includes unusually sized codebooks
|
2010-04-01 20:03:07 -07:00
|
|
|
{ name:"beta-phrasebook.ogg", type:"audio/ogg", duration:4.01 },
|
2009-10-13 20:35:59 -07:00
|
|
|
// Small file, only 1 frame with audio only.
|
|
|
|
{ name:"bug520493.ogg", type:"audio/ogg", duration:0.458 },
|
2009-10-13 20:36:01 -07:00
|
|
|
// Small file with vorbis comments with 0 length values and names.
|
|
|
|
{ name:"bug520500.ogg", type:"audio/ogg", duration:0.123 },
|
|
|
|
|
2009-10-04 21:04:07 -07:00
|
|
|
// Various weirdly formed Ogg files
|
|
|
|
{ name:"bug499519.ogv", type:"video/ogg", duration:0.24 },
|
|
|
|
{ name:"bug506094.ogv", type:"video/ogg", duration:0 },
|
2010-04-01 20:03:07 -07:00
|
|
|
{ name:"bug498855-1.ogv", type:"video/ogg", duration:0.24 },
|
|
|
|
{ name:"bug498855-2.ogv", type:"video/ogg", duration:0.24 },
|
|
|
|
{ name:"bug498855-3.ogv", type:"video/ogg", duration:0.24 },
|
|
|
|
{ name:"bug504644.ogv", type:"video/ogg", duration:1.6 },
|
2009-10-04 21:04:07 -07:00
|
|
|
{ name:"chain.ogv", type:"video/ogg", duration:Number.NaN },
|
2010-04-01 20:03:07 -07:00
|
|
|
{ name:"bug523816.ogv", type:"video/ogg", duration:0.533 },
|
|
|
|
{ name:"bug495129.ogv", type:"video/ogg", duration:2.41 },
|
2010-05-30 15:02:06 -07:00
|
|
|
|
|
|
|
{ name:"bug498380.ogv", type:"video/ogg", duration:0.533 },
|
2010-04-08 01:16:02 -07:00
|
|
|
{ name:"bug495794.ogg", type:"audio/ogg", duration:0.3 },
|
|
|
|
{ name:"bug557094.ogv", type:"video/ogg", duration:0.24 },
|
|
|
|
{ name:"audio-overhang.ogg", type:"audio/ogg", duration:2.3 },
|
|
|
|
{ name:"video-overhang.ogg", type:"audio/ogg", duration:3.966 },
|
2009-10-04 21:04:07 -07:00
|
|
|
|
2010-04-21 17:32:52 -07:00
|
|
|
// Test playback/metadata work after a redirect
|
2010-05-30 15:02:06 -07:00
|
|
|
{ name:"redirect.sjs?domain=mochi.test:8888&file=320x240.ogv",
|
2010-04-21 17:32:52 -07:00
|
|
|
type:"video/ogg", duration:0.233 },
|
|
|
|
|
2010-06-08 16:31:27 -07:00
|
|
|
// Test playback of a webm file
|
|
|
|
{ name:"seek.webm", type:"video/webm", duration:3.966 },
|
|
|
|
|
2010-05-30 15:02:06 -07:00
|
|
|
{ name:"bogus.duh", type:"bogus/duh", duration:Number.NaN }
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
// Converts a path/filename to a file:// URI which we can load from disk.
|
|
|
|
// Optionally checks whether the file actually exists on disk at the location
|
|
|
|
// we've specified.
|
|
|
|
function fileUriToSrc(path, mustExist) {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Cr = Components.results;
|
|
|
|
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
|
|
|
getService(Ci.nsIProperties);
|
|
|
|
var f = dirSvc.get("CurWorkD", Ci.nsILocalFile);
|
|
|
|
var split = path.split("/");
|
|
|
|
for(var i = 0; i < split.length; ++i) {
|
|
|
|
f.append(split[i]);
|
|
|
|
}
|
|
|
|
if (mustExist && !f.exists()) {
|
|
|
|
ok(false, "We expected '" + path + "' to exist, but it doesn't!");
|
|
|
|
}
|
|
|
|
return f.path;
|
|
|
|
}
|
|
|
|
|
|
|
|
// These are URIs to files that we use to check that we don't leak any state
|
|
|
|
// or other information such that script can determine stuff about a user's
|
|
|
|
// environment. Used by test_info_leak.
|
|
|
|
var gInfoLeakTests = [
|
|
|
|
{
|
|
|
|
type: 'video/ogg',
|
|
|
|
src: fileUriToSrc("tests/content/media/test/320x240.ogv", true),
|
|
|
|
},{
|
|
|
|
type: 'video/ogg',
|
|
|
|
src: fileUriToSrc("tests/content/media/test/404.ogv", false),
|
|
|
|
}, {
|
|
|
|
type: 'audio/x-wav',
|
|
|
|
src: fileUriToSrc("tests/content/media/test/r11025_s16_c1.wav", true),
|
|
|
|
}, {
|
|
|
|
type: 'audio/x-wav',
|
|
|
|
src: fileUriToSrc("tests/content/media/test/404.wav", false),
|
|
|
|
}, {
|
|
|
|
type: 'audio/ogg',
|
|
|
|
src: fileUriToSrc("tests/content/media/test/bug461281.ogg", true),
|
|
|
|
}, {
|
|
|
|
type: 'audio/ogg',
|
|
|
|
src: fileUriToSrc("tests/content/media/test/404.ogg", false),
|
|
|
|
}, {
|
|
|
|
type: 'video/ogg',
|
|
|
|
src: 'http://localhost/404.ogv',
|
|
|
|
}, {
|
|
|
|
type: 'audio/x-wav',
|
|
|
|
src: 'http://localhost/404.wav',
|
|
|
|
}, {
|
|
|
|
type: 'video/ogg',
|
|
|
|
src: 'http://example.com/tests/content/media/test/test_info_leak.html'
|
|
|
|
}, {
|
|
|
|
type: 'audio/ogg',
|
|
|
|
src: 'http://example.com/tests/content/media/test/test_info_leak.html'
|
|
|
|
}
|
2009-07-09 19:03:01 -07:00
|
|
|
];
|
|
|
|
|
2009-10-04 15:54:13 -07:00
|
|
|
// These are files that must fire an error during load or playback, and do not
|
|
|
|
// cause a crash. Put files of the same type together in this list so if
|
|
|
|
// something crashes we have some idea of which backend is responsible. Used
|
|
|
|
// by test_playback_errors, which expects one error event and no ended event.
|
2009-07-09 19:03:01 -07:00
|
|
|
// Put files of the same type together in this list so if something crashes
|
|
|
|
// we have some idea of which backend is responsible.
|
|
|
|
var gErrorTests = [
|
|
|
|
{ name:"bogus.wav", type:"audio/x-wav" },
|
|
|
|
{ name:"bogus.ogv", type:"video/ogg" },
|
2009-08-03 19:44:45 -07:00
|
|
|
{ name:"448636.ogv", type:"video/ogg" },
|
2010-04-01 20:03:07 -07:00
|
|
|
{ name:"bug504843.ogv", type:"video/ogg" },
|
|
|
|
{ name:"bug501279.ogg", type:"audio/ogg" },
|
2009-07-09 19:03:01 -07:00
|
|
|
{ name:"bogus.duh", type:"bogus/duh" }
|
|
|
|
];
|
|
|
|
|
2009-07-09 19:03:02 -07:00
|
|
|
// These are files that have nontrivial duration and are useful for seeking within.
|
|
|
|
var gSeekTests = [
|
|
|
|
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
|
|
|
|
{ name:"seek.ogv", type:"video/ogg", duration:3.966 },
|
2009-10-19 19:48:03 -07:00
|
|
|
{ name:"320x240.ogv", type:"video/ogg", duration:0.233 },
|
2009-07-09 19:03:02 -07:00
|
|
|
{ name:"bogus.duh", type:"bogus/duh", duration:123 }
|
|
|
|
];
|
|
|
|
|
2009-07-09 19:03:02 -07:00
|
|
|
// These are files suitable for using with a "new Audio" constructor.
|
|
|
|
var gAudioTests = [
|
|
|
|
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
|
|
|
|
{ name:"sound.ogg", type:"audio/ogg" },
|
|
|
|
{ name:"bogus.duh", type:"bogus/duh", duration:123 }
|
|
|
|
];
|
|
|
|
|
2010-05-30 15:02:06 -07:00
|
|
|
// These files ensure our hanlding of 404 errors is consistent across the
|
|
|
|
// various backends.
|
|
|
|
var g404Tests = [
|
|
|
|
{ name:"404.wav", type:"audio/x-wav" },
|
|
|
|
{ name:"404.ogv", type:"video/ogg" },
|
|
|
|
{ name:"404.oga", type:"audio/ogg" },
|
|
|
|
{ name:"404.webm", type:"video/webm" },
|
|
|
|
{ name:"bogus.duh", type:"bogus/duh" }
|
|
|
|
];
|
|
|
|
|
2009-09-21 17:08:13 -07:00
|
|
|
// These are files suitable for testing various decoder failures that are
|
|
|
|
// expected to fire MEDIA_ERR_DECODE. Used by test_decode_error, which expects
|
|
|
|
// an error and emptied event, and no loadedmetadata or ended event.
|
|
|
|
var gDecodeErrorTests = [
|
|
|
|
// Valid files with unsupported codecs
|
|
|
|
{ name:"r11025_msadpcm_c1.wav", type:"audio/x-wav" },
|
|
|
|
{ name:"dirac.ogg", type:"video/ogg" },
|
|
|
|
// Invalid files
|
|
|
|
{ name:"bogus.wav", type:"audio/x-wav" },
|
|
|
|
{ name:"bogus.ogv", type:"video/ogg" },
|
|
|
|
|
|
|
|
{ name:"bogus.duh", type:"bogus/duh" }
|
|
|
|
];
|
|
|
|
|
2009-07-09 19:03:01 -07:00
|
|
|
function checkMetadata(msg, e, test) {
|
|
|
|
if (test.width) {
|
|
|
|
is(e.videoWidth, test.width, msg + " video width");
|
|
|
|
}
|
|
|
|
if (test.height) {
|
|
|
|
is(e.videoHeight, test.height, msg + " video height");
|
|
|
|
}
|
|
|
|
if (test.duration) {
|
|
|
|
ok(Math.abs(e.duration - test.duration) < 0.1,
|
2010-05-30 15:02:06 -07:00
|
|
|
msg + " duration (" + e.duration + ") should be around " + test.duration);
|
2009-07-09 19:03:01 -07:00
|
|
|
}
|
|
|
|
}
|
2010-05-30 15:02:06 -07:00
|
|
|
|
|
|
|
// Returns true if all members of array 'v' have their _finished field set to true.
|
|
|
|
function AllFinished(v) {
|
|
|
|
if (v.length == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (var i=0; i<v.length; ++i) {
|
|
|
|
if (!v[i]._finished) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the first test from candidates array which we can play with the
|
|
|
|
// installed video backends.
|
|
|
|
function getPlayableVideo(candidates) {
|
|
|
|
var v = document.createElement("video");
|
|
|
|
var resources = candidates.filter(function(x){return /^video/.test(x.type) && v.canPlayType(x.type);});
|
|
|
|
if (resources.length > 0)
|
|
|
|
return resources[0];
|
|
|
|
return null;
|
|
|
|
}
|