Bug 1465409 - Change lint rules for mediasource tests to prefer no spaces for array notation. r=jya

Change rules so we enforce ["foo", "bar"] rather than [ "foo", "bar" ].

MozReview-Commit-ID: KX6wJd8jmeJ

--HG--
extra : rebase_source : 6800cf4e701a33f246418e0deb35a206af8104f4
This commit is contained in:
Bryce Van Dyk 2018-05-30 08:18:54 -04:00
Родитель 62a134a580
Коммит c9d6056854
39 изменённых файлов: 104 добавлений и 104 удалений

Просмотреть файл

@ -23,7 +23,7 @@ module.exports = {
},
// Use const/let instead of var for tighter scoping, avoiding redeclaration
"rules": {
"array-bracket-spacing": ["error", "always"],
"array-bracket-spacing": ["error", "never"],
"no-var": "error",
"prefer-const": "error"
}

Просмотреть файл

@ -1,9 +1,9 @@
// Helpers for Media Source Extensions tests
let gMSETestPrefs = [
[ "media.mediasource.enabled", true ],
[ "media.audio-max-decode-error", 0 ],
[ "media.video-max-decode-error", 0 ],
["media.mediasource.enabled", true],
["media.audio-max-decode-error", 0],
["media.video-max-decode-error", 0],
];
// Called before runWithMSE() to set the prefs before running MSE tests.
@ -187,8 +187,8 @@ async function waitUntilTime(target, targetTime) {
// Log events for debugging.
function logEvents(el) {
[ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
"waiting", "pause", "durationchange", "seeking",
"seeked" ].forEach(type => el.addEventListener(type, e => info(`got ${e.type} event`)));
"seeked"].forEach(type => el.addEventListener(type, e => info(`got ${e.type} event`)));
}

Просмотреть файл

