content/media/test/manifest.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // In each list of tests below, test file types that are not supported should
michael@0 2 // be ignored. To make sure tests respect that, we include a file of type
michael@0 3 // "bogus/duh" in each list.
michael@0 4
michael@0 5 // These are small test files, good for just seeing if something loads. We
michael@0 6 // really only need one test file per backend here.
michael@0 7 var gSmallTests = [
michael@0 8 { name:"small-shot.ogg", type:"audio/ogg", duration:0.276 },
michael@0 9 { name:"small-shot.m4a", type:"audio/mp4", duration:0.29 },
michael@0 10 { name:"small-shot.mp3", type:"audio/mpeg", duration:0.27 },
michael@0 11 { name:"small-shot-mp3.mp4", type:"audio/mp4; codecs=mp3", duration:0.34 },
michael@0 12 { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
michael@0 13 { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 },
michael@0 14 { name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },
michael@0 15 { name:"vp9.webm", type:"video/webm", width:320, height:240, duration:4 },
michael@0 16 { name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
michael@0 17 { name:"gizmo.mp4", type:"video/mp4", duration:5.56 },
michael@0 18 { name:"bogus.duh", type:"bogus/duh" }
michael@0 19 ];
michael@0 20
michael@0 21 // Used by test_bug654550.html, for videoStats preference
michael@0 22 var gVideoTests = [
michael@0 23 { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 },
michael@0 24 { name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },
michael@0 25 { name:"bogus.duh", type:"bogus/duh" }
michael@0 26 ];
michael@0 27
michael@0 28 // Used by test_progress to ensure we get the correct progress information
michael@0 29 // during resource download.
michael@0 30 var gProgressTests = [
michael@0 31 { name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0, size:11069 },
michael@0 32 { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444 },
michael@0 33 { name:"seek.ogv", type:"video/ogg", duration:3.966, size:285310 },
michael@0 34 { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266, size:28942 },
michael@0 35 { name:"seek.webm", type:"video/webm", duration:3.966, size:215529 },
michael@0 36 { name:"gizmo.mp4", type:"video/mp4", duration:5.56, size:383631 },
michael@0 37 { name:"bogus.duh", type:"bogus/duh" }
michael@0 38 ];
michael@0 39
michael@0 40 // Used by test_played.html
michael@0 41 var gPlayedTests = [
michael@0 42 { name:"big.wav", type:"audio/x-wav", duration:9.0 },
michael@0 43 { name:"seek.ogv", type:"video/ogg", duration:3.966 },
michael@0 44 { name:"seek.webm", type:"video/webm", duration:3.966 },
michael@0 45 { name:"gizmo.mp4", type:"video/mp4", duration:5.56 },
michael@0 46 { name:"owl.mp3", type:"audio/mpeg", duration:3.29 },
michael@0 47 { name:"vbr.mp3", type:"audio/mpeg", duration:10.0 },
michael@0 48 { name:"bug495794.ogg", type:"audio/ogg", duration:0.3 }
michael@0 49 ];
michael@0 50
michael@0 51 // Used by test_mozLoadFrom. Need one test file per decoder backend, plus
michael@0 52 // anything for testing clone-specific bugs.
michael@0 53 var cloneKey = Math.floor(Math.random()*100000000);
michael@0 54 var gCloneTests = gSmallTests.concat([
michael@0 55 // Actual duration is ~200ms, we have Content-Duration lie about it.
michael@0 56 { name:"bug520908.ogv", type:"video/ogg", duration:9000 },
michael@0 57 // short-video is more like 1s, so if you load this twice you'll get an unexpected duration
michael@0 58 { name:"dynamic_resource.sjs?key=" + cloneKey + "&res1=320x240.ogv&res2=short-video.ogv",
michael@0 59 type:"video/ogg", duration:0.266 },
michael@0 60 ]);
michael@0 61
michael@0 62 // Used by test_play_twice. Need one test file per decoder backend, plus
michael@0 63 // anything for testing bugs that occur when replying a played file.
michael@0 64 var gReplayTests = gSmallTests.concat([
michael@0 65 { name:"bug533822.ogg", type:"audio/ogg" },
michael@0 66 ]);
michael@0 67
michael@0 68 // Used by test_paused_after_ended. Need one test file per decoder backend, plus
michael@0 69 // anything for testing bugs that occur when replying a played file.
michael@0 70 var gPausedAfterEndedTests = gSmallTests.concat([
michael@0 71 { name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0 },
michael@0 72 { name:"small-shot.ogg", type:"video/ogg", duration:0.276 }
michael@0 73 ]);
michael@0 74
michael@0 75 // Test the mozHasAudio property, and APIs that detect different kinds of
michael@0 76 // tracks
michael@0 77 var gTrackTests = [
michael@0 78 { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444, hasAudio:true, hasVideo:false },
michael@0 79 { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266, size:28942, hasAudio:false, hasVideo:true },
michael@0 80 { name:"short-video.ogv", type:"video/ogg", duration:1.081, hasAudio:true, hasVideo:true },
michael@0 81 { name:"seek.webm", type:"video/webm", duration:3.966, size:215529, hasAudio:false, hasVideo:true },
michael@0 82 { name:"bogus.duh", type:"bogus/duh" }
michael@0 83 ];
michael@0 84
michael@0 85 // Used by any media recorder test. Need one test file per decoder backend
michael@0 86 // currently supported by the media encoder.
michael@0 87 var gMediaRecorderTests = [
michael@0 88 { name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 }
michael@0 89 ];
michael@0 90
michael@0 91 // These are files that we want to make sure we can play through. We can
michael@0 92 // also check metadata. Put files of the same type together in this list so if
michael@0 93 // something crashes we have some idea of which backend is responsible.
michael@0 94 // Used by test_playback, which expects no error event and one ended event.
michael@0 95 var gPlayTests = [
michael@0 96 // 8-bit samples
michael@0 97 { name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0 },
michael@0 98 // 8-bit samples, file is truncated
michael@0 99 { name:"r11025_u8_c1_trunc.wav", type:"audio/x-wav", duration:1.8 },
michael@0 100 // file has trailing non-PCM data
michael@0 101 { name:"r11025_s16_c1_trailing.wav", type:"audio/x-wav", duration:1.0 },
michael@0 102 // file with list chunk
michael@0 103 { name:"r16000_u8_c1_list.wav", type:"audio/x-wav", duration:4.2 },
michael@0 104
michael@0 105 // Ogg stream without eof marker
michael@0 106 { name:"bug461281.ogg", type:"application/ogg", duration:2.208 },
michael@0 107
michael@0 108 // oggz-chop stream
michael@0 109 { name:"bug482461.ogv", type:"video/ogg", duration:4.34 },
michael@0 110 // Theora only oggz-chop stream
michael@0 111 { name:"bug482461-theora.ogv", type:"video/ogg", duration:4.138 },
michael@0 112 // With first frame a "duplicate" (empty) frame.
michael@0 113 { name:"bug500311.ogv", type:"video/ogg", duration:1.96 },
michael@0 114 // Small audio file
michael@0 115 { name:"small-shot.ogg", type:"video/ogg", duration:0.276 },
michael@0 116 // More audio in file than video.
michael@0 117 { name:"short-video.ogv", type:"video/ogg", duration:1.081 },
michael@0 118 // First Theora data packet is zero bytes.
michael@0 119 { name:"bug504613.ogv", type:"video/ogg", duration:Number.NaN },
michael@0 120 // Multiple audio streams.
michael@0 121 { name:"bug516323.ogv", type:"video/ogg", duration:4.208 },
michael@0 122 // oggz-chop with non-keyframe as first frame
michael@0 123 { name:"bug556821.ogv", type:"video/ogg", duration:2.551 },
michael@0 124
michael@0 125 // Encoded with vorbis beta1, includes unusually sized codebooks
michael@0 126 { name:"beta-phrasebook.ogg", type:"audio/ogg", duration:4.01 },
michael@0 127 // Small file, only 1 frame with audio only.
michael@0 128 { name:"bug520493.ogg", type:"audio/ogg", duration:0.458 },
michael@0 129 // Small file with vorbis comments with 0 length values and names.
michael@0 130 { name:"bug520500.ogg", type:"audio/ogg", duration:0.123 },
michael@0 131
michael@0 132 // Various weirdly formed Ogg files
michael@0 133 { name:"bug499519.ogv", type:"video/ogg", duration:0.24 },
michael@0 134 { name:"bug506094.ogv", type:"video/ogg", duration:0 },
michael@0 135 { name:"bug498855-1.ogv", type:"video/ogg", duration:0.24 },
michael@0 136 { name:"bug498855-2.ogv", type:"video/ogg", duration:0.24 },
michael@0 137 { name:"bug498855-3.ogv", type:"video/ogg", duration:0.24 },
michael@0 138 { name:"bug504644.ogv", type:"video/ogg", duration:1.6 },
michael@0 139 { name:"chain.ogv", type:"video/ogg", duration:Number.NaN },
michael@0 140 { name:"bug523816.ogv", type:"video/ogg", duration:0.533 },
michael@0 141 { name:"bug495129.ogv", type:"video/ogg", duration:2.41 },
michael@0 142 { name:"bug498380.ogv", type:"video/ogg", duration:0.533 },
michael@0 143 { name:"bug495794.ogg", type:"audio/ogg", duration:0.3 },
michael@0 144 { name:"bug557094.ogv", type:"video/ogg", duration:0.24 },
michael@0 145 { name:"multiple-bos.ogg", type:"video/ogg", duration:0.431 },
michael@0 146 { name:"audio-overhang.ogg", type:"audio/ogg", duration:2.3 },
michael@0 147 { name:"video-overhang.ogg", type:"audio/ogg", duration:3.966 },
michael@0 148
michael@0 149 // bug461281.ogg with the middle second chopped out.
michael@0 150 { name:"audio-gaps.ogg", type:"audio/ogg", duration:2.208 },
michael@0 151
michael@0 152 // Test playback/metadata work after a redirect
michael@0 153 { name:"redirect.sjs?domain=mochi.test:8888&file=320x240.ogv",
michael@0 154 type:"video/ogg", duration:0.266 },
michael@0 155
michael@0 156 // Test playback of a webm file
michael@0 157 { name:"seek.webm", type:"video/webm", duration:3.966 },
michael@0 158
michael@0 159 // Test playback of a WebM file with non-zero start time.
michael@0 160 { name:"split.webm", type:"video/webm", duration:1.967 },
michael@0 161
michael@0 162 // Test playback of a WebM file with vp9 video
michael@0 163 //{ name:"vp9.webm", type:"video/webm", duration:4 },
michael@0 164 { name:"vp9cake.webm", type:"video/webm", duration:7.966 },
michael@0 165
michael@0 166 // Test playback of a raw file
michael@0 167 { name:"seek.yuv", type:"video/x-raw-yuv", duration:1.833 },
michael@0 168
michael@0 169 // A really short, low sample rate, single channel file. This tests whether
michael@0 170 // we can handle playing files when only push very little audio data to the
michael@0 171 // hardware.
michael@0 172 { name:"spacestorm-1000Hz-100ms.ogg", type:"audio/ogg", duration:0.099 },
michael@0 173
michael@0 174 // Opus data in an ogg container
michael@0 175 { name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
michael@0 176 // Opus data in a webm container
michael@0 177 { name:"detodos.webm", type:"audio/webm; codecs=opus", duration:2.9135 },
michael@0 178
michael@0 179 // Multichannel Opus in an ogg container
michael@0 180 { name:"test-1-mono.opus", type:"audio/ogg; codecs=opus", duration:1.044 },
michael@0 181 { name:"test-2-stereo.opus", type:"audio/ogg; codecs=opus", duration:2.925 },
michael@0 182 { name:"test-3-LCR.opus", type:"audio/ogg; codecs=opus", duration:4.214 },
michael@0 183 { name:"test-4-quad.opus", type:"audio/ogg; codecs=opus", duration:6.234 },
michael@0 184 { name:"test-5-5.0.opus", type:"audio/ogg; codecs=opus", duration:7.558 },
michael@0 185 { name:"test-6-5.1.opus", type:"audio/ogg; codecs=opus", duration:10.333 },
michael@0 186 { name:"test-7-6.1.opus", type:"audio/ogg; codecs=opus", duration:11.690 },
michael@0 187 { name:"test-8-7.1.opus", type:"audio/ogg; codecs=opus", duration:13.478 },
michael@0 188
michael@0 189 { name:"gizmo.mp4", type:"video/mp4", duration:5.56 },
michael@0 190
michael@0 191 { name:"small-shot.m4a", type:"audio/mp4", duration:0.29 },
michael@0 192 { name:"small-shot.mp3", type:"audio/mpeg", duration:0.27 },
michael@0 193 { name:"owl.mp3", type:"audio/mpeg", duration:3.29 },
michael@0 194 // owl.mp3 as above, but with something funny going on in the ID3v2 tag
michael@0 195 // that causes DirectShow to fail.
michael@0 196 { name:"owl-funny-id3.mp3", type:"audio/mpeg", duration:3.29 },
michael@0 197 // owl.mp3 as above, but with something even funnier going on in the ID3v2 tag
michael@0 198 // that causes DirectShow to fail.
michael@0 199 { name:"owl-funnier-id3.mp3", type:"audio/mpeg", duration:3.29 },
michael@0 200 // One second of silence with ~140KB of ID3 tags. Usually when the first MP3
michael@0 201 // frame is at such a high offset into the file, MP3FrameParser will give up
michael@0 202 // and report that the stream is not MP3. However, it does not count ID3 tags
michael@0 203 // in that offset. This test case makes sure that ID3 exclusion holds.
michael@0 204 { name:"huge-id3.mp3", type:"audio/mpeg", duration:1.00 },
michael@0 205 // A truncated VBR MP3 with just enough frames to keep most decoders happy.
michael@0 206 // The Xing header reports the length of the file to be around 10 seconds, but
michael@0 207 // there is really only one second worth of data. We want MP3FrameParser to
michael@0 208 // trust the header, so this should be reported as 10 seconds.
michael@0 209 { name:"vbr-head.mp3", type:"audio/mpeg", duration:10.00 },
michael@0 210
michael@0 211 // Invalid file
michael@0 212 { name:"bogus.duh", type:"bogus/duh", duration:Number.NaN }
michael@0 213 ];
michael@0 214
michael@0 215 // A file for each type we can support.
michael@0 216 var gSnifferTests = [
michael@0 217 { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444 },
michael@0 218 { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.233, size:28942 },
michael@0 219 { name:"seek.webm", type:"video/webm", duration:3.966, size:215529 },
michael@0 220 { name:"gizmo.mp4", type:"video/mp4", duration:5.56, size:383631 },
michael@0 221 // A mp3 file with id3 tags.
michael@0 222 { name:"id3tags.mp3", type:"audio/mpeg", duration:0.28, size:3530},
michael@0 223 { name:"bogus.duh", type:"bogus/duh" }
michael@0 224 ];
michael@0 225
michael@0 226 // Files we must reject as invalid.
michael@0 227 var gInvalidTests = [
michael@0 228 { name:"invalid-m0c0.opus", type:"audio/ogg; codecs=opus"},
michael@0 229 { name:"invalid-m0c3.opus", type:"audio/ogg; codecs=opus"},
michael@0 230 { name:"invalid-m1c0.opus", type:"audio/ogg; codecs=opus"},
michael@0 231 { name:"invalid-m1c9.opus", type:"audio/ogg; codecs=opus"},
michael@0 232 { name:"invalid-m2c0.opus", type:"audio/ogg; codecs=opus"},
michael@0 233 { name:"invalid-m2c1.opus", type:"audio/ogg; codecs=opus"},
michael@0 234 { name:"invalid-cmap-short.opus", type:"audio/ogg; codecs=opus"},
michael@0 235 { name:"invalid-cmap-s0c0.opus", type:"audio/ogg; codecs=opus"},
michael@0 236 { name:"invalid-cmap-s0c2.opus", type:"audio/ogg; codecs=opus"},
michael@0 237 { name:"invalid-cmap-s1c2.opus", type:"audio/ogg; codecs=opus"},
michael@0 238 { name:"invalid-preskip.webm", type:"audio/webm; codecs=opus"},
michael@0 239 ];
michael@0 240
michael@0 241 // Converts a path/filename to a file:// URI which we can load from disk.
michael@0 242 // Optionally checks whether the file actually exists on disk at the location
michael@0 243 // we've specified.
michael@0 244 function fileUriToSrc(path, mustExist) {
michael@0 245 // android mochitest doesn't support file://
michael@0 246 if (navigator.appVersion.indexOf("Android") != -1 || SpecialPowers.Services.appinfo.name == "B2G")
michael@0 247 return path;
michael@0 248
michael@0 249 const Ci = SpecialPowers.Ci;
michael@0 250 const Cc = SpecialPowers.Cc;
michael@0 251 const Cr = SpecialPowers.Cr;
michael@0 252 var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
michael@0 253 getService(Ci.nsIProperties);
michael@0 254 var f = dirSvc.get("CurWorkD", Ci.nsILocalFile);
michael@0 255 var split = path.split("/");
michael@0 256 for(var i = 0; i < split.length; ++i) {
michael@0 257 f.append(split[i]);
michael@0 258 }
michael@0 259 if (mustExist && !f.exists()) {
michael@0 260 ok(false, "We expected '" + path + "' to exist, but it doesn't!");
michael@0 261 }
michael@0 262 return f.path;
michael@0 263 }
michael@0 264
michael@0 265 // Returns true if two TimeRanges are equal, false otherwise
michael@0 266 function range_equals(r1, r2) {
michael@0 267 if (r1.length != r2.length) {
michael@0 268 return false;
michael@0 269 }
michael@0 270 for (var i = 0; i < r1.length; i++) {
michael@0 271 if (r1.start(i) != r2.start(i) || r1.end(i) != r2.end(i)) {
michael@0 272 return false;
michael@0 273 }
michael@0 274 }
michael@0 275 return true;
michael@0 276 }
michael@0 277
michael@0 278 // These are URIs to files that we use to check that we don't leak any state
michael@0 279 // or other information such that script can determine stuff about a user's
michael@0 280 // environment. Used by test_info_leak.
michael@0 281 var gInfoLeakTests = [
michael@0 282 {
michael@0 283 type: 'video/ogg',
michael@0 284 src: fileUriToSrc("tests/content/media/test/320x240.ogv", true),
michael@0 285 },{
michael@0 286 type: 'video/ogg',
michael@0 287 src: fileUriToSrc("tests/content/media/test/404.ogv", false),
michael@0 288 }, {
michael@0 289 type: 'audio/x-wav',
michael@0 290 src: fileUriToSrc("tests/content/media/test/r11025_s16_c1.wav", true),
michael@0 291 }, {
michael@0 292 type: 'audio/x-wav',
michael@0 293 src: fileUriToSrc("tests/content/media/test/404.wav", false),
michael@0 294 }, {
michael@0 295 type: 'audio/ogg',
michael@0 296 src: fileUriToSrc("tests/content/media/test/bug461281.ogg", true),
michael@0 297 }, {
michael@0 298 type: 'audio/ogg',
michael@0 299 src: fileUriToSrc("tests/content/media/test/404.ogg", false),
michael@0 300 }, {
michael@0 301 type: 'video/webm',
michael@0 302 src: fileUriToSrc("tests/content/media/test/seek.webm", true),
michael@0 303 }, {
michael@0 304 type: 'video/webm',
michael@0 305 src: fileUriToSrc("tests/content/media/test/404.webm", false),
michael@0 306 }, {
michael@0 307 type: 'video/ogg',
michael@0 308 src: 'http://localhost/404.ogv',
michael@0 309 }, {
michael@0 310 type: 'audio/x-wav',
michael@0 311 src: 'http://localhost/404.wav',
michael@0 312 }, {
michael@0 313 type: 'video/webm',
michael@0 314 src: 'http://localhost/404.webm',
michael@0 315 }, {
michael@0 316 type: 'video/ogg',
michael@0 317 src: 'http://example.com/tests/content/media/test/test_info_leak.html'
michael@0 318 }, {
michael@0 319 type: 'audio/ogg',
michael@0 320 src: 'http://example.com/tests/content/media/test/test_info_leak.html'
michael@0 321 }
michael@0 322 ];
michael@0 323
michael@0 324 // These are files that must fire an error during load or playback, and do not
michael@0 325 // cause a crash. Put files of the same type together in this list so if
michael@0 326 // something crashes we have some idea of which backend is responsible. Used
michael@0 327 // by test_playback_errors, which expects one error event and no ended event.
michael@0 328 // Put files of the same type together in this list so if something crashes
michael@0 329 // we have some idea of which backend is responsible.
michael@0 330 var gErrorTests = [
michael@0 331 { name:"bogus.wav", type:"audio/x-wav" },
michael@0 332 { name:"bogus.ogv", type:"video/ogg" },
michael@0 333 { name:"448636.ogv", type:"video/ogg" },
michael@0 334 { name:"bug504843.ogv", type:"video/ogg" },
michael@0 335 { name:"bug501279.ogg", type:"audio/ogg" },
michael@0 336 { name:"bug580982.webm", type:"video/webm" },
michael@0 337 { name:"bug603918.webm", type:"video/webm" },
michael@0 338 { name:"bug604067.webm", type:"video/webm" },
michael@0 339 { name:"bogus.duh", type:"bogus/duh" }
michael@0 340 ];
michael@0 341
michael@0 342 // These are files that have nontrivial duration and are useful for seeking within.
michael@0 343 var gSeekTests = [
michael@0 344 { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
michael@0 345 { name:"audio.wav", type:"audio/x-wav", duration:0.031247 },
michael@0 346 { name:"seek.ogv", type:"video/ogg", duration:3.966 },
michael@0 347 { name:"320x240.ogv", type:"video/ogg", duration:0.266 },
michael@0 348 { name:"seek.webm", type:"video/webm", duration:3.966 },
michael@0 349 { name:"bug516323.indexed.ogv", type:"video/ogg", duration:4.208333 },
michael@0 350 { name:"split.webm", type:"video/webm", duration:1.967 },
michael@0 351 { name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
michael@0 352 { name:"gizmo.mp4", type:"video/mp4", duration:5.56 },
michael@0 353 { name:"owl.mp3", type:"audio/mpeg", duration:3.29 },
michael@0 354 { name:"bogus.duh", type:"bogus/duh", duration:123 }
michael@0 355 ];
michael@0 356
michael@0 357 var gFastSeekTests = [
michael@0 358 { name:"gizmo.mp4", type:"video/mp4", keyframes:[0, 1.0, 2.0, 3.0, 4.0, 5.0 ] },
michael@0 359 // Note: Not all keyframes in the file are actually referenced in the Cues in this file.
michael@0 360 { name:"seek.webm", type:"video/webm", keyframes:[0, 0.8, 1.6, 2.4, 3.2]},
michael@0 361 // Note: the sync points are the points on both the audio and video streams
michael@0 362 // before the keyframes. You can't just assume that the keyframes are the sync
michael@0 363 // points, as the audio required for that sync point may be before the keyframe.
michael@0 364 { name:"bug516323.indexed.ogv", type:"video/ogg", keyframes:[0, 0.46, 3.06] },
michael@0 365 ];
michael@0 366
michael@0 367 function IsWindows8OrLater() {
michael@0 368 var re = /Windows NT (\d.\d)/;
michael@0 369 var winver = navigator.userAgent.match(re);
michael@0 370 return winver && winver.length == 2 && parseFloat(winver[1]) >= 6.2;
michael@0 371 }
michael@0 372
michael@0 373 // These are files that are non seekable, due to problems with the media,
michael@0 374 // for example broken or missing indexes.
michael@0 375 var gUnseekableTests = [
michael@0 376 { name:"no-cues.webm", type:"video/webm" },
michael@0 377 { name:"bogus.duh", type:"bogus/duh"}
michael@0 378 ];
michael@0 379 // Unfortunately big-buck-bunny-unseekable.mp4 is doesn't play on Windows 7, so
michael@0 380 // only include it in the unseekable tests if we're on later versions of Windows.
michael@0 381 // This test actually only passes on win8 at the moment.
michael@0 382 if (navigator.userAgent.indexOf("Windows") != -1 && IsWindows8OrLater()) {
michael@0 383 gUnseekableTests = gUnseekableTests.concat([
michael@0 384 { name:"big-buck-bunny-unseekable.mp4", type:"video/mp4" }
michael@0 385 ]);
michael@0 386 }
michael@0 387 // Android supports fragmented MP4 playback from 4.3.
michael@0 388 var androidVersion = SpecialPowers.Cc['@mozilla.org/system-info;1']
michael@0 389 .getService(SpecialPowers.Ci.nsIPropertyBag2)
michael@0 390 .getProperty('version');
michael@0 391 // Fragmented MP4.
michael@0 392 if (navigator.userAgent.indexOf("Mobile") != -1 && androidVersion >= 18) {
michael@0 393 gUnseekableTests = gUnseekableTests.concat([
michael@0 394 { name:"street.mp4", type:"video/mp4" }
michael@0 395 ]);
michael@0 396 }
michael@0 397
michael@0 398 // These are files suitable for using with a "new Audio" constructor.
michael@0 399 var gAudioTests = [
michael@0 400 { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
michael@0 401 { name:"sound.ogg", type:"audio/ogg" },
michael@0 402 { name:"owl.mp3", type:"audio/mpeg", duration:3.29 },
michael@0 403 { name:"small-shot.m4a", type:"audio/mp4", duration:0.29 },
michael@0 404 { name:"bogus.duh", type:"bogus/duh", duration:123 }
michael@0 405 ];
michael@0 406
michael@0 407 // These files ensure our handling of 404 errors is consistent across the
michael@0 408 // various backends.
michael@0 409 var g404Tests = [
michael@0 410 { name:"404.wav", type:"audio/x-wav" },
michael@0 411 { name:"404.ogv", type:"video/ogg" },
michael@0 412 { name:"404.oga", type:"audio/ogg" },
michael@0 413 { name:"404.webm", type:"video/webm" },
michael@0 414 { name:"bogus.duh", type:"bogus/duh" }
michael@0 415 ];
michael@0 416
michael@0 417 // These are files suitable for testing various decoder failures that are
michael@0 418 // expected to fire MEDIA_ERR_DECODE. Used by test_decode_error, which expects
michael@0 419 // an error and emptied event, and no loadedmetadata or ended event.
michael@0 420 var gDecodeErrorTests = [
michael@0 421 // Valid files with unsupported codecs
michael@0 422 { name:"r11025_msadpcm_c1.wav", type:"audio/x-wav" },
michael@0 423 { name:"dirac.ogg", type:"video/ogg" },
michael@0 424 // Invalid files
michael@0 425 { name:"bogus.wav", type:"audio/x-wav" },
michael@0 426 { name:"bogus.ogv", type:"video/ogg" },
michael@0 427
michael@0 428 { name:"bogus.duh", type:"bogus/duh" }
michael@0 429 ];
michael@0 430
michael@0 431 // These are files that are used for media fragments tests
michael@0 432 var gFragmentTests = [
michael@0 433 { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444 }
michael@0 434 ];
michael@0 435
michael@0 436 // Used by test_chaining.html. The |links| attributes is the number of links in
michael@0 437 // this file that we should be able to play.
michael@0 438 var gChainingTests = [
michael@0 439 // Vorbis and Opus chained file. They have user comments |index=n| where `n`
michael@0 440 // is the index of this segment in the file, 0 indexed.
michael@0 441 { name:"chain.ogg", type:"audio/ogg", links: 4},
michael@0 442 { name:"chain.opus", type:"audio/ogg; codec=opus", links: 4},
michael@0 443 // Those files are chained files with a different number of channels in each
michael@0 444 // part. This is not supported and should stop playing after the first part.
michael@0 445 { name:"variable-channel.ogg", type:"audio/ogg", links: 1 },
michael@0 446 { name:"variable-channel.opus", type:"audio/ogg; codec=opus", links: 1 },
michael@0 447 // Those files are chained files with a different sample rate in each
michael@0 448 // part. This is not supported and should stop playing after the first part.
michael@0 449 { name:"variable-samplerate.ogg", type:"audio/ogg", links: 1 },
michael@0 450 // Opus decoding in Firefox outputs 48 kHz PCM despite having a different
michael@0 451 // original sample rate, so we can safely play Opus chained media that have
michael@0 452 // different samplerate accross links.
michael@0 453 { name:"variable-samplerate.opus", type:"audio/ogg; codec=opus", links: 2 },
michael@0 454 // A chained video file. We don't support those, so only one link should be
michael@0 455 // reported.
michael@0 456 { name:"chained-video.ogv", type:"video/ogg", links: 1 },
michael@0 457 // A file that consist in 4 links of audio, then another link that has video.
michael@0 458 // We should stop right after the 4 audio links.
michael@0 459 { name:"chained-audio-video.ogg", type:"video/ogg", links: 4 },
michael@0 460 // An opus file that has two links, with a different preskip value for each
michael@0 461 // link. We should be able to play both links.
michael@0 462 { name:"variable-preskip.opus", type:"audio/ogg; codec=opus", links: 2 },
michael@0 463 { name:"bogus.duh", type:"bogus/duh" }
michael@0 464 ];
michael@0 465
michael@0 466 // Videos with an aspect ratio. Used for testing that displaying frames
michael@0 467 // on a canvas works correctly in the case of non-standard aspect ratios.
michael@0 468 // See bug 874897 for an example.
michael@0 469 var gAspectRatioTests = [
michael@0 470 { name:"VID_0001.ogg", type:"video/ogg", duration:19.966 }
michael@0 471 ];
michael@0 472
michael@0 473 // These are files with non-trivial tag sets.
michael@0 474 // Used by test_metadata.html.
michael@0 475 var gMetadataTests = [
michael@0 476 // Ogg Vorbis files
michael@0 477 { name:"short-video.ogv", tags: {
michael@0 478 TITLE:"Lepidoptera",
michael@0 479 ARTIST:"Epoq",
michael@0 480 ALBUM:"Kahvi Collective",
michael@0 481 DATE:"2002",
michael@0 482 COMMENT:"http://www.kahvi.org",
michael@0 483 }
michael@0 484 },
michael@0 485 { name:"bug516323.ogv", tags: {
michael@0 486 GENRE:"Open Movie",
michael@0 487 ENCODER:"Audacity",
michael@0 488 TITLE:"Elephants Dream",
michael@0 489 ARTIST:"Silvia Pfeiffer",
michael@0 490 COMMENTS:"Audio Description"
michael@0 491 }
michael@0 492 },
michael@0 493 { name:"bug516323.indexed.ogv", tags: {
michael@0 494 GENRE:"Open Movie",
michael@0 495 ENCODER:"Audacity",
michael@0 496 TITLE:"Elephants Dream",
michael@0 497 ARTIST:"Silvia Pfeiffer",
michael@0 498 COMMENTS:"Audio Description"
michael@0 499 }
michael@0 500 },
michael@0 501 { name:"detodos.opus", tags: {
michael@0 502 title:"De todos. Para todos.",
michael@0 503 artist:"Mozilla.org"
michael@0 504 }
michael@0 505 },
michael@0 506 { name:"sound.ogg", tags: { } },
michael@0 507 { name:"small-shot.ogg", tags: {
michael@0 508 title:"Pew SFX"
michael@0 509 }
michael@0 510 },
michael@0 511 { name:"badtags.ogg", tags: {
michael@0 512 // We list only the valid tags here, and verify
michael@0 513 // the invalid ones are filtered out.
michael@0 514 title:"Invalid comments test file",
michael@0 515 empty:"",
michael@0 516 "":"empty",
michael@0 517 "{- [(`!@\"#$%^&')] -}":"valid tag name, surprisingly"
michael@0 518 // The file also includes the following invalid tags.
michael@0 519 // "A description with no separator is a common problem.",
michael@0 520 // "雨":"Likely, but an invalid key (non-ascii).",
michael@0 521 // "not\nval\x1fid":"invalid tag name",
michael@0 522 // "not~valid":"this isn't a valid name either",
michael@0 523 // "not-utf-8":"invalid sequences: \xff\xfe\xfa\xfb\0eol"
michael@0 524 }
michael@0 525 },
michael@0 526 { name:"wave_metadata.wav", tags: {
michael@0 527 name:"Track Title",
michael@0 528 artist:"Artist Name",
michael@0 529 comments:"Comments",
michael@0 530 }
michael@0 531 },
michael@0 532 { name:"wave_metadata_utf8.wav", tags: {
michael@0 533 name:"歌曲名稱",
michael@0 534 artist:"作曲者",
michael@0 535 comments:"註解",
michael@0 536 }
michael@0 537 },
michael@0 538 { name:"wave_metadata_unknown_tag.wav", tags: {
michael@0 539 name:"Track Title",
michael@0 540 comments:"Comments",
michael@0 541 }
michael@0 542 },
michael@0 543 { name:"wave_metadata_bad_len.wav", tags: {
michael@0 544 name:"Track Title",
michael@0 545 artist:"Artist Name",
michael@0 546 }
michael@0 547 },
michael@0 548 { name:"wave_metadata_bad_no_null.wav", tags: {
michael@0 549 name:"Track Title",
michael@0 550 artist:"Artist Name",
michael@0 551 comments:"Comments!!",
michael@0 552 }
michael@0 553 },
michael@0 554 { name:"wave_metadata_bad_utf8.wav", tags: {
michael@0 555 name:"歌曲名稱",
michael@0 556 comments:"註解",
michael@0 557 }
michael@0 558 },
michael@0 559 { name:"wavedata_u8.wav", tags: { }
michael@0 560 },
michael@0 561 ];
michael@0 562
michael@0 563 function checkMetadata(msg, e, test) {
michael@0 564 if (test.width) {
michael@0 565 is(e.videoWidth, test.width, msg + " video width");
michael@0 566 }
michael@0 567 if (test.height) {
michael@0 568 is(e.videoHeight, test.height, msg + " video height");
michael@0 569 }
michael@0 570 if (test.duration) {
michael@0 571 ok(Math.abs(e.duration - test.duration) < 0.1,
michael@0 572 msg + " duration (" + e.duration + ") should be around " + test.duration);
michael@0 573 }
michael@0 574 }
michael@0 575
michael@0 576 // Returns the first test from candidates array which we can play with the
michael@0 577 // installed video backends.
michael@0 578 function getPlayableVideo(candidates) {
michael@0 579 var v = document.createElement("video");
michael@0 580 var resources = candidates.filter(function(x){return /^video/.test(x.type) && v.canPlayType(x.type);});
michael@0 581 if (resources.length > 0)
michael@0 582 return resources[0];
michael@0 583 return null;
michael@0 584 }
michael@0 585
michael@0 586 function getPlayableAudio(candidates) {
michael@0 587 var v = document.createElement("audio");
michael@0 588 var resources = candidates.filter(function(x){return /^audio/.test(x.type) && v.canPlayType(x.type);});
michael@0 589 if (resources.length > 0)
michael@0 590 return resources[0];
michael@0 591 return null;
michael@0 592 }
michael@0 593
michael@0 594 // Returns the type of element that should be created for the given mimetype.
michael@0 595 function getMajorMimeType(mimetype) {
michael@0 596 if (/^video/.test(mimetype)) {
michael@0 597 return "video";
michael@0 598 } else {
michael@0 599 return "audio";
michael@0 600 }
michael@0 601 }
michael@0 602
michael@0 603 function removeNodeAndSource(n) {
michael@0 604 n.remove();
michael@0 605 // force release of underlying decoder
michael@0 606 n.src = "";
michael@0 607 while (n.firstChild) {
michael@0 608 n.removeChild(n.firstChild);
michael@0 609 }
michael@0 610 }
michael@0 611
michael@0 612 // Number of tests to run in parallel. Warning: Each media element requires
michael@0 613 // at least 3 threads (4 on Linux), and on Linux each thread uses 10MB of
michael@0 614 // virtual address space. Beware!
michael@0 615 var PARALLEL_TESTS = 2;
michael@0 616
michael@0 617 // When true, we'll loop forever on whatever test we run. Use this to debug
michael@0 618 // intermittent test failures.
michael@0 619 const DEBUG_TEST_LOOP_FOREVER = false;
michael@0 620
michael@0 621 // Manages a run of media tests. Runs them in chunks in order to limit
michael@0 622 // the number of media elements/threads running in parallel. This limits peak
michael@0 623 // memory use, particularly on Linux x86 where thread stacks use 10MB of
michael@0 624 // virtual address space.
michael@0 625 // Usage:
michael@0 626 // 1. Create a new MediaTestManager object.
michael@0 627 // 2. Create a test startTest function. This takes a test object and a token,
michael@0 628 // and performs anything necessary to start the test. The test object is an
michael@0 629 // element in one of the g*Tests above. Your startTest function must call
michael@0 630 // MediaTestManager.start(token) if it starts a test. The test object is
michael@0 631 // guaranteed to be playable by our supported decoders; you don't need to
michael@0 632 // check canPlayType.
michael@0 633 // 3. When your tests finishes, call MediaTestManager.finished(), passing
michael@0 634 // the token back to the manager. The manager may either start the next run
michael@0 635 // or end the mochitest if all the tests are done.
michael@0 636 function MediaTestManager() {
michael@0 637
michael@0 638 // Sets up a MediaTestManager to runs through the 'tests' array, which needs
michael@0 639 // to be one of, or have the same fields as, the g*Test arrays of tests. Uses
michael@0 640 // the user supplied 'startTest' function to initialize the test. This
michael@0 641 // function must accept two arguments, the test entry from the 'tests' array,
michael@0 642 // and a token. Call MediaTestManager.started(token) if you start the test,
michael@0 643 // and MediaTestManager.finished(token) when the test finishes. You don't have
michael@0 644 // to start every test, but if you call started() you *must* call finish()
michael@0 645 // else you'll timeout.
michael@0 646 this.runTests = function(tests, startTest) {
michael@0 647 this.startTime = new Date();
michael@0 648 SimpleTest.info("Started " + this.startTime + " (" + this.startTime.getTime()/1000 + "s)");
michael@0 649 this.testNum = 0;
michael@0 650 this.tests = tests;
michael@0 651 this.startTest = startTest;
michael@0 652 this.tokens = [];
michael@0 653 this.isShutdown = false;
michael@0 654 this.numTestsRunning = 0;
michael@0 655 // Always wait for explicit finish.
michael@0 656 SimpleTest.waitForExplicitFinish();
michael@0 657 this.nextTest();
michael@0 658 }
michael@0 659
michael@0 660 // Registers that the test corresponding to 'token' has been started.
michael@0 661 // Don't call more than once per token.
michael@0 662 this.started = function(token) {
michael@0 663 this.tokens.push(token);
michael@0 664 this.numTestsRunning++;
michael@0 665 is(this.numTestsRunning, this.tokens.length, "[started " + token + "] Length of array should match number of running tests");
michael@0 666 }
michael@0 667
michael@0 668 // Registers that the test corresponding to 'token' has finished. Call when
michael@0 669 // you've finished your test. If all tests are complete this will finish the
michael@0 670 // run, otherwise it may start up the next run. It's ok to call multiple times
michael@0 671 // per token.
michael@0 672 this.finished = function(token) {
michael@0 673 var i = this.tokens.indexOf(token);
michael@0 674 if (i != -1) {
michael@0 675 // Remove the element from the list of running tests.
michael@0 676 this.tokens.splice(i, 1);
michael@0 677 }
michael@0 678 this.numTestsRunning--;
michael@0 679 is(this.numTestsRunning, this.tokens.length, "[finished " + token + "] Length of array should match number of running tests");
michael@0 680 if (this.tokens.length < PARALLEL_TESTS) {
michael@0 681 this.nextTest();
michael@0 682 }
michael@0 683 }
michael@0 684
michael@0 685 // Starts the next batch of tests, or finishes if they're all done.
michael@0 686 // Don't call this directly, call finished(token) when you're done.
michael@0 687 this.nextTest = function() {
michael@0 688 // Force an exact GC after every completed testcase. This ensures that any
michael@0 689 // decoders with live threads waiting for the GC are killed promptly, to free
michael@0 690 // up the thread stacks' address space, and destroy decoder resources.
michael@0 691 SpecialPowers.exactGC(window, function(){
michael@0 692 while (this.testNum < this.tests.length && this.tokens.length < PARALLEL_TESTS) {
michael@0 693 var test = this.tests[this.testNum];
michael@0 694 var token = (test.name ? (test.name + "-"): "") + this.testNum;
michael@0 695 this.testNum++;
michael@0 696
michael@0 697 if (DEBUG_TEST_LOOP_FOREVER && this.testNum == this.tests.length) {
michael@0 698 this.testNum = 0;
michael@0 699 }
michael@0 700
michael@0 701 // Ensure we can play the resource type.
michael@0 702 if (test.type && !document.createElement('video').canPlayType(test.type))
michael@0 703 continue;
michael@0 704
michael@0 705 // Do the init. This should start the test.
michael@0 706 this.startTest(test, token);
michael@0 707 }
michael@0 708
michael@0 709 if (this.testNum == this.tests.length &&
michael@0 710 !DEBUG_TEST_LOOP_FOREVER &&
michael@0 711 this.tokens.length == 0 &&
michael@0 712 !this.isShutdown)
michael@0 713 {
michael@0 714 this.isShutdown = true;
michael@0 715 if (this.onFinished) {
michael@0 716 this.onFinished();
michael@0 717 }
michael@0 718 mediaTestCleanup();
michael@0 719 var end = new Date();
michael@0 720 SimpleTest.info("Finished at " + end + " (" + (end.getTime() / 1000) + "s)");
michael@0 721 SimpleTest.info("Running time: " + (end.getTime() - this.startTime.getTime())/1000 + "s");
michael@0 722 SimpleTest.finish();
michael@0 723 return;
michael@0 724 }
michael@0 725 }.bind(this));
michael@0 726 }
michael@0 727 }
michael@0 728
michael@0 729 // Ensures we've got no active video or audio elements in the document, and
michael@0 730 // forces a GC to release the address space reserved by the decoders' threads'
michael@0 731 // stacks.
michael@0 732 function mediaTestCleanup() {
michael@0 733 var V = document.getElementsByTagName("video");
michael@0 734 for (i=0; i<V.length; i++) {
michael@0 735 removeNodeAndSource(V[i]);
michael@0 736 V[i] = null;
michael@0 737 }
michael@0 738 var A = document.getElementsByTagName("audio");
michael@0 739 for (i=0; i<A.length; i++) {
michael@0 740 removeNodeAndSource(A[i]);
michael@0 741 A[i] = null;
michael@0 742 }
michael@0 743 SpecialPowers.forceGC();
michael@0 744 }
michael@0 745
michael@0 746 (function() {
michael@0 747 // Ensure that preload preferences are comsistent
michael@0 748 var prefService = SpecialPowers.wrap(SpecialPowers.Components)
michael@0 749 .classes["@mozilla.org/preferences-service;1"]
michael@0 750 .getService(SpecialPowers.Ci.nsIPrefService);
michael@0 751 var branch = prefService.getBranch("media.");
michael@0 752 var oldDefault = 2;
michael@0 753 var oldAuto = 3;
michael@0 754 var oldAppleMedia = undefined;
michael@0 755 var oldGStreamer = undefined;
michael@0 756 var oldOpus = undefined;
michael@0 757
michael@0 758 try { oldAppleMedia = SpecialPowers.getBoolPref("media.apple.mp3.enabled"); } catch(ex) { }
michael@0 759 try { oldGStreamer = SpecialPowers.getBoolPref("media.gstreamer.enabled"); } catch(ex) { }
michael@0 760 try { oldDefault = SpecialPowers.getIntPref("media.preload.default"); } catch(ex) { }
michael@0 761 try { oldAuto = SpecialPowers.getIntPref("media.preload.auto"); } catch(ex) { }
michael@0 762 try { oldOpus = SpecialPowers.getBoolPref("media.opus.enabled"); } catch(ex) { }
michael@0 763
michael@0 764 SpecialPowers.setIntPref("media.preload.default", 2); // preload_metadata
michael@0 765 SpecialPowers.setIntPref("media.preload.auto", 3); // preload_enough
michael@0 766 // test opus playback iff the pref exists
michael@0 767 if (oldOpus !== undefined)
michael@0 768 SpecialPowers.setBoolPref("media.opus.enabled", true);
michael@0 769 if (oldGStreamer !== undefined)
michael@0 770 SpecialPowers.setBoolPref("media.gstreamer.enabled", true);
michael@0 771 if (oldAppleMedia !== undefined)
michael@0 772 SpecialPowers.setBoolPref("media.apple.mp3.enabled", true);
michael@0 773
michael@0 774 window.addEventListener("unload", function() {
michael@0 775 if (oldGStreamer !== undefined)
michael@0 776 SpecialPowers.setBoolPref("media.gstreamer.enabled", oldGStreamer);
michael@0 777 if (oldAppleMedia !== undefined)
michael@0 778 SpecialPowers.setBoolPref("media.apple.mp3.enabled", oldAppleMedia);
michael@0 779 SpecialPowers.setIntPref("media.preload.default", oldDefault);
michael@0 780 SpecialPowers.setIntPref("media.preload.auto", oldAuto);
michael@0 781 if (oldOpus !== undefined)
michael@0 782 SpecialPowers.setBoolPref("media.opus.enabled", oldOpus);
michael@0 783 }, false);
michael@0 784 })();

mercurial