new file mode 100644
--- /dev/null
+++ b/dom/media/mediasource/test/.eslintrc.js
@@ -0,0 +1,25 @@
+"use strict";
+
+module.exports = {
+ // Extend mochitest rules
+ "extends": "plugin:mozilla/mochitest-test",
+ // Globals from mediasource.js. We use false to indicate they should not
+ // be overwritten in scripts.
+ "globals": {
+ "addMSEPrefs": false,
+ "fetchAndLoad": false,
+ "fetchAndLoadAsync": false,
+ "fetchWithXHR": false,
+ "loadSegment": false,
+ "once": false,
+ "range": false,
+ "runWithMSE": false,
+ "waitUntilTime": false
+ },
+ // Use const/let instead of var for tighter scoping, avoiding redeclaration
+ "rules": {
+ "array-bracket-spacing": ["error", "always"],
+ "no-var": "error",
+ "prefer-const": "error"
+ }
+};
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -1,161 +1,161 @@
// Helpers for Media Source Extensions tests
-var gMSETestPrefs = [
+let gMSETestPrefs = [
[ "media.mediasource.enabled", true ],
- ['media.audio-max-decode-error', 0],
- ['media.video-max-decode-error', 0],
+ [ "media.audio-max-decode-error", 0 ],
+ [ "media.video-max-decode-error", 0 ],
];
// Called before runWithMSE() to set the prefs before running MSE tests.
function addMSEPrefs(...prefs) {
gMSETestPrefs = gMSETestPrefs.concat(prefs);
}
function runWithMSE(testFunction) {
function bootstrapTest() {
- var ms = new MediaSource();
+ const ms = new MediaSource();
- var el = document.createElement("video");
+ const el = document.createElement("video");
el.src = URL.createObjectURL(ms);
el.preload = "auto";
document.body.appendChild(el);
- SimpleTest.registerCleanupFunction(function () {
+ SimpleTest.registerCleanupFunction(function() {
el.remove();
el.removeAttribute("src");
el.load();
});
testFunction(ms, el);
}
- addLoadEvent(function () {
+ addLoadEvent(function() {
SpecialPowers.pushPrefEnv({"set": gMSETestPrefs}, bootstrapTest);
});
}
function fetchWithXHR(uri, onLoadFunction) {
- var p = new Promise(function(resolve, reject) {
- var xhr = new XMLHttpRequest();
+ const p = new Promise(function(resolve, reject) {
+ const xhr = new XMLHttpRequest();
xhr.open("GET", uri, true);
xhr.responseType = "arraybuffer";
- xhr.addEventListener("load", function () {
+ xhr.addEventListener("load", function() {
is(xhr.status, 200, "fetchWithXHR load uri='" + uri + "' status=" + xhr.status);
resolve(xhr.response);
});
xhr.send();
});
if (onLoadFunction) {
p.then(onLoadFunction);
}
return p;
-};
+}
function range(start, end) {
- var rv = [];
- for (var i = start; i < end; ++i) {
+ const rv = [];
+ for (let i = start; i < end; ++i) {
rv.push(i);
}
return rv;
}
function once(target, name, cb) {
- var p = new Promise(function(resolve, reject) {
+ const p = new Promise(function(resolve, reject) {
target.addEventListener(name, function() {
resolve();
}, {once: true});
});
if (cb) {
p.then(cb);
}
return p;
}
function timeRangeToString(r) {
- var str = "TimeRanges: ";
- for (var i = 0; i < r.length; i++) {
+ let str = "TimeRanges: ";
+ for (let i = 0; i < r.length; i++) {
str += "[" + r.start(i) + ", " + r.end(i) + ")";
}
return str;
}
function loadSegment(sb, typedArrayOrArrayBuffer) {
- var typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
- : typedArrayOrArrayBuffer;
+ const typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
+ : typedArrayOrArrayBuffer;
info(`Loading buffer: [${typedArray.byteOffset}, ${typedArray.byteOffset + typedArray.byteLength})`);
- var beforeBuffered = timeRangeToString(sb.buffered);
+ const beforeBuffered = timeRangeToString(sb.buffered);
return new Promise(function(resolve, reject) {
- once(sb, 'update').then(function() {
- var afterBuffered = timeRangeToString(sb.buffered);
+ once(sb, "update").then(function() {
+ const afterBuffered = timeRangeToString(sb.buffered);
info(`SourceBuffer buffered ranges grew from ${beforeBuffered} to ${afterBuffered}`);
resolve();
});
sb.appendBuffer(typedArray);
});
}
function fetchAndLoad(sb, prefix, chunks, suffix) {
// Fetch the buffers in parallel.
- var buffers = {};
- var fetches = [];
- for (var chunk of chunks) {
+ const buffers = {};
+ const fetches = [];
+ for (const chunk of chunks) {
fetches.push(fetchWithXHR(prefix + chunk + suffix).then(((c, x) => buffers[c] = x).bind(null, chunk)));
}
// Load them in series, as required per spec.
return Promise.all(fetches).then(function() {
- var rv = Promise.resolve();
- for (var chunk of chunks) {
+ let rv = Promise.resolve();
+ for (const chunk of chunks) {
rv = rv.then(loadSegment.bind(null, sb, buffers[chunk]));
}
return rv;
});
}
function loadSegmentAsync(sb, typedArrayOrArrayBuffer) {
- var typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
- : typedArrayOrArrayBuffer;
+ const typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
+ : typedArrayOrArrayBuffer;
info(`Loading buffer2: [${typedArray.byteOffset}, ${typedArray.byteOffset + typedArray.byteLength})`);
- var beforeBuffered = timeRangeToString(sb.buffered);
+ const beforeBuffered = timeRangeToString(sb.buffered);
return sb.appendBufferAsync(typedArray).then(() => {
- var afterBuffered = timeRangeToString(sb.buffered);
+ const afterBuffered = timeRangeToString(sb.buffered);
info(`SourceBuffer buffered ranges grew from ${beforeBuffered} to ${afterBuffered}`);
});
}
function fetchAndLoadAsync(sb, prefix, chunks, suffix) {
// Fetch the buffers in parallel.
- var buffers = {};
- var fetches = [];
- for (var chunk of chunks) {
+ const buffers = {};
+ const fetches = [];
+ for (const chunk of chunks) {
fetches.push(fetchWithXHR(prefix + chunk + suffix).then(((c, x) => buffers[c] = x).bind(null, chunk)));
}
// Load them in series, as required per spec.
return Promise.all(fetches).then(function() {
- var rv = Promise.resolve();
- for (var chunk of chunks) {
+ let rv = Promise.resolve();
+ for (const chunk of chunks) {
rv = rv.then(loadSegmentAsync.bind(null, sb, buffers[chunk]));
}
return rv;
});
}
-//Register timeout function to dump debugging logs.
+// Register timeout function to dump debugging logs.
SimpleTest.registerTimeoutFunction(function() {
- for (var v of document.getElementsByTagName("video")) {
+ for (const v of document.getElementsByTagName("video")) {
v.mozDumpDebugInfo();
}
- for (var a of document.getElementsByTagName("audio")) {
+ for (const a of document.getElementsByTagName("audio")) {
a.mozDumpDebugInfo();
}
});
function waitUntilTime(target, targetTime) {
return new Promise(function(resolve, reject) {
target.addEventListener("waiting", function onwaiting() {
info("Got a waiting event at " + target.currentTime);
--- a/dom/media/mediasource/test/test_AVC3_mp4.html
+++ b/dom/media/mediasource/test/test_AVC3_mp4.html
@@ -9,36 +9,36 @@
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
- fetchAndLoad(videosb, 'avc3/init', [''], '.mp4')
+ fetchAndLoad(videosb, "avc3/init", [ "" ], ".mp4")
.then(function() {
- var promises = [];
- promises.push(fetchAndLoad(videosb, 'avc3/segment', range(1, 2), '.m4s'));
+ const promises = [];
+ promises.push(fetchAndLoad(videosb, "avc3/segment", range(1, 2), ".m4s"));
promises.push(once(el, "loadeddata"));
return Promise.all(promises);
}).then(function() {
is(videosb.buffered.length, 1, "continuous buffered range");
ok(true, "got loadeddata");
ms.endOfStream();
return once(ms, "sourceended");
}).then(function() {
ok(true, "endOfStream completed");
// Now ensure that we can play to the end.
el.play();
- once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+ once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
});
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_AppendPartialInitSegment.html
+++ b/dom/media/mediasource/test/test_AppendPartialInitSegment.html
@@ -7,21 +7,21 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", async function (arrayBuffer) {
+ fetchWithXHR("seek.webm", async function(arrayBuffer) {
// init segment is total 236 bytes.
info("- append partial init segment -");
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 100));
info("- wait for updateend -");
await once(sb, "updateend");
info("- append remaining init segment -");
--- a/dom/media/mediasource/test/test_AudioChange_mp4.html
+++ b/dom/media/mediasource/test/test_AudioChange_mp4.html
@@ -11,61 +11,60 @@
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
// This test checks loading a stereo segment, followed by a 5.1 segment plays without error.
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
// Log events for debugging.
- var 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) {
- var v = e.target;
info("got " + e.type + " event");
}
events.forEach(function(e) {
el.addEventListener(e, logEvent);
});
ok(true, "Receive a sourceopen event");
- var audiosb = ms.addSourceBuffer("audio/mp4");
+ const audiosb = ms.addSourceBuffer("audio/mp4");
el.addEventListener("error", function(e) {
ok(false, "should not fire '" + e.type + "' event");
SimpleTest.finish();
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(audiosb, 'aac20-48000-64000-', ['init'], '.mp4'));
- promises.push(once(el, 'loadedmetadata'));
- Promise.all(promises)
+ const loadedmetadataPromises = [];
+ loadedmetadataPromises.push(fetchAndLoad(audiosb, "aac20-48000-64000-", [ "init" ], ".mp4"));
+ loadedmetadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(loadedmetadataPromises)
.then(function() {
ok(true, "got loadedmetadata event");
- var promises = [];
- promises.push(once(el, 'loadeddata'));
- promises.push(once(el, 'canplay'));
- promises.push(fetchAndLoad(audiosb, 'aac20-48000-64000-', ['1'], '.m4s'));
- return Promise.all(promises);
+ const canplayPromises = [];
+ canplayPromises.push(once(el, "loadeddata"));
+ canplayPromises.push(once(el, "canplay"));
+ canplayPromises.push(fetchAndLoad(audiosb, "aac20-48000-64000-", [ "1" ], ".m4s"));
+ return Promise.all(canplayPromises);
})
.then(function() {
ok(true, "got canplay event");
el.play();
- return fetchAndLoad(audiosb, 'aac51-48000-128000-', ['init'], '.mp4');
+ return fetchAndLoad(audiosb, "aac51-48000-128000-", [ "init" ], ".mp4");
})
- .then(fetchAndLoad.bind(null, audiosb, 'aac51-48000-128000-', ['2'], '.m4s'))
+ .then(fetchAndLoad.bind(null, audiosb, "aac51-48000-128000-", [ "2" ], ".m4s"))
.then(function() {
ms.endOfStream();
- return once(el, 'ended');
+ return once(el, "ended");
})
.then(function() {
ok(el.currentTime >= 6, "played to the end");
SimpleTest.finish();
- })
+ });
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_AutoRevocation.html
+++ b/dom/media/mediasource/test/test_AutoRevocation.html
@@ -7,27 +7,27 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function () {
- var ms = new MediaSource();
- var o = URL.createObjectURL(ms);
- var v = document.createElement("video");
+runWithMSE(function() {
+ const ms = new MediaSource();
+ const o = URL.createObjectURL(ms);
+ const v = document.createElement("video");
- v.addEventListener("error", function (e) {
+ v.addEventListener("error", function(e) {
ok(true, "ObjectURL should be auto-revoked");
SimpleTest.finish();
});
- v.addEventListener("stalled", function (e) {
+ v.addEventListener("stalled", function(e) {
ok(false, "If auto-revocation is gone, please turn on TODOs in browser_mediaSourceURL.js");
SimpleTest.finish();
});
setTimeout(function() {
v.src = o;
v.preload = "auto";
document.body.appendChild(v);
--- a/dom/media/mediasource/test/test_BufferedSeek.html
+++ b/dom/media/mediasource/test/test_BufferedSeek.html
@@ -7,39 +7,39 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
});
- var target = 2;
+ const target = 2;
- v.addEventListener("loadedmetadata", function () {
+ v.addEventListener("loadedmetadata", function() {
ok(true, "received loadedmetadata");
v.currentTime = target;
});
- var wasSeeking = false;
+ let wasSeeking = false;
- v.addEventListener("seeking", function () {
+ v.addEventListener("seeking", function() {
wasSeeking = true;
is(v.currentTime, target, "Video currentTime at target");
});
- v.addEventListener("seeked", function () {
+ v.addEventListener("seeked", function() {
ok(wasSeeking, "Received expected seeking and seeked events");
is(v.currentTime, target, "Video currentTime at target");
SimpleTest.finish();
});
});
});
</script>
--- a/dom/media/mediasource/test/test_BufferedSeek_mp4.html
+++ b/dom/media/mediasource/test/test_BufferedSeek_mp4.html
@@ -7,39 +7,39 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
});
- var target = 1.3;
+ const target = 1.3;
- v.addEventListener("loadedmetadata", function () {
+ v.addEventListener("loadedmetadata", function() {
ok(true, "received loadedmetadata");
v.currentTime = target;
});
- var wasSeeking = false;
+ let wasSeeking = false;
- v.addEventListener("seeking", function () {
+ v.addEventListener("seeking", function() {
wasSeeking = true;
is(v.currentTime, target, "Video currentTime at target");
});
- v.addEventListener("seeked", function () {
+ v.addEventListener("seeked", function() {
ok(wasSeeking, "Received expected seeking and seeked events");
is(v.currentTime, target, "Video currentTime at target");
SimpleTest.finish();
});
});
});
</script>
--- a/dom/media/mediasource/test/test_BufferingWait.html
+++ b/dom/media/mediasource/test/test_BufferingWait.html
@@ -6,44 +6,45 @@
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
receivedSourceOpen = true;
- var sb = ms.addSourceBuffer("video/webm");
+ const sb = ms.addSourceBuffer("video/webm");
ok(sb, "Create a SourceBuffer");
fetchWithXHR("seek.webm", function(arrayBuffer) {
- sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
- loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))().then(
- loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25523-318))).then(
- loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25523, 46712-25523))).then(
+ sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+ loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))()
+ .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25523 - 318)))
+ .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25523, 46712 - 25523)))
/* Note - Missing |46712, 67833 - 46712| segment here corresponding to (0.8, 1.2] */
/* Note - Missing |67833, 88966 - 67833| segment here corresponding to (1.2, 1.6] */
- loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966))).then(function() {
+ .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966)))
+ .then(function() {
// 0.767 is the time of the last video sample +- 40ms.
- var promise = waitUntilTime(v, .767-0.04);
+ const promise = waitUntilTime(v, .767 - 0.04);
info("Playing video. It should play for a bit, then fire 'waiting'");
v.play();
return promise;
}).then(function() {
window.firstStop = Date.now();
loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712));
- return waitUntilTime(v, 1.167-0.04);
+ return waitUntilTime(v, 1.167 - 0.04);
}).then(function() {
- var waitDuration = (Date.now() - window.firstStop) / 1000;
+ const waitDuration = (Date.now() - window.firstStop) / 1000;
ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
SimpleTest.finish();
/* If we allow the rest of the stream to be played, we get stuck at
around 2s. See bug 1093133.
once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
return loadSegment(sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833));
*/
});
--- a/dom/media/mediasource/test/test_BufferingWait_mp4.html
+++ b/dom/media/mediasource/test/test_BufferingWait_mp4.html
@@ -6,49 +6,49 @@
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
receivedSourceOpen = true;
- var sb = ms.addSourceBuffer("video/mp4");
+ const sb = ms.addSourceBuffer("video/mp4");
ok(sb, "Create a SourceBuffer");
- sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
- fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['1'], '.m4s'))
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['2'], '.m4s'))
+ sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+ fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", [ "1" ], ".m4s"))
+ .then(fetchAndLoad.bind(null, 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] */
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['5'], '.m4s'))
+ .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", [ "5" ], ".m4s"))
.then(function() {
- // last audio sample has a start time of 1.578956s
- var promise = waitUntilTime(v, 1.57895);
- info("Playing video. It should play for a bit, then fire 'waiting'");
- v.play();
- return promise;
- }).then(function() {
- window.firstStop = Date.now();
- fetchAndLoad(sb, 'bipbop/bipbop', ['3'], '.m4s');
- // last audio sample has a start time of 2.368435
- return waitUntilTime(v, 2.36843);
- }).then(function() {
- var waitDuration = (Date.now() - window.firstStop) / 1000;
- ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
- once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
- return fetchAndLoad(sb, 'bipbop/bipbop', ['4'], '.m4s');
- }).then(function() {
- ms.endOfStream();
- });;
+ // last audio sample has a start time of 1.578956s
+ const promise = waitUntilTime(v, 1.57895);
+ info("Playing video. It should play for a bit, then fire 'waiting'");
+ v.play();
+ return promise;
+ }).then(function() {
+ window.firstStop = Date.now();
+ fetchAndLoad(sb, "bipbop/bipbop", [ "3" ], ".m4s");
+ // last audio sample has a start time of 2.368435
+ return waitUntilTime(v, 2.36843);
+ }).then(function() {
+ const waitDuration = (Date.now() - window.firstStop) / 1000;
+ ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
+ once(v, "ended", SimpleTest.finish.bind(SimpleTest));
+ return fetchAndLoad(sb, "bipbop/bipbop", [ "4" ], ".m4s");
+ }).then(function() {
+ ms.endOfStream();
+ });
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_ChangeType.html
+++ b/dom/media/mediasource/test/test_ChangeType.html
@@ -6,79 +6,79 @@
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
async function setupTest() {
- await SpecialPowers.pushPrefEnv({'set': [['media.mediasource.experimental.enabled', true]]});
+ await SpecialPowers.pushPrefEnv({"set": [ [ "media.mediasource.experimental.enabled", true ] ]});
}
setupTest();
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
// Log events for debugging.
- var 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");
}
events.forEach(function(e) {
el.addEventListener(e, logEvent);
});
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
- if (typeof videosb.changeType === 'undefined') {
- info('changeType API is not available');
+ const videosb = ms.addSourceBuffer("video/mp4");
+ if (typeof videosb.changeType === "undefined") {
+ info("changeType API is not available");
}
el.addEventListener("error", function(e) {
ok(false, "should not fire '" + e.type + "' event");
SimpleTest.finish();
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop', ['init'], '.mp4'));
- promises.push(once(el, 'loadedmetadata'));
- Promise.all(promises)
+ const loadedmetadataPromises = [];
+ loadedmetadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop", [ "init" ], ".mp4"));
+ loadedmetadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(loadedmetadataPromises)
.then(function() {
ok(true, "got loadedmetadata event");
- var promises = [];
- promises.push(once(el, 'loadeddata'));
- promises.push(once(el, 'canplay'));
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop', range(1,3), '.m4s'));
- return Promise.all(promises);
+ const canplayPromises = [];
+ canplayPromises.push(once(el, "loadeddata"));
+ canplayPromises.push(once(el, "canplay"));
+ canplayPromises.push(fetchAndLoad(videosb, "bipbop/bipbop", range(1, 3), ".m4s"));
+ return Promise.all(canplayPromises);
})
.then(function() {
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(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
.then(function() {
videosb.timestampOffset = el.buffered.end(0);
try {
videosb.changeType("video/webm");
} catch (e) {
ok(false, "shouldn't throw an exception");
SimpleTest.finish();
throw e;
}
- return fetchAndLoad(videosb, 'bipbop/bipbop_300-3s', [''], '.webm');
+ return fetchAndLoad(videosb, "bipbop/bipbop_300-3s", [ "" ], ".webm");
})
.then(function() {
ms.endOfStream();
- return once(el, 'ended');
+ return once(el, "ended");
})
.then(function() {
ok(el.currentTime >= el.buffered.end(0), "played to the end");
SimpleTest.finish();
});
});
});
--- a/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
@@ -8,36 +8,36 @@
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var sb = ms.addSourceBuffer("video/mp4");
- fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_480_624kbps-video', range(1, 3), '.m4s'))
+ const sb = ms.addSourceBuffer("video/mp4");
+ fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
.then(function() {
el.play();
// let seek to the last audio frame.
// The seek will complete and then playback will stall.
el.currentTime = 1.532517;
- return Promise.all([once(el, 'seeked'), once(el, 'stalled')]);
+ return Promise.all([ once(el, "seeked"), once(el, "stalled") ]);
})
.then(function() {
info("seek completed");
- return fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4');
+ return fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
})
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', range(1, 4), '.m4s'))
+ .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", range(1, 4), ".m4s"))
.then(function() {
ms.endOfStream();
- return once(el, 'ended');
+ return once(el, "ended");
}).then(function() {
SimpleTest.finish();
});
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_DrainOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_DrainOnMissingData_mp4.html
@@ -8,45 +8,45 @@
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
- fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
+ const videosb = ms.addSourceBuffer("video/mp4");
+ fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
.then(function() {
// 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;
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', ['1'], '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", [ "1" ], ".m4s");
})
.then(function() {
info("Invoking play()");
- var promises = [];
- promises.push(once(el, 'playing'));
+ const promises = [];
+ promises.push(once(el, "playing"));
el.play();
return Promise.all(promises);
})
.then(function() {
info("got playing");
- return once(el, 'waiting');
+ return once(el, "waiting");
}).then(function() {
info("got waiting");
info("Loading more data");
// Waiting will be fired on the last frame +- 40ms.
- isfuzzy(el.currentTime, videosb.buffered.end(0) - 1/30,
+ isfuzzy(el.currentTime, videosb.buffered.end(0) - 1 / 30,
0.04, "Got a waiting event at " + el.currentTime);
videosb.appendWindowEnd = 1;
- var p = once(el, 'ended');
- var loads = fetchAndLoad(videosb, 'bipbop/bipbop_video', [1], '.m4s');
+ const p = once(el, "ended");
+ const loads = fetchAndLoad(videosb, "bipbop/bipbop_video", [ 1 ], ".m4s");
loads.then(() => ms.endOfStream());
return p;
}).then(function() {
// These fuzz factors are bigger than they should be. We should investigate
// and fix them in bug 1137574.
is(el.duration, 0.801666, "Video has correct duration: " + el.duration);
is(el.currentTime, el.duration, "Video has correct currentTime.");
SimpleTest.finish();
--- a/dom/media/mediasource/test/test_DurationChange.html
+++ b/dom/media/mediasource/test/test_DurationChange.html
@@ -7,40 +7,40 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
- var promises = [];
+ const promises = [];
promises.push(once(v, "loadedmetadata"));
promises.push(once(sb, "updateend"));
Promise.all(promises)
.then(function() {
is(v.duration, ms.duration, "video duration is mediasource one");
try {
ms.duration = 0;
} catch (e) { ok(false, "must not throw as operation is valid"); }
is(v.duration, 0, "reducing duration with no data buffered is valid");
sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
// Adding more data will fire durationchange.
once(sb, "updateend")
.then(function() {
ok(true, "got updateend");
// XXX: Duration should be exactly 4.0, see bug 1065207.
ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
- var error = false;
+ let error = false;
try {
ms.duration = 0;
} catch (e) {
ok(true, "must use remove for range removal");
is(e.name, "InvalidStateError", "Error is InvalidStateError");
error = true;
}
ok(error, "got an error");
@@ -73,17 +73,17 @@ runWithMSE(function (ms, v) {
ms.duration = -1;
} catch (e) {
ok(true, "can't set a negative duration");
is(e.name, "TypeError", "Error is TypeError");
error = true;
}
ok(error, "got an error");
sb.remove(sb.buffered.end(0), Infinity);
- is(sb.updating, true, "updating is true")
+ is(sb.updating, true, "updating is true");
error = false;
try {
ms.duration = Infinity;
} catch (e) {
ok(true, "setting the duration while updating is not allowed");
is(e.name, "InvalidStateError", "Error is InvalidStateError");
error = true;
}
@@ -98,17 +98,17 @@ runWithMSE(function (ms, v) {
}
ok(error, "got an error");
is(v.duration, sb.buffered.end(0), "duration is the highest end time reported by the buffered attribute ");
once(sb, "updateend", () => ms.endOfStream());
});
});
});
});
- ms.addEventListener("sourceended", function () {
+ ms.addEventListener("sourceended", function() {
SimpleTest.finish();
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_DurationUpdated.html
+++ b/dom/media/mediasource/test/test_DurationUpdated.html
@@ -7,30 +7,30 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var durationChangeCount = 0;
+let durationChangeCount = 0;
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- v.addEventListener("durationchange", function () {
+ v.addEventListener("durationchange", function() {
durationChangeCount++;
});
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
// Adding the first init segment will fire a durationchange.
- var promises = [];
+ const promises = [];
promises.push(once(sb, "updateend"));
promises.push(once(v, "loadedmetadata"));
Promise.all(promises)
.then(function() {
ok(true, "got loadedmetadata");
// Set mediasource duration to 0, so future appendBuffer
// will update the mediasource duration.
// Changing the duration will fire a durationchange.
@@ -41,17 +41,17 @@ runWithMSE(function (ms, v) {
.then(function() {
ok(true, "got updateend");
// this will not fire durationchange as new duration == old duration
ms.endOfStream();
});
});
});
});
- ms.addEventListener("sourceended", function () {
+ ms.addEventListener("sourceended", function() {
is(durationChangeCount, 3, "durationchange not fired as many times as expected");
// XXX: Duration should be exactly 4.0, see bug 1065207.
ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
SimpleTest.finish();
});
});
</script>
--- a/dom/media/mediasource/test/test_DurationUpdated_mp4.html
+++ b/dom/media/mediasource/test/test_DurationUpdated_mp4.html
@@ -7,30 +7,30 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var durationChangeCount = 0;
+let durationChangeCount = 0;
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- v.addEventListener("durationchange", function () {
+ v.addEventListener("durationchange", function() {
durationChangeCount++;
});
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
// Adding the first init segment will fire a durationchange.
- var promises = [];
+ const promises = [];
promises.push(once(sb, "updateend"));
promises.push(once(v, "loadedmetadata"));
Promise.all(promises)
.then(function() {
ok(true, "got loadedmetadata");
// Set mediasource duration to 0, so future appendBuffer
// will update the mediasource duration.
// Changing the duration will fire a durationchange.
@@ -41,17 +41,17 @@ runWithMSE(function (ms, v) {
.then(function() {
ok(true, "got updateend");
// this will not fire durationchange as new duration == old duration
ms.endOfStream();
});
});
});
});
- ms.addEventListener("sourceended", function () {
+ ms.addEventListener("sourceended", function() {
is(durationChangeCount, 3, "durationchange not fired as many times as expected");
is(v.duration, 1.696666, "Video has correct duration");
SimpleTest.finish();
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_EndOfStream.html
+++ b/dom/media/mediasource/test/test_EndOfStream.html
@@ -7,42 +7,42 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function () {
- var ms = new MediaSource();
+runWithMSE(function() {
+ const ms = new MediaSource();
- var v = document.createElement("video");
+ const v = document.createElement("video");
v.src = URL.createObjectURL(ms);
document.body.appendChild(v);
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 88966));
- var count = 0;
- sb.addEventListener("updateend", function () {
+ let count = 0;
+ sb.addEventListener("updateend", function() {
++count;
if (count == 1) {
setTimeout(function() {
- var fail = false;
- try {
- ms.endOfStream();
- } catch (e) {
- fail = true;
- }
- ok(!fail, "MediaSource.endOfStream succeeded");
- SimpleTest.finish();
- }, 0);
+ let fail = false;
+ try {
+ ms.endOfStream();
+ } catch (e) {
+ fail = true;
+ }
+ ok(!fail, "MediaSource.endOfStream succeeded");
+ SimpleTest.finish();
+ }, 0);
}
});
});
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_EndOfStream_mp4.html
+++ b/dom/media/mediasource/test/test_EndOfStream_mp4.html
@@ -7,42 +7,42 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function () {
- var ms = new MediaSource();
+runWithMSE(function() {
+ const ms = new MediaSource();
- var v = document.createElement("video");
+ const v = document.createElement("video");
v.src = URL.createObjectURL(ms);
document.body.appendChild(v);
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
- var count = 0;
- sb.addEventListener("updateend", function () {
+ let count = 0;
+ sb.addEventListener("updateend", function() {
++count;
if (count == 1) {
setTimeout(function() {
- var fail = false;
- try {
- ms.endOfStream();
- } catch (e) {
- fail = true;
- }
- ok(!fail, "MediaSource.endOfStream succeeded");
- SimpleTest.finish();
- }, 0);
+ let fail = false;
+ try {
+ ms.endOfStream();
+ } catch (e) {
+ fail = true;
+ }
+ ok(!fail, "MediaSource.endOfStream succeeded");
+ SimpleTest.finish();
+ }, 0);
}
});
});
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_EndedEvent.html
+++ b/dom/media/mediasource/test/test_EndedEvent.html
@@ -8,18 +8,18 @@
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
- once(ms, 'sourceopen').then(function() {
- var sb = ms.addSourceBuffer("video/webm");
+ once(ms, "sourceopen").then(function() {
+ const sb = ms.addSourceBuffer("video/webm");
fetchWithXHR("seek.webm", (buf) => sb.appendBuffer(new Uint8Array(buf)));
sb.addEventListener("updateend", () => ms.endOfStream());
// Test 'ended' is fired when seeking to the end of the media
// once the duration is known.
ms.onsourceended = () => {
el.currentTime = el.duration;
};
--- a/dom/media/mediasource/test/test_Eviction_mp4.html
+++ b/dom/media/mediasource/test/test_Eviction_mp4.html
@@ -17,64 +17,64 @@ SimpleTest.waitForExplicitFinish();
// Fill up the SourceBuffer by appending data repeatedly via doAppendDataFunc until
// an exception is thrown.
function fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) {
// We are appending data repeatedly in sequence mode, there should be no gaps.
ok(sourceBuffer.buffered.length <= 1, "there should be no gap in buffered ranges.");
try {
doAppendDataFunc();
- } catch(ex) {
+ } catch (ex) {
onCaughtExceptionCallback(ex);
return;
}
- once(sourceBuffer, 'updateend', () => {
+ once(sourceBuffer, "updateend", () => {
fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback);
});
}
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(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- let audiosb = ms.addSourceBuffer("audio/mp4");
+ const audiosb = ms.addSourceBuffer("audio/mp4");
audiosb.mode = "sequence";
- fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
+ fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
.then(function() {
- fetchWithXHR('bipbop/bipbop_audio1.m4s', function(audioBuffer) {
- fillUpSourceBuffer(audiosb,
- function() { // doAppendDataFunc
- audiosb.appendBuffer(audioBuffer);
- },
- function(ex) { // onCaughtExceptionCallback
- is(ex.name, 'QuotaExceededError', "QuotaExceededError thrown");
- is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
- let seekTime = audiosb.buffered.end(0) / 2;
- el.currentTime = seekTime;
- once(el, 'seeked', () => {
- dump("dump: seeked to " + seekTime);
- is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
- try {
- audiosb.appendBuffer(audioBuffer);
- } catch(ex) {
- ok(false, "Shouldn't throw another time when data can be evicted");
- el.mozDumpDebugInfo();
- SimpleTest.finish();
- return;
- }
- once(audiosb, 'update', () => {
- ok(true, "appendBuffer succeeded");
- SimpleTest.finish();
- });
- });
+ fetchWithXHR("bipbop/bipbop_audio1.m4s", function(audioBuffer) {
+ fillUpSourceBuffer(audiosb,
+ function() { // doAppendDataFunc
+ audiosb.appendBuffer(audioBuffer);
+ },
+ function(ex1) { // onCaughtExceptionCallback
+ is(ex1.name, "QuotaExceededError", "QuotaExceededError thrown");
+ is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
+ const seekTime = audiosb.buffered.end(0) / 2;
+ el.currentTime = seekTime;
+ once(el, "seeked", () => {
+ dump("dump: seeked to " + seekTime);
+ is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
+ try {
+ audiosb.appendBuffer(audioBuffer);
+ } catch (ex2) {
+ ok(false, "Shouldn't throw another time when data can be evicted");
+ el.mozDumpDebugInfo();
+ SimpleTest.finish();
+ return;
+ }
+ once(audiosb, "update", () => {
+ ok(true, "appendBuffer succeeded");
+ SimpleTest.finish();
+ });
+ });
});
});
});
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_ExperimentalAsync.html
+++ b/dom/media/mediasource/test/test_ExperimentalAsync.html
@@ -7,92 +7,92 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
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.
// We ensure that QuotaExceededError is thrown once the buffer is full.
// We then seek to half the content. By that time, another appendBuffer must succeed
// as the auto-eviction would succeed (removing all data prior currentTime)
// The test then fills the audio buffer and plays until the end.
// Fill up the SourceBuffer by appending data repeatedly via doAppendDataFunc until
// an exception is thrown.
async function fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) {
try {
// We are appending data repeatedly in sequence mode, there should be no gaps.
- while(true) {
+ while (true) {
ok(sourceBuffer.buffered.length <= 1, "there should be no gap in buffered ranges.");
await doAppendDataFunc();
}
} catch (ex) {
ok(true, "appendBuffer promise got rejected");
onCaughtExceptionCallback(ex);
}
}
runWithMSE(async function(ms, el) {
el.controls = true;
await once(ms, "sourceopen");
ok(true, "Receive a sourceopen event");
- let audiosb = ms.addSourceBuffer("audio/mp4");
+ const audiosb = ms.addSourceBuffer("audio/mp4");
// Test removeAsync
audiosb.mode = "sequence";
- var audioInitBuffer = await fetchWithXHR("bipbop/bipbop_audioinit.mp4");
+ const audioInitBuffer = await fetchWithXHR("bipbop/bipbop_audioinit.mp4");
await audiosb.appendBufferAsync(audioInitBuffer);
- var audioBuffer = await fetchWithXHR("bipbop/bipbop_audio1.m4s");
+ const audioBuffer = await fetchWithXHR("bipbop/bipbop_audio1.m4s");
fillUpSourceBuffer(audiosb,
function() { // doAppendDataFunc
return audiosb.appendBufferAsync(audioBuffer);
},
- async function(ex) { // onCaughtExceptionCallback
- is(ex.name, "QuotaExceededError", "QuotaExceededError thrown");
+ async function(ex1) { // onCaughtExceptionCallback
+ is(ex1.name, "QuotaExceededError", "QuotaExceededError thrown");
is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
- let seekTime = audiosb.buffered.end(0) / 2;
+ const seekTime = audiosb.buffered.end(0) / 2;
el.currentTime = seekTime;
await once(el, "seeked");
dump("dump: seeked to " + seekTime);
is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
- await audiosb.appendBufferAsync(audioBuffer).catch(function(ex) {
+ await audiosb.appendBufferAsync(audioBuffer).catch(function(ex2) {
ok(false, "Shouldn't throw another time when data can be evicted");
el.mozDumpDebugInfo();
SimpleTest.finish();
});
// Test that an error in remove return a rejected promise
- await audiosb.removeAsync(5, 0).catch(async function(ex) {
+ await audiosb.removeAsync(5, 0).catch(async function(ex3) {
ok(true, "remove promise got rejected with end <= start");
- is(ex.name, "TypeError");
- await audiosb.removeAsync(ms.duration + 1, Infinity).catch(async function(ex) {
+ is(ex3.name, "TypeError");
+ await audiosb.removeAsync(ms.duration + 1, Infinity).catch(async function(ex4) {
ok(true, "remove promise got rejected with start > duration");
- is(ex.name, "TypeError");
- await audiosb.removeAsync(0, Infinity).catch(function(ex) {
+ is(ex4.name, "TypeError");
+ await audiosb.removeAsync(0, Infinity).catch(function(ex5) {
ok(false, "shouldn't throw");
});
ok(true, "remove succeeded");
is(audiosb.buffered.length, 0, "buffered should be empty");
audiosb.mode = "segment";
audiosb.timestampOffset = 0;
el.currentTime = 0;
await fetchAndLoadAsync(audiosb, "bipbop/bipbop_audio", range(1, 4), ".m4s");
ms.endOfStream();
el.play();
await once(el, "ended");
is(el.currentTime, el.duration, "played to the end");
SimpleTest.finish();
- throw ex; // ensure we don't fallback on lines below.
+ throw ex4; // ensure we don't fallback on lines below.
});
ok(false, "should have returned an error");
});
ok(false, "should have returned an error");
}
);
});
--- a/dom/media/mediasource/test/test_FrameSelection.html
+++ b/dom/media/mediasource/test/test_FrameSelection.html
@@ -7,64 +7,64 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var updateCount = 0;
+const updateCount = 0;
- var targets = [{ currentTime: 3, videoWidth: 160, videoHeight: 120 },
- { currentTime: 2, videoWidth: 160, videoHeight: 120 },
- { currentTime: 0, videoWidth: 320, videoHeight: 240 }];
- var target;
+const targets = [ { currentTime: 3, videoWidth: 160, videoHeight: 120 },
+ { currentTime: 2, videoWidth: 160, videoHeight: 120 },
+ { currentTime: 0, videoWidth: 320, videoHeight: 240 } ];
+let target;
-var lowResBuffer;
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+let lowResBuffer;
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
fetchWithXHR("seek.webm")
- .then(function (arrayBuffer) {
- var p = once(v, 'loadedmetadata');
+ .then(function(arrayBuffer) {
+ const p = once(v, "loadedmetadata");
// Append entire file covering range [0, 4].
sb.appendBuffer(new Uint8Array(arrayBuffer));
return p;
}).then(function() {
is(v.currentTime, 0, "currentTime has correct initial value");
is(v.videoWidth, 320, "videoWidth has correct initial value");
is(v.videoHeight, 240, "videoHeight has correct initial value");
return fetchWithXHR("seek_lowres.webm");
- }).then(function (arrayBuffer) {
+ }).then(function(arrayBuffer) {
// Append initialization segment.
- var p = once(sb, 'updateend');
+ const p = once(sb, "updateend");
info("Appending low-res init segment");
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438));
lowResBuffer = arrayBuffer;
return p;
}).then(function() {
- var p = once(sb, 'updateend');
+ const p = once(sb, "updateend");
info("Appending low-res range [2,4]");
// Append media segment covering range [2, 4].
sb.appendBuffer(new Uint8Array(lowResBuffer, 51003));
return p;
}).then(function() {
ms.endOfStream();
- var p = Promise.all([once(v, 'seeked'), once(v, 'resize')]);
+ const p = Promise.all([ once(v, "seeked"), once(v, "resize") ]);
info("Seeking to t=3");
v.currentTime = 3;
return p;
}).then(function() {
is(v.currentTime, 3, "Video currentTime at target");
is(v.videoWidth, 160, "videoWidth has correct low-res value");
is(v.videoHeight, 120, "videoHeight has correct low-res value");
- var p = Promise.all([once(v, 'seeked'), once(v, 'resize')]);
+ const p = Promise.all([ once(v, "seeked"), once(v, "resize") ]);
info("Seeking to t=1");
v.currentTime = 1;
return p;
}).then(function() {
is(v.currentTime, 1, "Video currentTime at target");
is(v.videoWidth, 320, "videoWidth has correct high-res value");
is(v.videoHeight, 240, "videoHeight has correct high-res value");
SimpleTest.finish();
--- a/dom/media/mediasource/test/test_FrameSelection_mp4.html
+++ b/dom/media/mediasource/test/test_FrameSelection_mp4.html
@@ -9,65 +9,64 @@
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
// This test loads partial video, plays and waits until playback stalls.
// It then loads only 3 frames of a video at higher resolution.
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
receivedSourceOpen = true;
- var sb = ms.addSourceBuffer("video/mp4");
+ const sb = ms.addSourceBuffer("video/mp4");
ok(sb, "Create a SourceBuffer");
// Log events for debugging.
- var 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) {
- var v = e.target;
info("got " + e.type + " event");
}
events.forEach(function(e) {
v.addEventListener(e, logEvent);
});
- sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
- fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4')
+ sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+ fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4")
.then(function() {
- var promises = [];
- promises.push(fetchAndLoad(sb, 'bipbop/bipbop', range(1,3), '.m4s'));
+ const promises = [];
+ promises.push(fetchAndLoad(sb, "bipbop/bipbop", range(1, 3), ".m4s"));
promises.push(once(v, "loadeddata"));
return Promise.all(promises);
}).then(function() {
is(sb.buffered.length, 1, "continuous range");
v.play();
// We have nothing to play, waiting will be fired.
return waitUntilTime(v, 1.5);
}).then(function() {
- return fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['init'], '.mp4');
+ return fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4");
}).then(function() {
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).
- return fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['1'], '.m4s');
+ return fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "1" ], ".m4s");
}).then(function() {
ms.endOfStream();
- var promises = [];
+ const promises = [];
promises.push(once(ms, "sourceended"));
promises.push(once(v, "playing"));
promises.push(once(v, "ended"));
return Promise.all(promises);
}).then(function() {
- if(v.width, 640, "has proper width");
- if(v.height, 480, "has proper height");
+ if (v.width, 640, "has proper width");
+ if (v.height, 480, "has proper height");
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek.html
+++ b/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek.html
@@ -7,39 +7,39 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 67833));
});
- var target = 2;
+ const target = 2;
v.addEventListener("loadeddata", function() {
ok(v.readyState >= v.HAVE_CURRENT_DATA, "readyState is >= CURRENT_DATA");
v.currentTime = target;
}, {once: true});
- v.addEventListener("seeking", function () {
+ v.addEventListener("seeking", function() {
is(v.readyState, v.HAVE_METADATA, "readyState is HAVE_METADATA");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 67833));
});
});
- v.addEventListener("seeked", function () {
+ v.addEventListener("seeked", function() {
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>
--- a/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek_mp4.html
+++ b/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek_mp4.html
@@ -7,44 +7,44 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
// 25819 is the offset of the first media segment's end
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25819));
});
- var target = 1.3;
+ const target = 1.3;
v.addEventListener("loadeddata", function() {
ok(v.readyState >= v.HAVE_CURRENT_DATA, "readyState is >= CURRENT_DATA");
v.currentTime = target;
}, {once: true});
- v.addEventListener("seeking", function () {
+ v.addEventListener("seeking", function() {
is(v.readyState, v.HAVE_METADATA, "readyState is HAVE_METADATA");
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
// 25819 is the offset of the first media segment's end
- sb.addEventListener("updateend", function () {
+ sb.addEventListener("updateend", function() {
ms.endOfStream();
});
sb.appendBuffer(new Uint8Array(arrayBuffer, 25819));
});
});
- v.addEventListener("seeked", function () {
+ v.addEventListener("seeked", function() {
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>
--- a/dom/media/mediasource/test/test_LiveSeekable.html
+++ b/dom/media/mediasource/test/test_LiveSeekable.html
@@ -7,24 +7,24 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
// Load data with a +2 offset so that we can distinguish buffered range start
// and seekable range start.
sb.timestampOffset = 2;
- var promises = [];
- promises.push(fetchAndLoad(sb, 'seek', [''], '.webm'));
+ const promises = [];
+ promises.push(fetchAndLoad(sb, "seek", [ "" ], ".webm"));
promises.push(once(v, "loadedmetadata"));
Promise.all(promises)
.then(function() {
ms.duration = Infinity;
sb.abort();
is(sb.buffered.length, 1, "continuous buffered range");
is(sb.buffered.start(0), 2, "buffered range start at timestamp offset");
is(sb.buffered.end(0), 6.001, "buffered range end at original duration + timestamp offset");
--- a/dom/media/mediasource/test/test_LoadedDataFired_mp4.html
+++ b/dom/media/mediasource/test/test_LoadedDataFired_mp4.html
@@ -19,48 +19,48 @@ runWithMSE(function(ms, el) {
is(el.buffered.start(0), 0, "must fire loadeddata when data has been loaded");
is(el.currentTime, 0, "must fire loadeddata at start");
});
el.addEventListener("playing", function() {
ok(el.buffered.length > 0, "data is buffered");
is(el.buffered.start(0), 0, "must fire playing when data has been loaded");
ok(el.currentTime >= 0, "must have started playback");
});
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
- promises.push(once(el, "loadedmetadata"));
- Promise.all(promises)
+ const loadedmetadataPromises = [];
+ loadedmetadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+ loadedmetadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(loadedmetadataPromises)
.then(function() {
videosb.appendWindowStart = 2;
videosb.appendWindowEnd = 4;
is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
// Load [2.4, 3.968344). 2.4 as it's the first keyframe after 2s and
// 3.968344 as the last frame ends after 4s.
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 8), '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 8), ".m4s");
})
.then(function() {
is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
// test that appendWindowEnd did its job.
ok(el.buffered.start(0) >= 2, "no data can be found prior appendWindowStart");
- ok(el.buffered.end(el.buffered.length-1) <= 4, "no data can be found beyond appendWindowEnd");
+ ok(el.buffered.end(el.buffered.length - 1) <= 4, "no data can be found beyond appendWindowEnd");
el.play();
return once(el, "play");
})
.then(function() {
videosb.appendWindowStart = 0;
- var promises = [];
+ const playingPromises = [];
// Load [0, 3.971666).
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 8), '.m4s'));
+ playingPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 8), ".m4s"));
// playback can only start now.
- promises.push(once(el, "playing"));
- return Promise.all(promises);
+ playingPromises.push(once(el, "playing"));
+ return Promise.all(playingPromises);
})
.then(function() {
ok(true, "playing");
SimpleTest.finish();
});
});
});
--- a/dom/media/mediasource/test/test_LoadedMetadataFired.html
+++ b/dom/media/mediasource/test/test_LoadedMetadataFired.html
@@ -7,28 +7,28 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- v.addEventListener("loadedmetadata", function () {
+ v.addEventListener("loadedmetadata", function() {
ok(true, "Got loadedmetadata event");
is(v.videoWidth, 320, "videoWidth has correct initial value");
is(v.videoHeight, 240, "videoHeight has correct initial value");
SimpleTest.finish();
});
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
v.play();
});
});
});
</script>
--- a/dom/media/mediasource/test/test_LoadedMetadataFired_mp4.html
+++ b/dom/media/mediasource/test/test_LoadedMetadataFired_mp4.html
@@ -7,28 +7,28 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- v.addEventListener("loadedmetadata", function () {
+ v.addEventListener("loadedmetadata", function() {
ok(true, "Got loadedmetadata event");
is(v.videoWidth, 400, "videoWidth has correct initial value");
is(v.videoHeight, 300, "videoHeight has correct initial value");
SimpleTest.finish();
});
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
v.play();
});
});
});
</script>
--- a/dom/media/mediasource/test/test_MediaSource.html
+++ b/dom/media/mediasource/test/test_MediaSource.html
@@ -7,95 +7,95 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function () {
+runWithMSE(function() {
SimpleTest.doesThrow(() => new SourceBuffer, "new SourceBuffer should fail");
SimpleTest.doesThrow(() => new SourceBufferList, "new SourceBufferList direct should fail");
- var ms = new MediaSource();
+ const ms = new MediaSource();
ok(ms, "Create a MediaSource object");
ok(ms instanceof EventTarget, "MediaSource must be an EventTarget");
is(ms.readyState, "closed", "New MediaSource must be in closed state");
// Wrapper creation, tests for leaks.
SpecialPowers.wrap(ms);
// Set an expando to force wrapper creation, tests for leaks.
ms.foo = null;
- var o = URL.createObjectURL(ms);
+ const o = URL.createObjectURL(ms);
ok(o, "Create an objectURL from the MediaSource");
- var v = document.createElement("video");
+ const v = document.createElement("video");
v.preload = "auto";
v.src = o;
document.body.appendChild(v);
- var loadedmetadataCount = 0;
- var updatestartCount = 0;
- var updateendCount = 0;
- var updateCount = 0;
+ let loadedmetadataCount = 0;
+ let updatestartCount = 0;
+ let updateendCount = 0;
+ let updateCount = 0;
ok(MediaSource.isTypeSupported("video/webm; codecs=vp8"), "VP8 MSE is always supported");
ok(MediaSource.isTypeSupported("audio/webm", "Audio MSE is always supported"));
- ms.addEventListener("sourceopen", function () {
+ ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
- var sb = ms.addSourceBuffer("video/webm");
+ const sb = ms.addSourceBuffer("video/webm");
ok(sb, "Create a SourceBuffer");
is(ms.sourceBuffers.length, 1, "MediaSource.sourceBuffers is expected length");
is(ms.sourceBuffers[0], sb, "SourceBuffer in list matches our SourceBuffer");
is(ms.activeSourceBuffers.length, 0, "MediaSource.activeSourceBuffers is expected length");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
is(sb.updating, true, "SourceBuffer.updating is expected value after appendBuffer");
});
- sb.addEventListener("update", function () {
+ sb.addEventListener("update", function() {
is(sb.updating, false, "SourceBuffer.updating is expected value in update event");
updateCount++;
/* Ensure that we endOfStream on the first update event only as endOfStream can
raise more if the duration of the last buffered range and the intial duration
differ. See bug 1065207 */
if (updateCount == 1) {
ms.endOfStream();
}
});
- sb.addEventListener("updatestart", function () {
+ sb.addEventListener("updatestart", function() {
updatestartCount++;
});
- sb.addEventListener("updateend", function () {
+ sb.addEventListener("updateend", function() {
is(ms.activeSourceBuffers[0], sb, "SourceBuffer in active list matches our SourceBuffer");
is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event");
updateendCount++;
v.play();
});
});
- ms.addEventListener("sourceended", function () {
+ ms.addEventListener("sourceended", function() {
ok(true, "Receive a sourceended event");
is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
});
- v.addEventListener("loadedmetadata", function () {
+ v.addEventListener("loadedmetadata", function() {
loadedmetadataCount++;
});
- v.addEventListener("ended", function () {
+ v.addEventListener("ended", function() {
// XXX: Duration should be exactly 4.0, see bug 1065207.
ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
// XXX: 2 update events can be received dueto duration differences, see bug 1065207.
ok(updateCount == 1 || updateCount == 2, "update event received");
ok(updateendCount == 1 || updateendCount == 2, "updateend event received");
ok(updatestartCount == 1 || updatestartCount == 2, "updatestart event received");
is(loadedmetadataCount, 1, "loadedmetadata event received");
--- a/dom/media/mediasource/test/test_MediaSource_disabled.html
+++ b/dom/media/mediasource/test/test_MediaSource_disabled.html
@@ -16,17 +16,16 @@ function test() {
"MediaSource should be hidden behind a pref");
SimpleTest.doesThrow(() => new MediaSource,
"MediaSource should be hidden behind a pref");
SimpleTest.finish();
}
SpecialPowers.pushPrefEnv({"set":
[
- ["media.mediasource.enabled", false],
+ [ "media.mediasource.enabled", false ],
]
- },
- test);
+}, test);
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_MediaSource_flac_mp4.html
+++ b/dom/media/mediasource/test/test_MediaSource_flac_mp4.html
@@ -8,28 +8,28 @@
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
el.controls = true;
- ms.addEventListener("sourceopen", function () {
+ ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
- var sb = ms.addSourceBuffer("audio/mp4; codecs=\"flac\"");
+ const sb = ms.addSourceBuffer("audio/mp4; codecs=\"flac\"");
ok(sb, "Create a SourceBuffer");
- fetchAndLoad(sb, 'flac/IS', [''], '.mp4')
- .then(fetchAndLoad.bind(null, sb, 'flac/0000', range(1, 3), '.m4s'))
+ fetchAndLoad(sb, "flac/IS", [ "" ], ".mp4")
+ .then(fetchAndLoad.bind(null, sb, "flac/0000", range(1, 3), ".m4s"))
.then(function() {
el.play();
ms.endOfStream();
- return once(el, 'ended');
+ return once(el, "ended");
}).then(function() {
SimpleTest.finish();
});
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_MediaSource_memory_reporting.html
+++ b/dom/media/mediasource/test/test_MediaSource_memory_reporting.html
@@ -7,48 +7,48 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
+runWithMSE(function(ms, v) {
// Test that memory reporting works once we've played a video.
once(v, "ended", () => {
// Grab a memory report.
- var mgr = SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"]
- .getService(SpecialPowers.Ci.nsIMemoryReporterManager);
+ const mgr = SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"]
+ .getService(SpecialPowers.Ci.nsIMemoryReporterManager);
- var amount = 0;
- var resourcesPathSeen = false;
- var handleReport = function(aProcess, aPath, aKind, aUnits, aAmount, aDesc) {
+ let amount = 0;
+ let resourcePathSeen = false;
+ const handleReport = function(aProcess, aPath, aKind, aUnits, aAmount, aDesc) {
if (aPath == "explicit/media/resources") {
resourcePathSeen = true;
amount += aAmount;
}
- }
+ };
- var finished = function () {
+ const finished = function() {
ok(true, "Yay didn't crash!");
ok(resourcePathSeen, "Got media resources amount");
ok(amount > 0, "Non-zero amount reported for media resources");
SimpleTest.finish();
- }
+ };
mgr.getReports(handleReport, null, finished, null, /* anonymized = */ false);
});
// Load a webm video and play it.
ms.addEventListener("sourceopen", () => {
- var sb = ms.addSourceBuffer("video/webm");
- fetchAndLoad(sb, 'seek', [''], '.webm').then(function() {
+ const sb = ms.addSourceBuffer("video/webm");
+ fetchAndLoad(sb, "seek", [ "" ], ".webm").then(function() {
ms.endOfStream();
- v.play()
+ v.play();
});
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_MediaSource_mp4.html
+++ b/dom/media/mediasource/test/test_MediaSource_mp4.html
@@ -7,92 +7,92 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function () {
+runWithMSE(function() {
SimpleTest.doesThrow(() => new SourceBuffer, "new SourceBuffer should fail");
SimpleTest.doesThrow(() => new SourceBufferList, "new SourceBufferList direct should fail");
- var ms = new MediaSource();
+ const ms = new MediaSource();
ok(ms, "Create a MediaSource object");
ok(ms instanceof EventTarget, "MediaSource must be an EventTarget");
is(ms.readyState, "closed", "New MediaSource must be in closed state");
// Wrapper creation, tests for leaks.
SpecialPowers.wrap(ms);
// Set an expando to force wrapper creation, tests for leaks.
ms.foo = null;
- var o = URL.createObjectURL(ms);
+ const o = URL.createObjectURL(ms);
ok(o, "Create an objectURL from the MediaSource");
- var v = document.createElement("video");
+ const v = document.createElement("video");
v.preload = "auto";
v.src = o;
document.body.appendChild(v);
- var loadedmetadataCount = 0;
- var updatestartCount = 0;
- var updateendCount = 0;
- var updateCount = 0;
+ let loadedmetadataCount = 0;
+ let updatestartCount = 0;
+ let updateendCount = 0;
+ let updateCount = 0;
- ms.addEventListener("sourceopen", function () {
+ ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
- var sb = ms.addSourceBuffer("video/mp4");
+ const sb = ms.addSourceBuffer("video/mp4");
ok(sb, "Create a SourceBuffer");
is(ms.sourceBuffers.length, 1, "MediaSource.sourceBuffers is expected length");
is(ms.sourceBuffers[0], sb, "SourceBuffer in list matches our SourceBuffer");
is(ms.activeSourceBuffers.length, 0, "MediaSource.activeSourceBuffers is expected length");
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
is(sb.updating, true, "SourceBuffer.updating is expected value after appendBuffer");
});
- sb.addEventListener("update", function () {
+ sb.addEventListener("update", function() {
is(sb.updating, false, "SourceBuffer.updating is expected value in update event");
updateCount++;
/* Ensure that we endOfStream on the first update event only as endOfStream can
raise more if the duration of the last buffered range and the intial duration
differ. See bug 1065207 */
if (updateCount == 1) {
ms.endOfStream();
}
});
- sb.addEventListener("updatestart", function () {
+ sb.addEventListener("updatestart", function() {
updatestartCount++;
});
- sb.addEventListener("updateend", function () {
+ sb.addEventListener("updateend", function() {
is(ms.activeSourceBuffers[0], sb, "SourceBuffer in active list matches our SourceBuffer");
is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event");
updateendCount++;
v.play();
});
});
- ms.addEventListener("sourceended", function () {
+ ms.addEventListener("sourceended", function() {
ok(true, "Receive a sourceended event");
is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
});
- v.addEventListener("loadedmetadata", function () {
+ v.addEventListener("loadedmetadata", function() {
loadedmetadataCount++;
});
- v.addEventListener("ended", function () {
+ v.addEventListener("ended", function() {
// The bipbop video doesn't start at 0. The old MSE code adjust the
// timestamps and ignore the audio track. The new one doesn't.
isfuzzy(v.duration, 1.696, 0.166, "Video has correct duration");
isfuzzy(v.currentTime, 1.696, 0.166, "Video has correct duration");
// XXX: 2 update events can be received dueto duration differences, see bug 1065207.
ok(updateCount == 1 || updateCount == 2, "update event received");
ok(updateendCount == 1 || updateendCount == 2, "updateend event received");
ok(updatestartCount == 1 || updatestartCount == 2, "updatestart event received");
--- a/dom/media/mediasource/test/test_MultipleInitSegments.html
+++ b/dom/media/mediasource/test/test_MultipleInitSegments.html
@@ -8,40 +8,40 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek_lowres.webm", function (seek_lowres) {
- fetchWithXHR("seek.webm", function (seek) {
- var 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
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
+ fetchWithXHR("seek_lowres.webm", function(seek_lowres) {
+ fetchWithXHR("seek.webm", function(seek) {
+ 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
];
- var length = data.map(d => d[2] - d[1]).reduce((a, b) => a + b);
- var arrayBuffer = new Uint8Array(length);
- var pos = 0;
+ const length = data.map(d => d[2] - d[1]).reduce((a, b) => a + b);
+ const arrayBuffer = new Uint8Array(length);
+ let pos = 0;
data.forEach(function(d) {
- var buffer = new Uint8Array(d[0], d[1], d[2]-d[1]);
+ const buffer = new Uint8Array(d[0], d[1], d[2] - d[1]);
arrayBuffer.set(buffer, pos);
pos += buffer.byteLength;
});
loadSegment.bind(null, sb, arrayBuffer)().then(function() {
// Since we are passing multiple segments in one buffer,
// the first durationchange event from parsing the init
// segment will be fired before updateend.
- v.addEventListener("durationchange", function () {
+ v.addEventListener("durationchange", function() {
ok(v.duration, 1.201);
SimpleTest.finish();
});
ms.endOfStream();
});
});
});
});
--- a/dom/media/mediasource/test/test_MultipleInitSegments_mp4.html
+++ b/dom/media/mediasource/test/test_MultipleInitSegments_mp4.html
@@ -8,38 +8,38 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop_videoinit.mp4", function (init) {
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
+ fetchWithXHR("bipbop/bipbop_videoinit.mp4", function(init) {
init = new Uint8Array(init);
- fetchWithXHR("bipbop/bipbop_video1.m4s", function (segment1) {
+ fetchWithXHR("bipbop/bipbop_video1.m4s", function(segment1) {
segment1 = new Uint8Array(segment1);
- fetchWithXHR("bipbop/bipbop_video2.m4s", function (segment2) {
+ fetchWithXHR("bipbop/bipbop_video2.m4s", function(segment2) {
segment2 = new Uint8Array(segment2);
- var data = [init, segment1, init, segment2];
- var length = data.map(d => d.byteLength).reduce((a, b) => a + b);
- var arrayBuffer = new Uint8Array(length);
- var pos = 0;
+ const data = [ init, segment1, init, segment2 ];
+ const length = data.map(d => d.byteLength).reduce((a, b) => a + b);
+ const arrayBuffer = new Uint8Array(length);
+ let pos = 0;
data.forEach(function(buffer) {
arrayBuffer.set(buffer, pos);
pos += buffer.byteLength;
});
loadSegment.bind(null, sb, arrayBuffer)().then(function() {
// Since we are passing multiple segments in one buffer,
// the first durationchange event from parsing the init
// segment will be fired before updateend.
- v.addEventListener("durationchange", function () {
+ v.addEventListener("durationchange", function() {
ok(v.duration, 1.601666);
SimpleTest.finish();
});
ms.endOfStream();
});
});
});
});
--- a/dom/media/mediasource/test/test_OnEvents.html
+++ b/dom/media/mediasource/test/test_OnEvents.html
@@ -7,55 +7,55 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
+runWithMSE(function(ms, v) {
function initEvent(e) {
- v['got' + e] = false;
+ v["got" + e] = false;
}
function receiveEvent(e) {
- v['got' + e] = true;
+ v["got" + e] = true;
}
- var msevents = ["onsourceopen", "onsourceended"];
+ const msevents = [ "onsourceopen", "onsourceended" ];
msevents.forEach(function(e) {
initEvent(e);
ms[e] = function() { receiveEvent(e); };
});
- var sblistevents = ["onaddsourcebuffer", "onremovesourcebuffer"];
+ const sblistevents = [ "onaddsourcebuffer", "onremovesourcebuffer" ];
sblistevents.forEach(function(e) {
initEvent(e);
ms.sourceBuffers[e] = function() { receiveEvent(e); };
});
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- var sbevents = ["onupdatestart", "onupdate", "onupdateend", "onabort"];
+ const sbevents = [ "onupdatestart", "onupdate", "onupdateend", "onabort" ];
sbevents.forEach(function(e) {
initEvent(e);
sb[e] = function() { receiveEvent(e); };
});
- fetchAndLoad(sb, 'seek', [''], '.webm')
+ fetchAndLoad(sb, "seek", [ "" ], ".webm")
.then(function() {
- fetchWithXHR('seek.webm')
+ fetchWithXHR("seek.webm")
.then(function(arrayBuffer) {
sb.appendBuffer(arrayBuffer);
ms.removeSourceBuffer(sb); // will fire abort and removesourcebuffer
ms.endOfStream(); // will fire sourceended
once(ms, "sourceended").then(function() {
- var events = ["onsourceopen", "onsourceended", "onupdatestart", "onupdate", "onupdateend", "onabort", "onaddsourcebuffer", "onremovesourcebuffer"];
+ const events = [ "onsourceopen", "onsourceended", "onupdatestart", "onupdate", "onupdateend", "onabort", "onaddsourcebuffer", "onremovesourcebuffer" ];
events.forEach(function(e) {
- ok(v['got' + e], "got " + e);
+ ok(v["got" + e], "got " + e);
});
SimpleTest.finish();
});
});
});
});
});
--- a/dom/media/mediasource/test/test_PlayEvents.html
+++ b/dom/media/mediasource/test/test_PlayEvents.html
@@ -18,150 +18,149 @@ SimpleTest.waitForExplicitFinish();
// 3. Seek to an area with no buffered data, and ensure that readyState goes back to HAVE_METADATA
// 4. Load 1.6s of data at the seek position and ensure that canplay is fired and that readyState is now HAVE_FUTURE_DATA
// 5. Start playing video and check that once it reaches a position with no data, readyState goes back to HAVE_CURRENT_DATA and waiting event is fired.
// 6. Add 1.6s of data once video element fired waiting, that canplay is fired once readyState is HAVE_FUTURE_DATA.
// 7. Finally load data to the end and ensure that canplaythrough is fired and that readyState is now HAVE_ENOUGH_DATA
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
// Log events for debugging.
- var 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) {
- var v = e.target;
info("got " + e.type + " event");
}
events.forEach(function(e) {
el.addEventListener(e, logEvent);
});
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
el.addEventListener("error", function(e) {
ok(false, "should not fire '" + e + "' event");
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
- promises.push(once(el, 'loadedmetadata'));
- Promise.all(promises)
+ const metadataPromises = [];
+ metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+ metadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(metadataPromises)
.then(function() {
- ok(true, "got loadedmetadata event");
- var promises = [];
- promises.push(once(el, 'loadeddata'));
- promises.push(once(el, 'canplay'));
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s'));
- return Promise.all(promises);
+ ok(true, "got loadedmetadata event");
+ const canplayPromises = [];
+ canplayPromises.push(once(el, "loadeddata"));
+ canplayPromises.push(once(el, "canplay"));
+ canplayPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s"));
+ return Promise.all(canplayPromises);
})
.then(function() {
ok(true, "got canplay event");
// set element duration to 3.203333s. We do so in order to guarantee that
// the end of the buffered range will be equal to duration, causing
// canplaythrough to be fired later.
ms.duration = 3.203333;
- return once(el, 'durationchange');
+ return once(el, "durationchange");
})
.then(function() {
ok(true, "got durationchange event");
- var promises = [];
- promises.push(once(el, 'canplaythrough'));
+ const promises = [];
+ promises.push(once(el, "canplaythrough"));
// Load [0.801666, 3.203333]
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(3, 5), '.m4s'));
+ promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(3, 5), ".m4s"));
return Promise.all(promises);
})
.then(function() {
ok(true, "got canplaythrough event");
- // set element duration to 9.203333s, this value is set to coincide with
- // data added later (we now have an empty range from 6s to 9.203333s).
- ms.duration = 9.203333;
- return once(el, 'durationchange');
+ // set element duration to 9.203333s, this value is set to coincide with
+ // data added later (we now have an empty range from 6s to 9.203333s).
+ ms.duration = 9.203333;
+ return once(el, "durationchange");
})
.then(function() {
ok(true, "got durationchange event");
// An arbitrary value, so we are guaranteed to be in a range with no data.
el.currentTime = 6;
videosb.timestampOffset = 6;
ok(el.seeking, "seeking started");
- return once(el, 'seeking');
+ return once(el, "seeking");
})
.then(function() {
ok(true, "got seeking event");
is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
- var promises = [];
- promises.push(once(el, 'seeked'));
- promises.push(once(el, 'canplay'));
+ const promises = [];
+ promises.push(once(el, "seeked"));
+ promises.push(once(el, "canplay"));
// Load [6+0, 6+1.601666)
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s'));
+ promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s"));
return Promise.all(promises);
})
.then(function() {
ok(true, "got seeked and canplay event");
is(el.currentTime, 6, "seeked to 6s");
is(el.readyState, el.HAVE_FUTURE_DATA, "readyState is HAVE_FUTURE_DATA");
- var promises = [];
- promises.push(once(el, 'canplaythrough'));
+ const promises = [];
+ promises.push(once(el, "canplaythrough"));
// Load [6+1.60166, 6+3.203333]
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(3, 5), '.m4s'));
+ promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(3, 5), ".m4s"));
return Promise.all(promises);
})
.then(function() {
ok(true, "got canplaythrough event");
// set element duration to 19.805s, this value is set to coincide with
// data added later (we now have an empty range from 15 to 19.805).
ms.duration = 19.805;
- return once(el, 'durationchange');
+ return once(el, "durationchange");
})
.then(function() {
ok(true, "got durationchange event");
el.currentTime = 15;
videosb.timestampOffset = 15;
ok(el.seeking, "seeking started");
- return once(el, 'seeking');
+ return once(el, "seeking");
})
.then(function() {
ok(true, "got seeking event");
- var promises = [];
- promises.push(once(el, 'seeked'));
+ const promises = [];
+ promises.push(once(el, "seeked"));
// Load [15+0, 15+1.601666)
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s'));
+ promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s"));
return Promise.all(promises);
})
.then(function() {
ok(true, "got seeked event");
// Load [15+1.60166, 15+3.203333]
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(3, 5), '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", range(3, 5), ".m4s");
})
.then(function() {
ok(true, "data loaded");
// Playback we play for a little while then stall.
- var promises = [];
- promises.push(once(el, 'playing'));
- promises.push(once(el, 'waiting'));
+ const promises = [];
+ promises.push(once(el, "playing"));
+ promises.push(once(el, "waiting"));
el.play();
return Promise.all(promises);
})
.then(function() {
ok(true, "got playing and waiting event");
// Playback has stalled, readyState is back to HAVE_CURRENT_DATA.
is(el.readyState, el.HAVE_CURRENT_DATA, "readyState is HAVE_CURRENT_DATA");
- var promises = [];
- promises.push(once(el, 'playing'));
- promises.push(once(el, 'canplay'));
- promises.push(once(el, 'canplaythrough'));
+ const promises = [];
+ promises.push(once(el, "playing"));
+ promises.push(once(el, "canplay"));
+ promises.push(once(el, "canplaythrough"));
// Load [15+3.203333, 15+4.805)
// Our final buffered range will now be [0, 3.203333)[6, 9.203333)[15, 19.805)
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 7), '.m4s'));
+ promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 7), ".m4s"));
return Promise.all(promises);
})
.then(function() {
ok(true, "got playing, canplay and canplaythrough event");
SimpleTest.finish();
- })
+ });
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_PlayEventsAutoPlaying.html
+++ b/dom/media/mediasource/test/test_PlayEventsAutoPlaying.html
@@ -14,64 +14,64 @@ SimpleTest.waitForExplicitFinish();
// This test checks that readyState is properly set and the appropriate events are being fired accordingly:
// 1. Ensure that play/playing aren't fired before any media data been added.
// 2. Load 1.6s of data and ensure that canplay, play and playing events are fired.
runWithMSE(function(ms, el) {
el.controls = true;
el.autoplay = true;
- var eventCounts = { play: 0, playing: 0};
+ const eventCounts = { play: 0, playing: 0};
function ForbiddenEvents(e) {
- var v = e.target;
+ const v = e.target;
ok(v.readyState >= v.HAVE_FUTURE_DATA, "Must not have received event too early");
is(eventCounts[e.type], 0, "event should have only be fired once");
eventCounts[e.type]++;
}
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
// Log events for debugging.
- var 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");
}
events.forEach(function(e) {
el.addEventListener(e, logEvent);
});
el.addEventListener("play", ForbiddenEvents);
el.addEventListener("playing", ForbiddenEvents);
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
el.addEventListener("error", function(e) {
ok(false, "should not fire '" + e + "' event");
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
- promises.push(once(el, 'loadedmetadata'));
- Promise.all(promises)
+ const metadataPromises = [];
+ metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+ metadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(metadataPromises)
.then(function() {
- ok(true, "got loadedmetadata event");
- var promises = [];
- promises.push(once(el, 'loadeddata'));
- promises.push(once(el, 'canplay'));
- promises.push(once(el, 'play'));
- promises.push(once(el, 'playing'));
- promises.push(once(el, 'ended'));
- // 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.
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s')
- .then(() => ms.endOfStream()));
- return Promise.all(promises);
+ ok(true, "got loadedmetadata event");
+ const playedThroughPromises = [];
+ playedThroughPromises.push(once(el, "loadeddata"));
+ playedThroughPromises.push(once(el, "canplay"));
+ playedThroughPromises.push(once(el, "play"));
+ playedThroughPromises.push(once(el, "playing"));
+ playedThroughPromises.push(once(el, "ended"));
+ // 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.
+ playedThroughPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s")
+ .then(() => ms.endOfStream()));
+ return Promise.all(playedThroughPromises);
})
.then(function() {
ok(true, "got all required event");
SimpleTest.finish();
- })
+ });
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_PlayEventsAutoPlaying2.html
+++ b/dom/media/mediasource/test/test_PlayEventsAutoPlaying2.html
@@ -14,63 +14,63 @@ SimpleTest.waitForExplicitFinish();
// This test checks that readyState is properly set and the appropriate events are being fired accordingly:
// 1. Ensure that play/playing aren't fired before any media data been added.
// 2. Load more than 10s of data and ensure that canplay, play and playing events are fired.
runWithMSE(function(ms, el) {
el.controls = true;
el.autoplay = true;
- var eventCounts = { play: 0, playing: 0};
+ const eventCounts = { play: 0, playing: 0};
function ForbiddenEvents(e) {
- var v = e.target;
+ const v = e.target;
ok(v.readyState >= v.HAVE_FUTURE_DATA, "Must not have received event too early");
is(eventCounts[e.type], 0, "event should have only be fired once");
eventCounts[e.type]++;
}
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
// Log events for debugging.
- var 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");
}
events.forEach(function(e) {
el.addEventListener(e, logEvent);
});
el.addEventListener("play", ForbiddenEvents);
el.addEventListener("playing", ForbiddenEvents);
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
el.addEventListener("error", function(e) {
ok(false, "should not fire '" + e + "' event");
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
- promises.push(once(el, 'loadedmetadata'));
- Promise.all(promises)
+ const metadataPromises = [];
+ metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+ metadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(metadataPromises)
.then(function() {
- ok(true, "got loadedmetadata event");
- var promises = [];
- // We shift the timestamps slightly to create a small gaps at the start.
- // one that should normally be ignored.
- videosb.timestampOffset = 0.1;
- promises.push(once(el, 'loadeddata'));
- promises.push(once(el, 'canplay'));
- promises.push(once(el, 'play'));
- promises.push(once(el, 'playing'));
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 14), '.m4s'));
- return Promise.all(promises);
+ ok(true, "got loadedmetadata event");
+ const playingPromises = [];
+ // We shift the timestamps slightly to create a small gaps at the start.
+ // one that should normally be ignored.
+ videosb.timestampOffset = 0.1;
+ playingPromises.push(once(el, "loadeddata"));
+ playingPromises.push(once(el, "canplay"));
+ playingPromises.push(once(el, "play"));
+ playingPromises.push(once(el, "playing"));
+ playingPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 14), ".m4s"));
+ return Promise.all(playingPromises);
})
.then(function() {
ok(true, "got all required event");
SimpleTest.finish();
- })
+ });
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_RemoveSourceBuffer.html
+++ b/dom/media/mediasource/test/test_RemoveSourceBuffer.html
@@ -4,29 +4,29 @@
<title>MSE: check buffered status after removed all source buffer</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
-var videoURL = "seek.webm";
+const videoURL = "seek.webm";
SimpleTest.waitForExplicitFinish();
runWithMSE(async function(ms, el) {
info("- wait for sourceopen -");
- await once(ms, 'sourceopen');
+ await once(ms, "sourceopen");
info("- wait for fetching data -");
- var arrayBuffer = await fetchWithXHR(videoURL);
+ const arrayBuffer = await fetchWithXHR(videoURL);
info("- create source buffer and append data -");
- var sourceBuffer = ms.addSourceBuffer("video/webm");
+ const sourceBuffer = ms.addSourceBuffer("video/webm");
sourceBuffer.appendBuffer(arrayBuffer);
await once(sourceBuffer, "updateend");
is(ms.sourceBuffers.length, 1,
"the length of source buffers list is 1.");
is(ms.activeSourceBuffers.length, 1,
"the length of active source buffers list is 1.");
ok(ms.duration != 0, "duration is not 0.");
is(el.buffered.length, 1, "buffered range is 1.");
--- a/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html
+++ b/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html
@@ -6,48 +6,48 @@
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
receivedSourceOpen = true;
- var sb = ms.addSourceBuffer("video/mp4");
+ const sb = ms.addSourceBuffer("video/mp4");
ok(sb, "Create a SourceBuffer");
- sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
- fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4')
+ sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+ fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4")
.then(function() {
- var promises = [];
- promises.push(fetchAndLoad(sb, 'bipbop/bipbop', range(1,3), '.m4s'));
+ const promises = [];
+ promises.push(fetchAndLoad(sb, "bipbop/bipbop", range(1, 3), ".m4s"));
promises.push(once(v, "loadeddata"));
return Promise.all(promises);
}).then(function() {
// clear the entire sourcebuffer.
sb.remove(0, 5);
return once(sb, "updateend");
}).then(function() {
v.play();
// We have nothing to play, waiting will be fired.
return once(v, "waiting");
}).then(function() {
- var promises = [];
+ const promises = [];
promises.push(once(v, "playing"));
- promises.push(fetchAndLoad(sb, 'bipbop/bipbop', range(1,4), '.m4s'));
+ promises.push(fetchAndLoad(sb, "bipbop/bipbop", range(1, 4), ".m4s"));
return Promise.all(promises);
}).then(function() {
ms.endOfStream();
- var promises = [];
+ const promises = [];
promises.push(once(ms, "sourceended"));
promises.push(once(v, "ended"));
return Promise.all(promises);
}).then(SimpleTest.finish.bind(SimpleTest));
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_SeekNoData_mp4.html
+++ b/dom/media/mediasource/test/test_SeekNoData_mp4.html
@@ -14,57 +14,57 @@ SimpleTest.waitForExplicitFinish();
// Avoid making trouble for people who fix rounding bugs.
function fuzzyEquals(a, b) {
return Math.abs(a - b) < 0.01;
}
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var audiosb = ms.addSourceBuffer("audio/mp4");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const audiosb = ms.addSourceBuffer("audio/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
el.addEventListener("error", function(e) {
ok(false, "should not fire '" + e + "' event");
});
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
try {
el.currentTime = 3;
} catch (e) {
ok(false, "should not throw '" + e + "' exception");
}
is(el.currentTime, 3, "currentTime is default playback start position");
is(el.seeking, false, "seek not started with HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4'));
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
- promises.push(once(el, 'loadedmetadata'))
- Promise.all(promises)
+ const metadataPromises = [];
+ metadataPromises.push(fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4"));
+ metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+ metadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(metadataPromises)
.then(function() {
- var p = once(el, 'seeking');
+ const p = once(el, "seeking");
el.play();
el.currentTime = 5;
is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
is(el.seeking, true, "seek not started with HAVE_METADATA");
is(el.currentTime, 5, "currentTime is seek position");
return p;
})
.then(function() {
- ok(true, "Got seeking event");
- var promises = [];
- promises.push(once(el, 'seeked'));
- promises.push(fetchAndLoad(audiosb, 'bipbop/bipbop_audio', range(5, 9), '.m4s'));
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(6, 10), '.m4s'));
- return Promise.all(promises);
+ ok(true, "Got seeking event");
+ const seekedPromises = [];
+ seekedPromises.push(once(el, "seeked"));
+ seekedPromises.push(fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(5, 9), ".m4s"));
+ seekedPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(6, 10), ".m4s"));
+ return Promise.all(seekedPromises);
})
.then(function() {
ok(true, "Got seeked event");
ok(el.currentTime >= 5, "Time >= 5");
- once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+ once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
ms.endOfStream();
});
});
});
</script>
</pre>
</body>
--- a/dom/media/mediasource/test/test_SeekToEnd_mp4.html
+++ b/dom/media/mediasource/test/test_SeekToEnd_mp4.html
@@ -9,49 +9,49 @@
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
- var audiosb = ms.addSourceBuffer("audio/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
+ const audiosb = ms.addSourceBuffer("audio/mp4");
- fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
- .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4'))
+ fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
+ .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4"))
.then(function() {
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;
- return fetchAndLoad(audiosb, 'bipbop/bipbop_audio', range(1, 6), '.m4s');
+ return fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 6), ".m4s");
}).then(function() {
ms.endOfStream();
- return Promise.all([once(el, "durationchange"), once(ms, "sourceended")]);
+ return Promise.all([ once(el, "durationchange"), once(ms, "sourceended") ]);
}).then(function() {
ok(true, "endOfStream completed");
// Seek to the middle of the gap where audio is missing. As we are in readyState = ended
// seeking must complete.
el.currentTime = videosb.buffered.end(0) / 2 + audiosb.buffered.end(0) / 2;
ok(el.currentTime - audiosb.buffered.end(0) > 1, "gap is big enough");
is(el.buffered.length, 1, "continuous buffered range");
is(el.buffered.end(0), videosb.buffered.end(0), "buffered range end is aligned with longest track");
ok(el.seeking, "element is now seeking");
ok(el.currentTime >= el.buffered.start(0) && el.currentTime <= el.buffered.end(0), "seeking time is in buffered range");
ok(el.currentTime > audiosb.buffered.end(0), "seeking point is not buffered in audio track");
- return once(el, 'seeked');
+ return once(el, "seeked");
}).then(function() {
ok(true, "we have successfully seeked");
// Now ensure that we can play to the end, even though we are missing data in one track.
el.play();
- once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+ once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
});
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_SeekToLastFrame_mp4.html
+++ b/dom/media/mediasource/test/test_SeekToLastFrame_mp4.html
@@ -8,31 +8,31 @@
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var sb = ms.addSourceBuffer("video/mp4");
- fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_480_624kbps-video', range(1, 3), '.m4s'))
+ const sb = ms.addSourceBuffer("video/mp4");
+ fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
.then(function() {
el.play();
// let seek to the last audio frame.
el.currentTime = 1.532517;
- return once(el, 'seeked');
+ return once(el, "seeked");
})
.then(function() {
ok(true, "seek completed");
ms.endOfStream();
- return once(el, 'ended');
+ return once(el, "ended");
}).then(function() {
SimpleTest.finish();
});
});
});
</script>
</pre>
--- a/dom/media/mediasource/test/test_SeekTwice_mp4.html
+++ b/dom/media/mediasource/test/test_SeekTwice_mp4.html
@@ -14,40 +14,40 @@ SimpleTest.waitForExplicitFinish();
// Avoid making trouble for people who fix rounding bugs.
function fuzzyEquals(a, b) {
return Math.abs(a - b) < 0.01;
}
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var audiosb = ms.addSourceBuffer("audio/mp4");
- var videosb = ms.addSourceBuffer("video/mp4");
- fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
- .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(6, 12), '.m4s'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(7, 14), '.m4s'))
+ const audiosb = ms.addSourceBuffer("audio/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
+ fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s"))
+ .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(7, 14), ".m4s"))
.then(function() {
- var p = once(el, 'seeking');
+ const p = once(el, "seeking");
el.play();
el.currentTime = 4.5; // Seek to a gap in the video
return p;
}).then(function() {
ok(true, "Got seeking event");
- var p = once(el, 'seeked');
+ const p = once(el, "seeked");
el.currentTime = 6; // Seek past the gap.
return p;
}).then(function() {
ok(true, "Got seeked event");
ok(el.currentTime >= 6, "Time >= 6");
- once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+ once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
ms.endOfStream();
});
});
});
</script>
</pre>
</body>
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream.html
@@ -7,32 +7,32 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", async function (arrayBuffer) {
+ fetchWithXHR("seek.webm", async function(arrayBuffer) {
info("- append buffer -");
sb.appendBuffer(new Uint8Array(arrayBuffer));
info("- wait for metadata -");
await once(v, "loadedmetadata");
info("- wait for updateend -");
await once(sb, "updateend");
info("- check seekable -");
- var target = 2;
+ const target = 2;
ok(v.seekable.length, "Resource is seekable");
is(v.seekable.start(0), 0, "Seekable's start point is correct");
is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit.html
@@ -7,37 +7,37 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", async function (arrayBuffer) {
+ fetchWithXHR("seek.webm", async function(arrayBuffer) {
info("- append first buffer -");
// 25523 is the offset of the first media segment's end
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25523));
info("- wait for metadata -");
await once(v, "loadedmetadata");
info("- wait for updateend -");
await once(sb, "updateend");
info("- append second buffer -");
sb.appendBuffer(new Uint8Array(arrayBuffer, 25523));
await once(sb, "updateend");
info("- check seekable -");
- var target = 2;
+ const target = 2;
ok(v.seekable.length, "Resource is seekable");
is(v.seekable.start(0), 0, "Seekable's start point is correct");
is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit_mp4.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit_mp4.html
@@ -7,37 +7,37 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop2s.mp4", async function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", async function(arrayBuffer) {
info("- append first buffer -");
// 25819 is the offset of the first media segment's end
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25819));
info("- wait for metadata -");
await once(v, "loadedmetadata");
info("- wait for updateend -");
await once(sb, "updateend");
info("- append second buffer -");
sb.appendBuffer(new Uint8Array(arrayBuffer, 25819));
await once(sb, "updateend");
info("- check seekable -");
- var target = 1.3;
+ const target = 1.3;
ok(v.seekable.length, "Resource is seekable");
is(v.seekable.start(0), 0, "Seekable's start point is correct");
is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream_mp4.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream_mp4.html
@@ -7,32 +7,32 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop2s.mp4", async function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", async function(arrayBuffer) {
info("- append buffer -");
sb.appendBuffer(new Uint8Array(arrayBuffer));
info("- wait for metadata -");
await once(v, "loadedmetadata");
info("- wait for updateend -");
await once(sb, "updateend");
info("- check seekable -");
- var target = 1.3;
+ const target = 1.3;
ok(v.seekable.length, "Resource is seekable");
is(v.seekable.start(0), 0, "Seekable's start point is correct");
is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekedEvent_mp4.html
+++ b/dom/media/mediasource/test/test_SeekedEvent_mp4.html
@@ -30,45 +30,45 @@ runWithMSE(function(ms, el) {
el._loadeddata = true;
});
el.addEventListener("playing", function() {
ok(true, "got playing");
is(el._seeked, true, "must have received seeked prior playing");
is(el._loadeddata, true, "must have received loadeddata prior playing");
el._playing = true;
});
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
- var promises = [];
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
- promises.push(once(el, "loadedmetadata"));
- Promise.all(promises)
+ const metadataPromises = [];
+ metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+ metadataPromises.push(once(el, "loadedmetadata"));
+ Promise.all(metadataPromises)
.then(function() {
el.play();
videosb.timestampOffset = 2;
is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
// Load [2, 3.606).
- var promises = [];
- promises.push(once(el, "play"));
- promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['1'], '.m4s'));
- return Promise.all(promises);
+ const playPromises = [];
+ playPromises.push(once(el, "play"));
+ playPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "1" ], ".m4s"));
+ return Promise.all(playPromises);
})
.then(function() {
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', ['2'], '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", [ "2" ], ".m4s");
})
.then(function() {
// TODO: readyState should be at least HAVE_CURRENTDATA, see bug 1367993.
ok(el.readyState >= el.HAVE_METADATA, "readyState is HAVE_METADATA");
el.currentTime = 2;
- var promises = [];
- promises.push(once(el, "seeked"));
- promises.push(once(el, "playing"));
- return Promise.all(promises);
+ const seekedAndPlayingPromises = [];
+ seekedAndPlayingPromises.push(once(el, "seeked"));
+ seekedAndPlayingPromises.push(once(el, "playing"));
+ return Promise.all(seekedAndPlayingPromises);
})
.then(function() {
ok(true, "completed seek");
SimpleTest.finish();
});
});
});
--- a/dom/media/mediasource/test/test_Sequence_mp4.html
+++ b/dom/media/mediasource/test/test_Sequence_mp4.html
@@ -6,34 +6,34 @@
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
receivedSourceOpen = true;
- var sb = ms.addSourceBuffer("video/mp4");
+ const sb = ms.addSourceBuffer("video/mp4");
ok(sb, "Create a SourceBuffer");
- sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
- sb.mode = 'sequence';
+ sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+ sb.mode = "sequence";
- fetchAndLoad(sb, 'bipbop/bipbop_video', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_video', ['5'], '.m4s'))
- .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_video', ['2'], '.m4s'))
+ fetchAndLoad(sb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_video", [ "5" ], ".m4s"))
+ .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_video", [ "2" ], ".m4s"))
.then(function() {
- 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");
- SimpleTest.finish();
- });
+ 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");
+ SimpleTest.finish();
+ });
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_SetModeThrows.html
+++ b/dom/media/mediasource/test/test_SetModeThrows.html
@@ -8,19 +8,19 @@
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
// MSE supports setting mode now. make sure it does not throw.
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
sb.mode = "segments";
ok("true", "Setting to segments does not throw");
try {
sb.mode = "sequence";
ok("true", "Setting to sequence does not throw");
} catch (e) { ok(false, "Should not throw setting mode to sequence: " + e); }
--- a/dom/media/mediasource/test/test_SplitAppend.html
+++ b/dom/media/mediasource/test/test_SplitAppend.html
@@ -7,38 +7,37 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var updateCount = 0;
+let updateCount = 0;
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
- sb.addEventListener("updateend", function () {
+ sb.addEventListener("updateend", function() {
updateCount++;
if (updateCount == 1) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
- }
- else if (updateCount == 2) {
+ } else if (updateCount == 2) {
ms.endOfStream();
}
});
v.play();
});
});
- v.addEventListener("ended", function () {
+ v.addEventListener("ended", function() {
// XXX: Duration should be exactly 4.0, see bug 1065207.
ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
SimpleTest.finish();
});
});
</script>
--- a/dom/media/mediasource/test/test_SplitAppendDelay.html
+++ b/dom/media/mediasource/test/test_SplitAppendDelay.html
@@ -8,40 +8,39 @@
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
-var updateCount = 0;
+let updateCount = 0;
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
- sb.addEventListener("updateend", function () {
+ sb.addEventListener("updateend", function() {
updateCount++;
if (updateCount == 1) {
- window.setTimeout(function () {
+ window.setTimeout(function() {
sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
}, 1000);
- }
- else if (updateCount == 2) {
+ } else if (updateCount == 2) {
ms.endOfStream();
}
});
v.play();
});
});
- v.addEventListener("ended", function () {
+ v.addEventListener("ended", function() {
// XXX: Duration should be exactly 4.0, see bug 1065207.
ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
SimpleTest.finish();
});
});
</script>
--- a/dom/media/mediasource/test/test_SplitAppendDelay_mp4.html
+++ b/dom/media/mediasource/test/test_SplitAppendDelay_mp4.html
@@ -8,40 +8,39 @@
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
-var updateCount = 0;
+let updateCount = 0;
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
- sb.addEventListener("updateend", function () {
+ sb.addEventListener("updateend", function() {
updateCount++;
if (updateCount == 1) {
- window.setTimeout(function () {
+ window.setTimeout(function() {
sb.appendBuffer(new Uint8Array(arrayBuffer, 1395));
}, 1000);
- }
- else if (updateCount == 2) {
+ } else if (updateCount == 2) {
ms.endOfStream();
}
});
v.play();
});
});
- v.addEventListener("ended", function () {
+ v.addEventListener("ended", function() {
// The bipbop video doesn't start at 0. The old MSE code adjust the
// timestamps and ignore the audio track. The new one doesn't.
isfuzzy(v.duration, 1.696, 0.166, "Video has correct duration");
isfuzzy(v.currentTime, 1.696, 0.166, "Video has played to end");
SimpleTest.finish();
});
});
--- a/dom/media/mediasource/test/test_SplitAppend_mp4.html
+++ b/dom/media/mediasource/test/test_SplitAppend_mp4.html
@@ -7,38 +7,37 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-var updateCount = 0;
+let updateCount = 0;
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
- sb.addEventListener("updateend", function () {
+ sb.addEventListener("updateend", function() {
updateCount++;
if (updateCount == 1) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 1395));
- }
- else if (updateCount == 2) {
+ } else if (updateCount == 2) {
ms.endOfStream();
}
});
v.play();
});
});
- v.addEventListener("ended", function () {
+ v.addEventListener("ended", function() {
// The bipbop video doesn't start at 0. The old MSE code adjust the
// timestamps and ignore the audio track. The new one doesn't.
isfuzzy(v.duration, 1.696, 0.166, "Video has correct duration");
isfuzzy(v.currentTime, 1.696, 0.166, "Video has played to end");
SimpleTest.finish();
});
});
--- a/dom/media/mediasource/test/test_Threshold_mp4.html
+++ b/dom/media/mediasource/test/test_Threshold_mp4.html
@@ -9,70 +9,70 @@
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
-var threshold = 0.5; // gap threshold in seconds.
-var fuzz = 0.000001; // fuzz when comparing double.
+ const threshold = 0.5; // gap threshold in seconds.
+ const fuzz = 0.000001; // fuzz when comparing double.
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var videosb = ms.addSourceBuffer("video/mp4");
- var vchunks = [ {start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666}];
+ const videosb = ms.addSourceBuffer("video/mp4");
+ const vchunks = [ {start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666} ];
- fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s'))
+ fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 5), ".m4s"))
.then(function() {
// We will insert a gap of threshold
videosb.timestampOffset = threshold;
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
}).then(function() {
// 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'.
info("Invoking play()");
- var p = once(el, 'playing');
+ const p = once(el, "playing");
el.play();
return p;
}).then(function() {
- return once(el, 'waiting');
+ return once(el, "waiting");
}).then(function() {
// We're waiting for data after the start of the last frame.
// 0.033333 is the duration of the last frame.
ok(el.currentTime >= vchunks[1].end - 0.033333 + threshold - fuzz
&& el.currentTime <= vchunks[1].end + threshold + fuzz, "skipped the gap properly: " + el.currentTime + " " + (vchunks[1].end + threshold));
is(el.buffered.length, 2, "buffered range has right length");
// Now we test that seeking will succeed despite the gap.
el.currentTime = el.buffered.end(0) + (threshold / 2);
- return once(el, 'seeked');
+ return once(el, "seeked");
}).then(function() {
// Now we test that we don't pass the gap.
// Clean up our sourcebuffer by removing all data.
videosb.timestampOffset = 0;
videosb.remove(0, Infinity);
el.currentTime = 0;
el.pause();
return once(videosb, "updateend");
}).then(function() {
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s");
}).then(function() {
// We will insert a gap of threshold + 1ms
- videosb.timestampOffset = threshold + 1/1000;
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s');
+ videosb.timestampOffset = threshold + 1 / 1000;
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
}).then(function() {
info("Invoking play()");
- var p = once(el, 'playing');
+ const p = once(el, "playing");
el.play();
return p;
}).then(function() {
- return once(el, 'waiting');
+ return once(el, "waiting");
}).then(function() {
// We're waiting for data after the start of the last frame.
// 0.033333 is the duration of the last frame.
ok(el.currentTime >= vchunks[0].end - 0.033333 - fuzz
&& el.currentTime <= vchunks[0].end + fuzz, "stopped at the gap properly: " + el.currentTime + " " + vchunks[0].end);
SimpleTest.finish();
});
});
--- a/dom/media/mediasource/test/test_TimestampOffset_mp4.html
+++ b/dom/media/mediasource/test/test_TimestampOffset_mp4.html
@@ -8,79 +8,79 @@
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
function range(start, end) {
- var rv = [];
- for (var i = start; i < end; ++i) {
+ const rv = [];
+ for (let i = start; i < end; ++i) {
rv.push(i);
}
return rv;
}
-var eps = 0.01;
+const eps = 0.01;
runWithMSE(function(ms, el) {
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var audiosb = ms.addSourceBuffer("audio/mp4");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const audiosb = ms.addSourceBuffer("audio/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
// We divide the video into 3 chunks:
// chunk 0: segments 1-4
// 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.
- var vchunks = [ {start: 0, end: 3.2033}, { start: 3.2033, end: 6.4066}, { start: 6.4066, end: 10.01} ];
- var firstvoffset = vchunks[2].end - vchunks[2].start; // Duration of chunk 2
- var secondvoffset = -(vchunks[1].end - vchunks[1].start); // -(Duration of chunk 1)
+ const vchunks = [ {start: 0, end: 3.2033}, { start: 3.2033, end: 6.4066}, { 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)
- fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s'))
+ fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 5), ".m4s"))
.then(function() {
is(videosb.buffered.length, 1, "No discontinuity");
isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "Chunk start");
isfuzzy(videosb.buffered.end(0), vchunks[0].end, eps, "Chunk end");
videosb.timestampOffset = firstvoffset;
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
})
.then(function(data) {
is(videosb.buffered.length, 2, "One discontinuity");
isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "First Chunk start");
isfuzzy(videosb.buffered.end(0), vchunks[0].end, eps, "First chunk end");
- isfuzzy(videosb.buffered.start(1), vchunks[1].start + firstvoffset, eps, "Second chunk start");
+ isfuzzy(videosb.buffered.start(1), vchunks[1].start + firstvoffset, eps, "Second chunk start");
isfuzzy(videosb.buffered.end(1), vchunks[1].end + firstvoffset, eps, "Second chunk end");
videosb.timestampOffset = secondvoffset;
- return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(9, 14), '.m4s');
+ return fetchAndLoad(videosb, "bipbop/bipbop_video", range(9, 14), ".m4s");
})
.then(function() {
is(videosb.buffered.length, 1, "No discontinuity (end)");
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;
- }).then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4'))
- .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 12), '.m4s'))
+ }).then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4"))
+ .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 12), ".m4s"))
.then(function() {
is(audiosb.buffered.length, 1, "No audio discontinuity");
isfuzzy(audiosb.buffered.start(0), 3, eps, "Audio starts at 3");
// Trim the rest of the audio.
audiosb.remove(videosb.buffered.end(0), Infinity);
videosb.remove(videosb.buffered.end(0), Infinity);
- return Promise.all([audiosb.updating ? once(audiosb, 'updateend') : Promise.resolve(),
- videosb.updating ? once(videosb, 'updateend') : Promise.resolve()]);
+ return Promise.all([ audiosb.updating ? once(audiosb, "updateend") : Promise.resolve(),
+ videosb.updating ? once(videosb, "updateend") : Promise.resolve() ]);
}).then(function() {
info("waiting for play to complete");
el.play();
el.currentTime = el.buffered.start(0);
ms.endOfStream();
- Promise.all([once(el, 'ended'), once(el, 'seeked')]).then(SimpleTest.finish.bind(SimpleTest));
+ Promise.all([ once(el, "ended"), once(el, "seeked") ]).then(SimpleTest.finish.bind(SimpleTest));
});
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_TruncatedDuration.html
+++ b/dom/media/mediasource/test/test_TruncatedDuration.html
@@ -20,48 +20,48 @@
SimpleTest.waitForExplicitFinish();
function round(n) {
return Math.round(n * 1000) / 1000;
}
function do_seeking(e) {
- var v = e.target;
+ const v = e.target;
v.removeEventListener("seeking", do_seeking);
SimpleTest.finish();
}
function do_seeked(e) {
- var v = e.target;
+ const v = e.target;
v.removeEventListener("seeked", do_seeked);
- var duration = round(v.duration / 3);
+ const duration = round(v.duration / 3);
is(v._sb.updating, false, "sourcebuffer isn't updating");
v._sb.remove(duration, Infinity);
once(v._sb, "updateend", function() {
- v._ms.duration = duration
+ v._ms.duration = duration;
// frames aren't truncated, so duration may be slightly more.
- isfuzzy(v.duration, duration, 1/30, "element duration was updated");
+ isfuzzy(v.duration, duration, 1 / 30, "element duration was updated");
v._sb.abort(); // this shouldn't abort updating the duration (bug 1130826).
ok(v.seeking, "seeking is true");
// test playback position was updated (bug 1130839).
is(v.currentTime, v.duration, "current time was updated");
is(v._sb.buffered.length, 1, "One buffered range");
// Truncated mediasource duration will cause the video element to seek.
v.addEventListener("seeking", do_seeking);
});
}
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
v._sb = sb;
v._ms = ms;
- fetchWithXHR("seek.webm", function (arrayBuffer) {
+ fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
once(sb, "updateend", function() {
v.currentTime = v.duration / 2;
is(v.currentTime, v.duration / 2, "current time was updated");
ok(v.seeking, "seeking is true");
v.addEventListener("seeked", do_seeked);
});
});
--- a/dom/media/mediasource/test/test_TruncatedDuration_mp4.html
+++ b/dom/media/mediasource/test/test_TruncatedDuration_mp4.html
@@ -19,48 +19,48 @@
SimpleTest.waitForExplicitFinish();
function round(n) {
return Math.round(n * 1000) / 1000;
}
function do_seeking(e) {
- var v = e.target;
+ const v = e.target;
v.removeEventListener("seeking", do_seeking);
SimpleTest.finish();
}
function do_seeked(e) {
- var v = e.target;
+ const v = e.target;
v.removeEventListener("seeked", do_seeked);
- var duration = round(v.duration / 3);
+ const duration = round(v.duration / 3);
is(v._sb.updating, false, "sourcebuffer isn't updating");
v._sb.remove(duration, Infinity);
once(v._sb, "updateend", function() {
- v._ms.duration = duration
+ v._ms.duration = duration;
// frames aren't truncated, so duration may be slightly more.
- isfuzzy(v.duration, duration, 1/30, "element duration was updated");
+ isfuzzy(v.duration, duration, 1 / 30, "element duration was updated");
v._sb.abort(); // this shouldn't abort updating the duration (bug 1130826).
ok(v.seeking, "seeking is true");
// test playback position was updated (bug 1130839).
is(v.currentTime, v.duration, "current time was updated");
is(v._sb.buffered.length, 1, "One buffered range");
// Truncated mediasource duration will cause the video element to seek.
v.addEventListener("seeking", do_seeking);
});
}
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/mp4");
v._sb = sb;
v._ms = ms;
- fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+ fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
once(sb, "updateend", function() {
// mp4 metadata states 10s when we only have 1.6s worth of video.
sb.remove(sb.buffered.end(0), Infinity);
once(sb, "updateend", function() {
ms.duration = sb.buffered.end(0);
is(v.duration, ms.duration, "current time updated with mediasource duration");
v.currentTime = v.duration / 2;
--- a/dom/media/mediasource/test/test_WaitingOnMissingData.html
+++ b/dom/media/mediasource/test/test_WaitingOnMissingData.html
@@ -7,49 +7,49 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var sb = ms.addSourceBuffer("video/webm");
+ const sb = ms.addSourceBuffer("video/webm");
fetchWithXHR("seek.webm", function(arrayBuffer) {
- sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+ sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))()
- .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25223-318)))
- .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25223, 46712-25223)))
+ .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25223 - 318)))
+ .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25223, 46712 - 25223)))
/* Note - Missing |46712, 67833 - 46712| segment here */
.then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833)))
.then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966)))
.then(function() {
// 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'.
info("Invoking play()");
- var p = once(el, 'playing');
+ const p = once(el, "playing");
el.play();
return p;
}).then(function() {
ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
- var p = once(el, 'waiting');
+ const p = once(el, "waiting");
el.play();
return p;
}).then(function() {
// currentTime is based on the current video frame, so if the audio ends just before
// the next video frame, currentTime can be up to 1 frame's worth earlier than
// min(audioEnd, videoEnd).
// 0.0465 is the length of the last audio frame.
ok(el.currentTime >= (sb.buffered.end(0) - 0.0465),
"Got a waiting event at " + el.currentTime);
info("Loading more data");
- var p = once(el, 'ended');
+ const p = once(el, "ended");
loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712)).then(() => ms.endOfStream());
return p;
}).then(function() {
// These fuzz factors are bigger than they should be. We should investigate
// and fix them in bug 1137574.
isfuzzy(el.duration, 4.001, 0.1, "Video has correct duration: " + el.duration);
isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
SimpleTest.finish();
--- a/dom/media/mediasource/test/test_WaitingOnMissingDataEnded_mp4.html
+++ b/dom/media/mediasource/test/test_WaitingOnMissingDataEnded_mp4.html
@@ -8,40 +8,40 @@
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- el.addEventListener("ended", function () {
+ el.addEventListener("ended", function() {
ok(false, "ended should never fire");
SimpleTest.finish();
});
- var videosb = ms.addSourceBuffer("video/mp4");
- fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(6, 8), '.m4s'))
+ const videosb = ms.addSourceBuffer("video/mp4");
+ fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 5), ".m4s"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(6, 8), ".m4s"))
.then(function() {
is(el.buffered.length, 2, "discontinuous buffered range");
ms.endOfStream();
- return Promise.all([once(el, "durationchange"), once(ms, "sourceended")]);
+ return Promise.all([ once(el, "durationchange"), once(ms, "sourceended") ]);
}).then(function() {
// 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'.
info("Invoking play()");
el.play();
- return once(el, 'playing');
+ return once(el, "playing");
}).then(function() {
ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
- return once(el, 'waiting');
+ return once(el, "waiting");
}).then(function() {
// waiting is fired when we start to play the last frame.
// 0.033334 is the duration of the last frame, + 0.000001 of fuzz.
// the next video frame, currentTime can be up to 1 frame's worth earlier than end of video.
isfuzzy(el.currentTime, videosb.buffered.end(0), 0.033334, "waiting was fired on gap");
SimpleTest.finish();
});
});
--- a/dom/media/mediasource/test/test_WaitingOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_WaitingOnMissingData_mp4.html
@@ -8,50 +8,50 @@
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var audiosb = ms.addSourceBuffer("audio/mp4");
- var videosb = ms.addSourceBuffer("video/mp4");
- fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
- .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(6, 12), '.m4s'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(7, 14), '.m4s'))
+ const audiosb = ms.addSourceBuffer("audio/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
+ fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s"))
+ .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(7, 14), ".m4s"))
.then(function() {
// 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'.
info("Invoking play()");
- var p = once(el, 'playing');
+ const p = once(el, "playing");
el.play();
return p;
}).then(function() {
ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
- var p = once(el, 'waiting');
+ const p = once(el, "waiting");
el.play();
return p;
}).then(function() {
// currentTime is based on the current video frame, so if the audio ends just before
// the next video frame, currentTime can be up to 1 frame's worth earlier than
// min(audioEnd, videoEnd).
// 0.0465 is the length of the last audio frame.
ok(el.currentTime >= (Math.min(audiosb.buffered.end(0), videosb.buffered.end(0)) - 0.0465),
- "Got a waiting event at " + el.currentTime);
+ "Got a waiting event at " + el.currentTime);
info("Loading more data");
- var p = once(el, 'ended');
- var loads = Promise.all([fetchAndLoad(audiosb, 'bipbop/bipbop_audio', [5], '.m4s'),
- fetchAndLoad(videosb, 'bipbop/bipbop_video', [6], '.m4s')]);
+ const p = once(el, "ended");
+ const loads = Promise.all([ fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ 5 ], ".m4s"),
+ fetchAndLoad(videosb, "bipbop/bipbop_video", [ 6 ], ".m4s") ]);
loads.then(() => ms.endOfStream());
return p;
}).then(function() {
// These fuzz factors are bigger than they should be. We should investigate
// and fix them in bug 1137574.
isfuzzy(el.duration, 10.1, 0.1, "Video has correct duration: " + el.duration);
isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
SimpleTest.finish();
--- a/dom/media/mediasource/test/test_WaitingToEndedTransition_mp4.html
+++ b/dom/media/mediasource/test/test_WaitingToEndedTransition_mp4.html
@@ -8,43 +8,43 @@
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function(ms, el) {
el.controls = true;
- once(ms, 'sourceopen').then(function() {
+ once(ms, "sourceopen").then(function() {
ok(true, "Receive a sourceopen event");
- var audiosb = ms.addSourceBuffer("audio/mp4");
- var videosb = ms.addSourceBuffer("video/mp4");
+ const audiosb = ms.addSourceBuffer("audio/mp4");
+ const videosb = ms.addSourceBuffer("video/mp4");
// ensure tracks end at approximately the same time to ensure ended event is
// always fired (bug 1233639).
audiosb.appendWindowEnd = 3.9;
videosb.appendWindowEnd = 3.9;
- fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
- .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
- .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
+ fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"))
+ .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s"))
+ .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
.then(function() {
// 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'.
info("Invoking play()");
- var p = once(el, 'playing');
+ const p = once(el, "playing");
el.play();
return p;
}).then(function() {
ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
- var p = once(el, 'waiting');
+ const p = once(el, "waiting");
el.play();
return p;
}).then(function() {
- var p = once(el, 'ended');
+ const p = once(el, "ended");
ms.endOfStream();
return p;
}).then(function() {
is(el.duration, 3.854512, "Video has correct duration: " + el.duration);
is(el.currentTime, el.duration, "Video has correct currentTime.");
SimpleTest.finish();
});
});
--- a/dom/media/mediasource/test/test_WebMTagsBeforeCluster.html
+++ b/dom/media/mediasource/test/test_WebMTagsBeforeCluster.html
@@ -7,23 +7,23 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
-addMSEPrefs(["media.mediasource.webm.enabled", true]);
+addMSEPrefs([ "media.mediasource.webm.enabled", true ]);
-runWithMSE(function (ms, v) {
- ms.addEventListener("sourceopen", function () {
- var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+ ms.addEventListener("sourceopen", function() {
+ const sb = ms.addSourceBuffer("video/webm");
- fetchWithXHR("tags_before_cluster.webm", async function (arrayBuffer) {
+ fetchWithXHR("tags_before_cluster.webm", async function(arrayBuffer) {
info("- append buffer -");
sb.appendBuffer(new Uint8Array(arrayBuffer));
info("- wait for metadata -");
await once(v, "loadedmetadata");
info("- wait for updateend -");
await once(sb, "updateend");