@ -18,7 +18,7 @@ runWithMSE(async (ms, el) => {
ok(true, "Receive a sourceopen event");
const videosb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(videosb, "avc3/init", [ "" ], ".mp4");
await fetchAndLoad(videosb, "avc3/init", [""], ".mp4");
const p = once(el, "loadeddata");
await fetchAndLoad(videosb, "avc3/segment", range(1, 2), ".m4s");
await p;

Просмотреть файл

@ -27,16 +27,16 @@ runWithMSE(async (ms, el) => {
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
let p = once(el, "loadedmetadata");
await fetchAndLoad(audiosb, "aac20-48000-64000-", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "aac20-48000-64000-", ["init"], ".mp4");
await p;
ok(true, "got loadedmetadata event");
p = Promise.all([ once(el, "loadeddata"), once(el, "canplay") ]);
await fetchAndLoad(audiosb, "aac20-48000-64000-", [ "1" ], ".m4s");
p = Promise.all([once(el, "loadeddata"), once(el, "canplay")]);
await fetchAndLoad(audiosb, "aac20-48000-64000-", ["1"], ".m4s");
await p;
ok(true, "got canplay event");
el.play();
await fetchAndLoad(audiosb, "aac51-48000-128000-", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "aac51-48000-128000-", [ "2" ], ".m4s");
await fetchAndLoad(audiosb, "aac51-48000-128000-", ["init"], ".mp4");
await fetchAndLoad(audiosb, "aac51-48000-128000-", ["2"], ".m4s");
ms.endOfStream();
await once(el, "ended");
ok(el.currentTime >= 6, "played to the end");

Просмотреть файл

@ -22,23 +22,23 @@ runWithMSE(async (ms, v) => {
ok(false, "Got Error: " + e);
SimpleTest.finish();
});
await fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop", [ "1" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop", [ "2" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop", ["init"], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop", ["1"], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop", ["2"], ".m4s");
/* Note - Missing |bipbop3| segment here corresponding to (1.62, 2.41] */
/* Note - Missing |bipbop4| segment here corresponding to (2.41, 3.20] */
await fetchAndLoad(sb, "bipbop/bipbop", [ "5" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop", ["5"], ".m4s");
// last audio sample has a start time of 1.578956s
info("Playing video. It should play for a bit, then fire 'waiting'");
v.play();
await waitUntilTime(v, 1.57895);
const firstStop = Date.now();
await fetchAndLoad(sb, "bipbop/bipbop", [ "3" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop", ["3"], ".m4s");
// last audio sample has a start time of 2.368435
await waitUntilTime(v, 2.36843);
const waitDuration = (Date.now() - firstStop) / 1000;
ok(waitDuration < 15, `Should not spend inordinate amount of time buffering: ${waitDuration}`);
await fetchAndLoad(sb, "bipbop/bipbop", [ "4" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop", ["4"], ".m4s");
ms.endOfStream();
await once(v, "ended");
SimpleTest.finish();

Просмотреть файл

@ -11,7 +11,7 @@
SimpleTest.waitForExplicitFinish();
async function setupTest() {
await SpecialPowers.pushPrefEnv({"set": [ [ "media.mediasource.experimental.enabled", true ] ]});
await SpecialPowers.pushPrefEnv({"set": [["media.mediasource.experimental.enabled", true]]});
}
setupTest();
@ -19,9 +19,9 @@ runWithMSE(function(ms, el) {
el.controls = true;
once(ms, "sourceopen").then(function() {
// Log events for debugging.
const events = [ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
"waiting", "pause", "durationchange", "seeking", "seeked" ];
const events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
"waiting", "pause", "durationchange", "seeking", "seeked"];
function logEvent(e) {
info("got " + e.type + " event");
}
@ -42,7 +42,7 @@ runWithMSE(function(ms, el) {
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
const loadedmetadataPromises = [];
loadedmetadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop", [ "init" ], ".mp4"));
loadedmetadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop", ["init"], ".mp4"));
loadedmetadataPromises.push(once(el, "loadedmetadata"));
Promise.all(loadedmetadataPromises)
.then(function() {
@ -57,7 +57,7 @@ runWithMSE(function(ms, el) {
ok(true, "got canplay event");
el.play();
videosb.timestampOffset = el.buffered.end(0);
return fetchAndLoad(videosb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4");
return fetchAndLoad(videosb, "bipbop/bipbop_480_624kbps-video", ["init"], ".mp4");
})
.then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
.then(function() {
@ -69,7 +69,7 @@ runWithMSE(function(ms, el) {
SimpleTest.finish();
throw e;
}
return fetchAndLoad(videosb, "bipbop/bipbop_300-3s", [ "" ], ".webm");
return fetchAndLoad(videosb, "bipbop/bipbop_300-3s", [""], ".webm");
})
.then(function() {
ms.endOfStream();

Просмотреть файл

@ -16,15 +16,15 @@ runWithMSE(async (ms, el) => {
await once(ms, "sourceopen");
ok(true, "Receive a sourceopen event");
const sb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", ["init"], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s");
el.play();
// let seek to the last audio frame.
// The seek will complete and then playback will stall.
el.currentTime = 1.532517;
await Promise.all([ once(el, "seeked"), once(el, "waiting") ]);
await Promise.all([once(el, "seeked"), once(el, "waiting")]);
info("seek completed");
await fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop", ["init"], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop", range(1, 4), ".m4s");
ms.endOfStream();
await once(el, "ended");

Просмотреть файл

@ -16,11 +16,11 @@ runWithMSE(async (ms, el) => {
await once(ms, "sourceopen");
ok(true, "Receive a sourceopen event");
const videosb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
// Set appendWindowEnd to ensure we only have about 6 frames worth.
// We must feed at least 6 frames to pass the MDSM pre-roll.
videosb.appendWindowEnd = .4;
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "1" ], ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["1"], ".m4s");
info("Invoking play()");
const p = once(el, "playing");
await el.play();
@ -33,7 +33,7 @@ runWithMSE(async (ms, el) => {
isfuzzy(el.currentTime, videosb.buffered.end(0) - 1 / 30,
0.04, `Got a waiting event at ${el.currentTime}`);
videosb.appendWindowEnd = 1;
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ 1 ], ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [1], ".m4s");
ms.endOfStream();
await once(el, "ended");
// These fuzz factors are bigger than they should be. We should investigate

Просмотреть файл

@ -18,7 +18,7 @@ runWithMSE(async (ms, v) => {
const arrayBuffer = await fetchWithXHR("seek.webm");
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
await Promise.all([ once(v, "loadedmetadata"), once(sb, "updateend") ]);
await Promise.all([once(v, "loadedmetadata"), once(sb, "updateend")]);
is(v.duration, ms.duration, "video duration is mediasource one");
must_not_throw(() => ms.duration = 0, "duration = 0 is valid initially");
is(v.duration, 0, "reducing duration with no data buffered is valid");

Просмотреть файл

@ -23,7 +23,7 @@ runWithMSE(async (ms, v) => {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
// Adding the first init segment will fire a durationchange.
await Promise.all([ once(sb, "updateend"), once(v, "loadedmetadata") ]);
await Promise.all([once(sb, "updateend"), once(v, "loadedmetadata")]);
ok(true, "got loadedmetadata");
// Set mediasource duration to 0, so future appendBuffer
// will update the mediasource duration.

Просмотреть файл

@ -23,7 +23,7 @@ runWithMSE(async (ms, v) => {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
// Adding the first init segment will fire a durationchange.
await Promise.all([ once(sb, "updateend"), once(v, "loadedmetadata") ]);
await Promise.all([once(sb, "updateend"), once(v, "loadedmetadata")]);
ok(true, "got loadedmetadata");
// Set mediasource duration to 0, so future appendBuffer
// will update the mediasource duration.

Просмотреть файл

@ -16,8 +16,8 @@ SimpleTest.waitForExplicitFinish();
// as the auto-eviction would succeed (removing all data prior currentTime)
addMSEPrefs(
[ "media.mediasource.eviction_threshold.audio", 524288 ],
[ "media.dormant-on-pause-timeout-ms", -1 ] // FIXME: bug 1319292
["media.mediasource.eviction_threshold.audio", 524288],
["media.dormant-on-pause-timeout-ms", -1] // FIXME: bug 1319292
);
runWithMSE(async (ms, el) => {
@ -26,7 +26,7 @@ runWithMSE(async (ms, el) => {
ok(true, "Receive a sourceopen event");
const audiosb = ms.addSourceBuffer("audio/mp4");
audiosb.mode = "sequence";
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
const audioBuffer = await fetchWithXHR("bipbop/bipbop_audio1.m4s");
await must_reject(async () => {

Просмотреть файл

@ -12,9 +12,9 @@
SimpleTest.waitForExplicitFinish();
addMSEPrefs(
[ "media.mediasource.eviction_threshold.audio", 524288 ],
[ "media.dormant-on-pause-timeout-ms", -1 ], // FIXME: bug 1319292
[ "media.mediasource.experimental.enabled", true ]
["media.mediasource.eviction_threshold.audio", 524288],
["media.dormant-on-pause-timeout-ms", -1], // FIXME: bug 1319292
["media.mediasource.experimental.enabled", true]
);
// We fill up the source buffer with audio data until the buffer is full.

Просмотреть файл

@ -41,7 +41,7 @@ runWithMSE(async (ms, v) => {
ms.endOfStream();
info("Seeking to t=3");
p = Promise.all([ once(v, "seeked"), once(v, "resize") ]);
p = Promise.all([once(v, "seeked"), once(v, "resize")]);
v.currentTime = 3;
await p;
is(v.currentTime, 3, "Video currentTime at target");
@ -49,7 +49,7 @@ runWithMSE(async (ms, v) => {
is(v.videoHeight, 120, "videoHeight has correct low-res value");
info("Seeking to t=1");
p = Promise.all([ once(v, "seeked"), once(v, "resize") ]);
p = Promise.all([once(v, "seeked"), once(v, "resize")]);
v.currentTime = 1;
await p;
is(v.currentTime, 1, "Video currentTime at target");

Просмотреть файл

@ -25,7 +25,7 @@ runWithMSE(async (ms, v) => {
ok(false, `should not fire ${e.type} event`);
SimpleTest.finish();
});
await fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop", ["init"], ".mp4");
const p = once(v, "loadeddata");
await fetchAndLoad(sb, "bipbop/bipbop", range(1, 3), ".m4s");
await p;
@ -33,12 +33,12 @@ runWithMSE(async (ms, v) => {
v.play();
// We have nothing to play, waiting will be fired.
await waitUntilTime(v, 1.5);
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", ["init"], ".mp4");
sb.timestampOffset = 1.601666; // End of the video track buffered - time of first video sample (0.095).
sb.appendWindowEnd = 1.796677; // Only allow room for three extra video frames (we need 3 as this video has b-frames).
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "1" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", ["1"], ".m4s");
ms.endOfStream();
await Promise.all([ once(ms, "sourceended"), once(v, "playing"), once(v, "ended") ]);
await Promise.all([once(ms, "sourceended"), once(v, "playing"), once(v, "ended")]);
if (v.width, 640, "has proper width");
if (v.height, 480, "has proper height");
SimpleTest.finish();

Просмотреть файл

@ -20,7 +20,7 @@ runWithMSE(async (ms, v) => {
// and seekable range start.
sb.timestampOffset = 2;
const p = once(v, "loadedmetadata");
await fetchAndLoad(sb, "seek", [ "" ], ".webm");
await fetchAndLoad(sb, "seek", [""], ".webm");
await p;
ms.duration = Infinity;
sb.abort();

Просмотреть файл

@ -29,7 +29,7 @@ runWithMSE(async (ms, el) => {
const videosb = ms.addSourceBuffer("video/mp4");
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
let p = once(el, "loadedmetadata");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await p;
videosb.appendWindowStart = 2;
videosb.appendWindowEnd = 4;

Просмотреть файл

@ -21,7 +21,7 @@ function test() {
SpecialPowers.pushPrefEnv({"set":
[
[ "media.mediasource.enabled", false ],
["media.mediasource.enabled", false],
]
}, test);

Просмотреть файл

@ -19,7 +19,7 @@ runWithMSE(async (ms, el) => {
const sb = ms.addSourceBuffer("audio/mp4; codecs=\"flac\"");
ok(sb, "Create a SourceBuffer");
await fetchAndLoad(sb, "flac/IS", [ "" ], ".mp4");
await fetchAndLoad(sb, "flac/IS", [""], ".mp4");
await fetchAndLoad(sb, "flac/0000", range(1, 3), ".m4s");
el.play();
ms.endOfStream();

Просмотреть файл

@ -16,7 +16,7 @@ runWithMSE(async (ms, v) => {
// Load a webm video and play it.
await once(ms, "sourceopen");
const sb = ms.addSourceBuffer("video/webm");
await fetchAndLoad(sb, "seek", [ "" ], ".webm");
await fetchAndLoad(sb, "seek", [""], ".webm");
const p = once(v, "ended");
ms.endOfStream();
v.play();

Просмотреть файл

@ -19,10 +19,10 @@ runWithMSE(async (ms, v) => {
const seek_lowres = await fetchWithXHR("seek_lowres.webm");
const seek = await fetchWithXHR("seek.webm");
const data = [
[ seek_lowres, 0, 438 ], // lowres init segment
[ seek_lowres, 438, 25950 ], // lowres media segment 0-1
[ seek, 0, 318 ], // init segment
[ seek, 46712, 67833 ] // media segment 0.8-1.201
[seek_lowres, 0, 438], // lowres init segment
[seek_lowres, 438, 25950], // lowres media segment 0-1
[seek, 0, 318], // init segment
[seek, 46712, 67833] // media segment 0.8-1.201
];
const length = data.map(d => d[2] - d[1]).reduce((a, b) => a + b, 0);
const arrayBuffer = new Uint8Array(length);

Просмотреть файл

@ -19,7 +19,7 @@ runWithMSE(async (ms, v) => {
const init = new Uint8Array(await fetchWithXHR("bipbop/bipbop_videoinit.mp4"));
const segment1 = new Uint8Array(await fetchWithXHR("bipbop/bipbop_video1.m4s"));
const segment2 = new Uint8Array(await fetchWithXHR("bipbop/bipbop_video2.m4s"));
const data = [ init, segment1, init, segment2 ];
const data = [init, segment1, init, segment2];
const length = data.map(d => d.byteLength).reduce((a, b) => a + b, 0);
const arrayBuffer = new Uint8Array(length);
let pos = 0;

Просмотреть файл

@ -15,24 +15,24 @@ SimpleTest.waitForExplicitFinish();
runWithMSE(async (ms, v) => {
const receiveEvent = e => v["got" + e] = true;
const msevents = [ "onsourceopen", "onsourceended" ];
const msevents = ["onsourceopen", "onsourceended"];
msevents.forEach(e => ms[e] = () => receiveEvent(e));
const sblistevents = [ "onaddsourcebuffer", "onremovesourcebuffer" ];
const sblistevents = ["onaddsourcebuffer", "onremovesourcebuffer"];
sblistevents.forEach(e => ms.sourceBuffers[e] = () => receiveEvent(e));
await once(ms, "sourceopen");
const sb = ms.addSourceBuffer("video/webm");
const sbevents = [ "onupdatestart", "onupdate", "onupdateend", "onabort" ];
const sbevents = ["onupdatestart", "onupdate", "onupdateend", "onabort"];
sbevents.forEach(e => sb[e] = () => receiveEvent(e));
await fetchAndLoad(sb, "seek", [ "" ], ".webm");
await fetchAndLoad(sb, "seek", [""], ".webm");
sb.appendBuffer(await fetchWithXHR("seek.webm"));
ms.removeSourceBuffer(sb); // will fire abort and removesourcebuffer
ms.endOfStream(); // will fire sourceended
await once(ms, "sourceended");
[ ...msevents, ...sbevents, ...sblistevents ].forEach(e => ok(v["got" + e], "got " + e));
[...msevents, ...sbevents, ...sblistevents].forEach(e => ok(v["got" + e], "got " + e));
SimpleTest.finish();
});

Просмотреть файл

@ -33,10 +33,10 @@ runWithMSE(async (ms, el) => {
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
let p = once(el, "loadedmetadata");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await p;
ok(true, "got loadedmetadata event");
p = Promise.all([ once(el, "loadeddata"), once(el, "canplay") ]);
p = Promise.all([once(el, "loadeddata"), once(el, "canplay")]);
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s");
await p;
ok(true, "got canplay event");
@ -64,7 +64,7 @@ runWithMSE(async (ms, el) => {
ok(true, "got seeking event");
is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
// Load [6+0, 6+1.601666)
p = Promise.all([ once(el, "seeked"), once(el, "canplay") ]);
p = Promise.all([once(el, "seeked"), once(el, "canplay")]);
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s");
await p;
ok(true, "got seeked and canplay event");
@ -94,7 +94,7 @@ runWithMSE(async (ms, el) => {
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(3, 5), ".m4s");
ok(true, "data loaded");
// Playback we play for a little while then stall.
p = Promise.all([ once(el, "playing"), once(el, "waiting") ]);
p = Promise.all([once(el, "playing"), once(el, "waiting")]);
el.play();
await p;
ok(true, "got playing and waiting event");
@ -102,7 +102,7 @@ runWithMSE(async (ms, el) => {
is(el.readyState, el.HAVE_CURRENT_DATA, "readyState is HAVE_CURRENT_DATA");
// Load [15+3.203333, 15+4.805)
// Our final buffered range will now be [0, 3.203333)[6, 9.203333)[15, 19.805)
p = Promise.all([ once(el, "playing"), once(el, "canplay"), once(el, "canplaythrough") ]);
p = Promise.all([once(el, "playing"), once(el, "canplay"), once(el, "canplaythrough")]);
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 7), ".m4s");
await p;
ok(true, "got playing, canplay and canplaythrough event");

Просмотреть файл

@ -39,12 +39,12 @@ runWithMSE(async (ms, el) => {
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
let p = once(el, "loadedmetadata");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await p;
ok(true, "got loadedmetadata event");
// We're only adding 1.6s worth of data, not enough for readyState to change to HAVE_ENOUGH_DATA
// So we end the media source so that all the playable data is available.
p = Promise.all([ "loadeddata", "canplay", "play", "playing", "ended" ].map(e => once(el, e)));
p = Promise.all(["loadeddata", "canplay", "play", "playing", "ended"].map(e => once(el, e)));
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s");
ms.endOfStream();
await p;

Просмотреть файл

@ -39,13 +39,13 @@ runWithMSE(async (ms, el) => {
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
let p = once(el, "loadedmetadata");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await p;
ok(true, "got loadedmetadata event");
// We shift the timestamps slightly to create a small gaps at the start.
// one that should normally be ignored.
videosb.timestampOffset = 0.1;
p = Promise.all([ "loadeddata", "canplay", "play", "playing" ].map(e => once(el, e)));
p = Promise.all(["loadeddata", "canplay", "play", "playing"].map(e => once(el, e)));
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 14), ".m4s");
await p;
ok(true, "got all required event");

Просмотреть файл

@ -21,7 +21,7 @@ runWithMSE(async (ms, v) => {
ok(false, "Got Error: " + e);
SimpleTest.finish();
});
await fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop", ["init"], ".mp4");
let p = once(v, "loadeddata");
await fetchAndLoad(sb, "bipbop/bipbop", range(1, 3), ".m4s");
await p;
@ -35,7 +35,7 @@ runWithMSE(async (ms, v) => {
await fetchAndLoad(sb, "bipbop/bipbop", range(1, 4), ".m4s");
await p;
ms.endOfStream();
await Promise.all([ once(ms, "sourceended"), once(v, "ended") ]);
await Promise.all([once(ms, "sourceended"), once(v, "ended")]);
SimpleTest.finish(SimpleTest);
});
</script>

Просмотреть файл

@ -27,8 +27,8 @@ runWithMSE(async (ms, el) => {
is(el.currentTime, 3, "currentTime is default playback start position");
is(el.seeking, false, "seek not started with HAVE_NOTHING");
await Promise.all([
fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4"),
fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"),
fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4"),
fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4"),
once(el, "loadedmetadata")
]);
const p = once(el, "seeking");

Просмотреть файл

@ -19,15 +19,15 @@ runWithMSE(async (ms, el) => {
const videosb = ms.addSourceBuffer("video/mp4");
const audiosb = ms.addSourceBuffer("audio/mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
is(videosb.buffered.length, 1, "continuous buffered range");
// Ensure we have at least 2s less audio than video.
audiosb.appendWindowEnd = videosb.buffered.end(0) - 2;
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 6), ".m4s");
ms.endOfStream();
await Promise.all([ once(el, "durationchange"), once(ms, "sourceended") ]);
await Promise.all([once(el, "durationchange"), once(ms, "sourceended")]);
ok(true, "endOfStream completed");
// Seek to the middle of the gap where audio is missing. As we are in readyState = ended
// seeking must complete.

Просмотреть файл

@ -16,7 +16,7 @@ runWithMSE(async (ms, el) => {
await once(ms, "sourceopen");
ok(true, "Receive a sourceopen event");
const sb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", ["init"], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s");
el.play();
// let seek to the last audio frame.

Просмотреть файл

@ -18,10 +18,10 @@ runWithMSE(async (ms, el) => {
ok(true, "Receive a sourceopen event");
const audiosb = ms.addSourceBuffer("audio/mp4");
const videosb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(7, 14), ".m4s");
let p = once(el, "seeking");

Просмотреть файл

@ -14,7 +14,7 @@ SimpleTest.waitForExplicitFinish();
runWithMSE(async (ms, el) => {
el.controls = true;
const events = [ "seeked", "loadeddata", "playing" ];
const events = ["seeked", "loadeddata", "playing"];
let eventCount = 0;
events.forEach(type => el.addEventListener(type,
() => is(events[eventCount++], type, "events must come in order")));
@ -23,20 +23,20 @@ runWithMSE(async (ms, el) => {
const videosb = ms.addSourceBuffer("video/mp4");
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
let p = once(el, "loadedmetadata");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await p;
el.play();
videosb.timestampOffset = 2;
is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
// Load [2, 3.606).
p = once(el, "play");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "1" ], ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["1"], ".m4s");
await p;
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "2" ], ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["2"], ".m4s");
// TODO: readyState should be at least HAVE_CURRENTDATA, see bug 1367993.
ok(el.readyState >= el.HAVE_METADATA, "readyState is HAVE_METADATA");
el.currentTime = 2;
await Promise.all([ once(el, "seeked"), once(el, "playing") ]);
await Promise.all([once(el, "seeked"), once(el, "playing")]);
ok(true, "completed seek");
is(eventCount, events.length, "Received expected number of events");
SimpleTest.finish();

Просмотреть файл

@ -23,9 +23,9 @@ runWithMSE(async (ms, v) => {
});
sb.mode = "sequence";
await fetchAndLoad(sb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop_video", [ "5" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop_video", [ "2" ], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(sb, "bipbop/bipbop_video", ["5"], ".m4s");
await fetchAndLoad(sb, "bipbop/bipbop_video", ["2"], ".m4s");
is(v.buffered.length, 1, "Continuous buffered range");
is(v.buffered.start(0), 0, "Buffered range starts at 0");
ok(sb.timestampOffset > 0, "SourceBuffer.timestampOffset set to allow continuous range");

Просмотреть файл

@ -19,9 +19,9 @@ runWithMSE(async (ms, el) => {
await once(ms, "sourceopen");
ok(true, "Receive a sourceopen event");
const videosb = ms.addSourceBuffer("video/mp4");
const vchunks = [ {start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666} ];
const vchunks = [{start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666}];
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s");
// We will insert a gap of threshold
videosb.timestampOffset = threshold;

Просмотреть файл

@ -25,13 +25,13 @@ runWithMSE(async (ms, el) => {
// chunk 1: segments 5-8
// chunk 2: segments 9-13
// We then fill the timeline so that it seamlessly plays the chunks in order 0, 2, 1.
const vchunks = [ {start: 0, end: 3.2033},
const vchunks = [{start: 0, end: 3.2033},
{ start: 3.2033, end: 6.4066},
{ start: 6.4066, end: 10.01} ];
{ start: 6.4066, end: 10.01}];
const firstvoffset = vchunks[2].end - vchunks[2].start; // Duration of chunk 2
const secondvoffset = -(vchunks[1].end - vchunks[1].start); // -(Duration of chunk 1)
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s");
is(videosb.buffered.length, 1, "No discontinuity");
isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "Chunk start");
@ -49,7 +49,7 @@ runWithMSE(async (ms, el) => {
isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "Chunk start");
isfuzzy(videosb.buffered.end(0), vchunks[2].end, eps, "Chunk end");
audiosb.timestampOffset = 3;
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 12), ".m4s");
is(audiosb.buffered.length, 1, "No audio discontinuity");
isfuzzy(audiosb.buffered.start(0), 3, eps, "Audio starts at 3");
@ -67,7 +67,7 @@ runWithMSE(async (ms, el) => {
el.play();
el.currentTime = el.buffered.start(0);
ms.endOfStream();
await Promise.all([ once(el, "ended"), once(el, "seeked") ]);
await Promise.all([once(el, "ended"), once(el, "seeked")]);
SimpleTest.finish();
});

Просмотреть файл

@ -20,12 +20,12 @@ runWithMSE(async (ms, el) => {
SimpleTest.finish();
});
const videosb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(6, 8), ".m4s");
is(el.buffered.length, 2, "discontinuous buffered range");
ms.endOfStream();
await Promise.all([ once(el, "durationchange"), once(ms, "sourceended") ]);
await Promise.all([once(el, "durationchange"), once(ms, "sourceended")]);
// HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM
// has notified it of available data. Make sure that we get "playing" before
// we starting waiting for "waiting".

Просмотреть файл

@ -17,10 +17,10 @@ runWithMSE(async (ms, el) => {
ok(true, "Receive a sourceopen event");
const audiosb = ms.addSourceBuffer("audio/mp4");
const videosb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(7, 14), ".m4s");
// HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM
@ -43,8 +43,8 @@ runWithMSE(async (ms, el) => {
info("Loading more data");
p = once(el, "ended");
await Promise.all([
fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ 5 ], ".m4s"),
fetchAndLoad(videosb, "bipbop/bipbop_video", [ 6 ], ".m4s")
fetchAndLoad(audiosb, "bipbop/bipbop_audio", [5], ".m4s"),
fetchAndLoad(videosb, "bipbop/bipbop_video", [6], ".m4s")
]);
ms.endOfStream();
await p;

Просмотреть файл

@ -21,8 +21,8 @@ runWithMSE(async (ms, el) => {
// always fired (bug 1233639).
audiosb.appendWindowEnd = 3.9;
videosb.appendWindowEnd = 3.9;
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s");
// HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM

Просмотреть файл

@ -12,7 +12,7 @@
SimpleTest.waitForExplicitFinish();
addMSEPrefs([ "media.mediasource.webm.enabled", true ]);
addMSEPrefs(["media.mediasource.webm.enabled", true]);
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {