Bug 1556854 - Enable ESLint for dom/media/test/, disabling failing rules, fixing instances of no-shadow failures. r=jya

Differential Revision: https://phabricator.services.mozilla.com/D49799

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2019-10-24 12:05:46 +00:00
parent d7b145656a
commit a46a631fb2
38 changed files with 349 additions and 327 deletions

View file

@ -11,10 +11,6 @@
# Exclude expected objdirs.
obj*/
# dom/ exclusions which should be removed (aka ESLint enabled)
dom/media/test/
!dom/media/test/marionette/yttest/*.js
# build/ third-party code
build/pgo/js-input/
@ -159,6 +155,8 @@ dom/encoding/test/file_utf16_be_bom.js
dom/encoding/test/file_utf16_le_bom.js
# Not parsable
dom/media/test/marionette/yttest/duration_test.js
dom/media/test/marionette/yttest/until_end_test.js
dom/tests/mochitest/general/test_focusrings.xul
dom/html/test/test_bug677658.html

View file

@ -382,5 +382,31 @@ module.exports = {
"rules": {
"mozilla/prefer-boolean-length-check": "off",
}
}, {
"files": [
"dom/media/**",
],
"rules": {
"consistent-return": "off",
"curly": "off",
"dot-notation": "off",
"mozilla/consistent-if-bracing": "off",
"mozilla/no-useless-parameters": "off",
"mozilla/use-default-preference-values": "off",
"mozilla/use-services": "off",
"no-array-constructor": "off",
"no-async-promise-executor": "off",
"no-else-return": "off",
"no-redeclare": "off",
"no-nested-ternary": "off",
"no-self-assign": "off",
"no-new-object": "off",
"no-undef": "off",
"no-unsanitized/property": "off",
"no-unused-vars": "off",
"no-useless-return": "off",
"object-shorthand": "off",
"prettier/prettier": "off",
}
}]
};

View file

@ -38,8 +38,8 @@
(eventName) => {
return new Promise(async function (resolve, reject) {
window.addEventListener(eventName, async function (event) {
let played = await element.play().then(() => true, () => false);
ok(played, "Expect to be activated already in " + eventName);
let p = await element.play().then(() => true, () => false);
ok(p, "Expect to be activated already in " + eventName);
resolve();
}, false);
});

View file

@ -12,7 +12,7 @@ var config = {
"quality": function () {
if (config.HD || config.LQ) {
var youtubePlayerListener = function (LQ, HD) {
return function youtubePlayerListener (e) {
return function (e) {
if (e === 1) {
var player = document.getElementById('movie_player');
if (player) {
@ -70,4 +70,3 @@ var config = {
/* */
observer.observe(content, {"childList": true, "subtree": true});
}

View file

@ -21,25 +21,25 @@ function createTestArray() {
}
function startTest(test, token) {
var v = document.createElement('video');
v.token = token += "-seek" + test.number + ".js";
manager.started(v.token);
v.src = test.name;
v.preload = "metadata";
document.body.appendChild(v);
var video = document.createElement('video');
video.token = token += "-seek" + test.number + ".js";
manager.started(video.token);
video.src = test.name;
video.preload = "metadata";
document.body.appendChild(video);
var name = test.name + " seek test " + test.number;
var localIs = function(name) { return function(a, b, msg) {
is(a, b, name + ": " + msg);
var localIs = function(n) { return function(a, b, msg) {
is(a, b, n + ": " + msg);
}}(name);
var localOk = function(name) { return function(a, msg) {
ok(a, name + ": " + msg);
var localOk = function(n) { return function(a, msg) {
ok(a, n + ": " + msg);
}}(name);
var localFinish = function(v, manager) { return function() {
var localFinish = function(v, m) { return function() {
v.onerror = null;
removeNodeAndSource(v);
dump("SEEK-TEST: Finished " + name + " token: " + v.token + "\n");
manager.finished(v.token);
}}(v, manager);
m.finished(v.token);
}}(video, manager);
dump("SEEK-TEST: Started " + name + "\n");
window['test_seek' + test.number](v, test.duration/2, localIs, localOk, localFinish);
window['test_seek' + test.number](video, test.duration/2, localIs, localOk, localFinish);
}

View file

@ -36,32 +36,32 @@ function testBuffered(e) {
var caught = false;
try {
b.start(-1);
} catch (e) {
caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} catch (ex) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR;
}
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on under start bounds range");
caught = false;
try {
b.end(-1);
} catch (e) {
caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} catch (ex) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR;
}
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on under end bounds range");
caught = false;
try {
b.start(b.length);
} catch (e) {
caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} catch (ex) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR;
}
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on over start bounds range");
caught = false;
try {
b.end(b.length);
} catch (e) {
caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} catch (ex) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR;
}
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on over end bounds range");

View file

@ -27,7 +27,7 @@ for (let ev of events) {
a.addEventListener(ev, dumpEvent);
}
(async _ => {
(async () => {
try {
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("Timeouts for shortcutting test-timeout");
@ -60,7 +60,7 @@ for (let ev of events) {
a.currentTime = test.duration - 1;
await Promise.race([
new Promise(res => a.onended = res),
wait(30000).then(_ => Promise.reject(new Error("Timeout"))),
wait(30000).then(() => Promise.reject(new Error("Timeout"))),
]);
} catch(e) {
ok(false, e);

View file

@ -30,17 +30,17 @@ function startTest(test, token) {
clone.token = evt.target.token;
clone.play();
clone.onloadstart = function(evt) {
info("cloned " + evt.target.token + " start loading.");
evt.target.onloadstart = null;
clone.onloadstart = function(event) {
info("cloned " + event.target.token + " start loading.");
event.target.onloadstart = null;
removeNodeAndSource(v);
}
clone.onended = function(evt) {
ok(true, "cloned " + evt.target.token + " ended.");
evt.target.onended = null;
removeNodeAndSource(evt.target);
manager.finished(evt.target.token);
clone.onended = function(event) {
ok(true, "cloned " + event.target.token + " ended.");
event.target.onended = null;
removeNodeAndSource(event.target);
manager.finished(event.target.token);
}
}
}

View file

@ -42,7 +42,7 @@ function testWebM1(e) {
ok(v.buffered.length >= 1, "Should have a buffered range");
var halfBuffered = v.buffered.end(0) / 2;
function startTest() {
function start() {
is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start");
is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end");
ok(!completed, "Should not be completed yet");
@ -51,8 +51,8 @@ function testWebM1(e) {
v.seeking = true;
readonly = v.seeking === false;
}
catch(e) {
readonly = "threw exception: " + e;
catch(ex) {
readonly = "threw exception: " + ex;
}
is(readonly, true, "seeking should be readonly");
@ -90,7 +90,7 @@ function testWebM1(e) {
once(v, "seeking", seekStarted);
once(v, "seeked", seekEnded);
startTest();
start();
}
// Fetch the media resource using XHR so we can be sure the entire
@ -133,4 +133,4 @@ manager.runTests(gCuelessWebMTests, startTest);
</script>
</pre>
</body>
</html>
</html>

View file

@ -39,7 +39,7 @@ function testWebM2(e) {
ok(v.buffered.length >= 1, "Should have a buffered range");
var halfBuffered = v.buffered.end(0) / 2;
function startTest() {
function start() {
if (completed)
return;
@ -80,7 +80,7 @@ function testWebM2(e) {
v.addEventListener("seeking", seekStarted);
v.addEventListener("seeked", seekEnded);
startTest();
start();
}
// Fetch the media resource using XHR so we can be sure the entire
@ -123,4 +123,4 @@ manager.runTests(gCuelessWebMTests, startTest);
</script>
</pre>
</body>
</html>
</html>

View file

@ -39,7 +39,7 @@ function testWebM3(e) {
ok(v.buffered.length >= 1, "Should have a buffered range");
var halfBuffered = v.buffered.end(0) / 2;
function startTest() {
function start() {
if (completed)
return;
@ -76,7 +76,7 @@ function testWebM3(e) {
v.addEventListener("seeking", seekStarted);
v.addEventListener("seeked", seekEnded);
startTest()
start()
}
// Fetch the media resource using XHR so we can be sure the entire
@ -119,4 +119,4 @@ manager.runTests(gCuelessWebMTests, startTest);
</script>
</pre>
</body>
</html>
</html>

View file

@ -44,8 +44,8 @@ function startTest(test, token)
var eventCounts = { play: 0, playing: 0};
function ForbiddenEvents(e) {
var v = e.target;
ok(v.readyState >= v.HAVE_FUTURE_DATA, "Must not have received event too early");
var video = e.target;
ok(video.readyState >= video.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]++;
}

View file

@ -33,12 +33,12 @@ function KeysChangeFunc(session, keys, token) {
session.keyIdsReceived[keyid] = false;
}
return function(ev) {
var session = ev.target;
session.gotKeysChanged = true;
var s = ev.target;
s.gotKeysChanged = true;
var keyList = [];
var valueList = [];
var map = session.keyStatuses;
var map = s.keyStatuses;
// Test that accessing keys not known to the CDM has expected behaviour.
var absentKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
@ -55,8 +55,8 @@ function KeysChangeFunc(session, keys, token) {
valueList.push(val);
is(val, "usable", token + ": key status should be usable");
var kid = Base64ToHex(window.btoa(ArrayBufferToString(key)));
ok(kid in session.keyIdsReceived, TimeStamp(token) + " session[" + session.sessionId + "].keyIdsReceived contained " + kid + " as expected.");
session.keyIdsReceived[kid] = true;
ok(kid in s.keyIdsReceived, TimeStamp(token) + " session[" + s.sessionId + "].keyIdsReceived contained " + kid + " as expected.");
s.keyIdsReceived[kid] = true;
}
var index = 0;

View file

@ -109,9 +109,9 @@
Log(token, "encrypted event => len=" + initData.length + " " + hexStr);
let session = event.target.mediaKeys.createSession();
initDatas.set(hexStr, session);
session.addEventListener("message", event => {
event.target.update(
GenerateClearKeyLicense(event.message, test.keys));
session.addEventListener("message", e => {
e.target.update(
GenerateClearKeyLicense(e.message, test.keys));
});
session.generateRequest(event.initDataType, event.initData);
@ -138,4 +138,4 @@
</script>
</body>
</html>
</html>

View file

@ -48,8 +48,8 @@ function startTest(test, token)
var gotTypeError = false;
try {
ctx2d.drawImage(v, 0, 0);
} catch (e) {
if (e instanceof TypeError) {
} catch (ex) {
if (ex instanceof TypeError) {
gotTypeError = true;
}
}

View file

@ -98,25 +98,25 @@ function createTestArray() {
}
function startTest(test, token) {
var v = document.createElement('video');
var video = document.createElement('video');
manager.started(token);
v.preload = "metadata";
v.src = test.name;
v.token = token;
v.controls = true;
document.body.appendChild(v);
video.preload = "metadata";
video.src = test.name;
video.token = token;
video.controls = true;
document.body.appendChild(video);
var name = test.name + " fragment test";
var localIs = function(name) { return function(a, b, msg) {
is(a, b, name + ": " + msg);
var localIs = function(n) { return function(a, b, msg) {
is(a, b, n + ": " + msg);
}}(name);
var localOk = function(name) { return function(a, msg) {
ok(a, name + ": " + msg);
var localOk = function(n) { return function(a, msg) {
ok(a, n + ": " + msg);
}}(name);
var localFinish = function(v, manager) { return function() {
var localFinish = function(v, m) { return function() {
removeNodeAndSource(v);
manager.finished(v.token);
}}(v, manager);
window['test_fragment_noplay'](v, test.start, test.end, localIs, localOk, localFinish);
m.finished(v.token);
}}(video, manager);
window['test_fragment_noplay'](video, test.start, test.end, localIs, localOk, localFinish);
}
manager.runTests(createTestArray(), startTest);

View file

@ -62,25 +62,25 @@ function startTest(test, token) {
todo(false, test.todo);
return;
}
var v = document.createElement('video');
var video = document.createElement('video');
manager.started(token);
v.preload = "metadata";
v.src = test.name;
v.token = token;
v.controls = true;
document.body.appendChild(v);
video.preload = "metadata";
video.src = test.name;
video.token = token;
video.controls = true;
document.body.appendChild(video);
var name = test.name + " fragment test";
var localIs = function(name) { return function(a, b, msg) {
is(a, b, name + ": " + msg);
var localIs = function(n) { return function(a, b, msg) {
is(a, b, n + ": " + msg);
}}(name);
var localOk = function(name) { return function(a, msg) {
ok(a, name + ": " + msg);
var localOk = function(n) { return function(a, msg) {
ok(a, n + ": " + msg);
}}(name);
var localFinish = function(v, manager) { return function() {
var localFinish = function(v, m) { return function() {
removeNodeAndSource(v);
manager.finished(v.token);
}}(v, manager);
window['test_fragment_play'](v, test.start, test.end, localIs, localOk, localFinish);
m.finished(v.token);
}}(video, manager);
window['test_fragment_play'](video, test.start, test.end, localIs, localOk, localFinish);
}
manager.runTests(createTestArray(), startTest);

View file

@ -38,11 +38,11 @@ function tryClone(e) {
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
"waiting", "pause"];
function logEvent(evt) {
var e = evt.target;
info(`${e.token} got ${evt.type}`);
var event = evt.target;
info(`${event.token} got ${evt.type}`);
}
events.forEach(function(e) {
clone.addEventListener(e, logEvent);
events.forEach(function(event) {
clone.addEventListener(event, logEvent);
});

View file

@ -107,8 +107,8 @@ for (var i = 0; i < gSmallTests.length; ++i) {
// The following nested function hack is to ensure that 'test' is correctly
// captured in the closure and we don't end up getting the value 'test'
// had in the last iteration of the loop. I blame Brendan.
var check = function(test) { return function (e) {
checkMetadata(test.name, e, test);
var check = function(t) { return function (e) {
checkMetadata(t.name, e, t);
}}(test);
var otherType = type.match(/^video\//) ? "audio/x-wav" : "video/ogg";
@ -130,8 +130,8 @@ for (var i = 0; i < gSmallTests.length; ++i) {
maketest(late_add_sources_first, src, type, check));
}
function startTest(test, token) {
test(token);
function startTest(t, token) {
t(token);
}
manager.runTests(subtests, startTest);

View file

@ -49,7 +49,7 @@ async function startTest() {
// We'll stop recording upon the 1st blob being received
if (dataAvailableCount === 1) {
mediaRecorder.onstop = function (evt) {
mediaRecorder.onstop = function (event) {
info('onstop fired');
if (!onDataAvailableFirst) {

View file

@ -13,7 +13,7 @@ function unexpected({type}) {
ok(false, `${type} unexpectedly fired`);
}
(async _ => {
(async () => {
SimpleTest.waitForExplicitFinish();
let blobUrl = null;
let stream = null;
@ -78,7 +78,7 @@ function unexpected({type}) {
await Promise.race([
new Promise(res => video.onended = res),
new Promise((_, rej) => video.onerror = _ => rej(video.error.message)),
new Promise((res, rej) => video.onerror = () => rej(video.error.message)),
]);
} catch (e) {
ok(false, e);

View file

@ -68,7 +68,7 @@ function startTest(test, token) {
// We'll stop recording upon the 1st blob being received
if (dataAvailableCount === 1) {
mediaRecorder.onstop = function (evt) {
mediaRecorder.onstop = function (event) {
info('onstop fired');
if (!onDataAvailableFirst) {

View file

@ -13,21 +13,21 @@
var manager = new MediaTestManager;
function startTest(test, token) {
var v = document.createElement('video');
v.token = token;
var video = document.createElement('video');
video.token = token;
manager.started(token);
v.src = test.name;
v.name = test.name;
v.playingCount = 0;
v._playedOnce = false;
video.src = test.name;
video.name = test.name;
video.playingCount = 0;
video._playedOnce = false;
var check = function(test, v) { return function() {
checkMetadata(test.name, v, test);
}}(test, v);
var check = function(t, v) { return function() {
checkMetadata(t.name, v, test);
}}(test, video);
var noLoad = function(test, v) { return function() {
ok(false, test.name + " should not fire 'load' event");
}}(test, v);
var noLoad = function(t, v) { return function() {
ok(false, t.name + " should not fire 'load' event");
}}(test, video);
function finish(v) {
removeNodeAndSource(v);
@ -40,14 +40,14 @@ function startTest(test, token) {
}
}
var checkEnded = function(test, v) { return function() {
if (test.duration) {
ok(Math.abs(v.currentTime - test.duration) < 0.1,
test.name + " current time at end: " + v.currentTime);
var checkEnded = function(t, v) { return function() {
if (t.duration) {
ok(Math.abs(v.currentTime - t.duration) < 0.1,
t.name + " current time at end: " + v.currentTime);
}
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, test.name + " checking playback has ended");
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended");
ok(v.playingCount > 0, "Expect at least one playing event");
v.playingCount = 0;
@ -58,33 +58,33 @@ function startTest(test, token) {
v._playedOnce = true;
v.play();
}
}}(test, v);
}}(test, video);
var checkSuspended = function(test, v) { return function() {
var checkSuspended = function(t, v) { return function() {
if (v.seenSuspend) {
return;
}
v.seenSuspend = true;
ok(true, test.name + " got suspend");
ok(true, t.name + " got suspend");
mayFinish(v);
}}(test, v);
}}(test, video);
var checkPlaying = function(test, v) { return function() {
is(test.name, v.name, "Should be testing file we think we're testing...");
var checkPlaying = function(t, v) { return function() {
is(t.name, v.name, "Should be testing file we think we're testing...");
v.playingCount++;
}}(test, v);
}}(test, video);
v.addEventListener("load", noLoad);
v.addEventListener("loadedmetadata", check);
v.addEventListener("playing", checkPlaying);
video.addEventListener("load", noLoad);
video.addEventListener("loadedmetadata", check);
video.addEventListener("playing", checkPlaying);
// We should get "ended" and "suspend" events for every resource
v.addEventListener("ended", checkEnded);
v.addEventListener("suspend", checkSuspended);
video.addEventListener("ended", checkEnded);
video.addEventListener("suspend", checkSuspended);
document.body.appendChild(v);
v.play();
document.body.appendChild(video);
video.play();
}
manager.runTests(gReplayTests, startTest);

View file

@ -13,91 +13,91 @@
var manager = new MediaTestManager;
function startTest(test, token) {
var v = document.createElement('video');
v.preload = "metadata";
v.token = token;
v.prevTime = 0;
v.seenEnded = false;
v.seenSuspend = false;
var video = document.createElement('video');
video.preload = "metadata";
video.token = token;
video.prevTime = 0;
video.seenEnded = false;
video.seenSuspend = false;
var handler = {
"ontimeout": function() {
Log(token, "timed out: ended=" + v.seenEnded + ", suspend=" + v.seenSuspend);
Log(token, "timed out: ended=" + video.seenEnded + ", suspend=" + video.seenSuspend);
}
};
manager.started(token, handler);
v.src = test.name;
v.name = test.name;
video.src = test.name;
video.name = test.name;
var check = function(test, v) { return function() {
is(test.name, v.name, test.name + ": Name should match #1");
checkMetadata(test.name, v, test);
}}(test, v);
var check = function(t, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #1");
checkMetadata(t.name, v, t);
}}(test, video);
var noLoad = function(test, v) { return function() {
ok(false, test.name + " should not fire 'load' event");
}}(test, v);
var noLoad = function(t, v) { return function() {
ok(false, t.name + " should not fire 'load' event");
}}(test, video);
var noError = function(test, v) { return function() {
ok(false, test.name + " should not fire 'error' event " + v.error.message);
}}(test, v);
var noError = function(t, v) { return function() {
ok(false, t.name + " should not fire 'error' event " + v.error.message);
}}(test, video);
var finish = function() {
v.finished = true;
v.removeEventListener("timeupdate", timeUpdate);
removeNodeAndSource(v);
manager.finished(v.token);
video.finished = true;
video.removeEventListener("timeupdate", timeUpdate);
removeNodeAndSource(video);
manager.finished(video.token);
}
// We should get "ended" and "suspend" events to finish the test.
var mayFinish = function() {
if (v.seenEnded && v.seenSuspend) {
if (video.seenEnded && video.seenSuspend) {
finish();
}
}
var checkEnded = function(test, v) { return function() {
is(test.name, v.name, test.name + ": Name should match #2");
checkMetadata(test.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, test.name + " checking playback has ended");
ok(!v.finished, test.name + " shouldn't be finished");
ok(!v.seenEnded, test.name + " shouldn't be ended");
var checkEnded = function(t, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #2");
checkMetadata(t.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended");
ok(!v.finished, t.name + " shouldn't be finished");
ok(!v.seenEnded, t.name + " shouldn't be ended");
v.seenEnded = true;
mayFinish();
}}(test, v);
}}(test, video);
var checkSuspended = function(test, v) { return function() {
var checkSuspended = function(t, v) { return function() {
if (v.seenSuspend) {
return;
}
is(test.name, v.name, test.name + ": Name should match #3");
is(t.name, v.name, t.name + ": Name should match #3");
v.seenSuspend = true;
mayFinish();
}}(test, v);
}}(test, video);
var timeUpdate = function(test, v) { return function() {
var timeUpdate = function(t, v) { return function() {
if (v.prevTime > v.currentTime) {
ok(false, test.name + " time should run forwards: p=" +
ok(false, t.name + " time should run forwards: p=" +
v.prevTime + " c=" + v.currentTime);
}
v.prevTime = v.currentTime;
}}(test, v);
}}(test, video);
v.addEventListener("load", noLoad);
v.addEventListener("error", noError);
v.addEventListener("loadedmetadata", check);
v.addEventListener("timeupdate", timeUpdate);
video.addEventListener("load", noLoad);
video.addEventListener("error", noError);
video.addEventListener("loadedmetadata", check);
video.addEventListener("timeupdate", timeUpdate);
// We should get "ended" and "suspend" events for every resource
v.addEventListener("ended", checkEnded);
v.addEventListener("suspend", checkSuspended);
video.addEventListener("ended", checkEnded);
video.addEventListener("suspend", checkSuspended);
document.body.appendChild(v);
v.play();
document.body.appendChild(video);
video.play();
}
manager.runTests(gPlayTests, startTest);

View file

@ -13,10 +13,10 @@
var manager = new MediaTestManager;
function startTest(test, token) {
var v = document.createElement('video');
var video = document.createElement('video');
manager.started(token);
v._errorCount = 0;
v._ignore = false;
video._errorCount = 0;
video._ignore = false;
function endedTest(v) {
if (v._ignore)
return;
@ -24,20 +24,20 @@ function startTest(test, token) {
v.remove();
manager.finished(token);
}
var checkError = function(test, v) { return function(evt) {
var checkError = function(t, v) { return function(evt) {
v._errorCount++;
is(v._errorCount, 1, test.name + " only one error fired");
is(v._errorCount, 1, t.name + " only one error fired");
endedTest(v);
}}(test, v);
var checkEnded = function(test, v) { return function() {
ok(false, test.name + " successfully played");
}}(test, video);
var checkEnded = function(t, v) { return function() {
ok(false, t.name + " successfully played");
endedTest(v);
}}(test, v);
v.addEventListener("error", checkError);
v.addEventListener("ended", checkEnded);
v.src = test.name;
document.body.appendChild(v);
v.play();
}}(test, video);
video.addEventListener("error", checkError);
video.addEventListener("ended", checkEnded);
video.src = test.name;
document.body.appendChild(video);
video.play();
}
manager.runTests(gErrorTests, startTest);

View file

@ -13,74 +13,74 @@
var manager = new MediaTestManager;
function startTest(test, token) {
var v = document.createElement('video');
v.preload = "metadata";
v.token = token;
v.prevTime = 0;
v.seenEnded = false;
var video = document.createElement('video');
video.preload = "metadata";
video.token = token;
video.prevTime = 0;
video.seenEnded = false;
var handler = {
"ontimeout": function() {
Log(token, "timed out: ended=" + v.seenEnded);
Log(token, "timed out: ended=" + video.seenEnded);
}
};
manager.started(token, handler);
v.src = test.name;
v.name = test.name;
video.src = test.name;
video.name = test.name;
var check = function(test, v) { return function() {
is(test.name, v.name, test.name + ": Name should match #1");
checkMetadata(test.name, v, test);
}}(test, v);
var check = function(t, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #1");
checkMetadata(t.name, v, t);
}}(test, video);
var noLoad = function(test, v) { return function() {
ok(false, test.name + " should not fire 'load' event");
}}(test, v);
var noLoad = function(t, v) { return function() {
ok(false, t.name + " should not fire 'load' event");
}}(test, video);
var finish = function() {
v.finished = true;
v.removeEventListener("timeupdate", timeUpdate);
removeNodeAndSource(v);
manager.finished(v.token);
video.finished = true;
video.removeEventListener("timeupdate", timeUpdate);
removeNodeAndSource(video);
manager.finished(video.token);
}
// We should get "ended" events to finish the test.
var mayFinish = function() {
if (v.seenEnded) {
if (video.seenEnded) {
finish();
}
}
var checkEnded = function(test, v) { return function() {
is(test.name, v.name, test.name + ": Name should match #2");
checkMetadata(test.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, test.name + " checking playback has ended");
ok(!v.finished, test.name + " shouldn't be finished");
ok(!v.seenEnded, test.name + " shouldn't be ended");
var checkEnded = function(t, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #2");
checkMetadata(t.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended");
ok(!v.finished, t.name + " shouldn't be finished");
ok(!v.seenEnded, t.name + " shouldn't be ended");
v.seenEnded = true;
mayFinish();
}}(test, v);
}}(test, video);
var timeUpdate = function(test, v) { return function() {
var timeUpdate = function(t, v) { return function() {
if (v.prevTime > v.currentTime) {
ok(false, test.name + " time should run forwards: p=" +
ok(false, t.name + " time should run forwards: p=" +
v.prevTime + " c=" + v.currentTime);
}
v.prevTime = v.currentTime;
}}(test, v);
}}(test, video);
v.addEventListener("load", noLoad);
v.addEventListener("loadedmetadata", check);
v.addEventListener("timeupdate", timeUpdate);
video.addEventListener("load", noLoad);
video.addEventListener("loadedmetadata", check);
video.addEventListener("timeupdate", timeUpdate);
// We should get "ended" events for the hls resource
v.addEventListener("ended", checkEnded);
video.addEventListener("ended", checkEnded);
document.body.appendChild(v);
v.play();
document.body.appendChild(video);
video.play();
}
manager.runTests(gHLSTests, startTest);

View file

@ -20,22 +20,22 @@
var manager = new MediaTestManager;
function startTest(test, token) {
var v = document.createElement('video');
v.preload = "metadata";
v.token = token;
var video = document.createElement('video');
video.preload = "metadata";
video.token = token;
var handler = {
"ontimeout": function() {
Log(token, "timed out: ended=" + v.seenEnded + ", suspend=" + v.seenSuspend);
Log(token, "timed out: ended=" + video.seenEnded + ", suspend=" + video.seenSuspend);
}
};
manager.started(token, handler);
v.src = test.name;
v.name = test.name;
video.src = test.name;
video.name = test.name;
var check = function(test, v) { return function() {
is(test.name, v.name, test.name + ": Name should match #1");
var check = function(t, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #1");
Log(v.token, "removeChild: " + v.name);
document.body.removeChild(v);
var appendAndPlayElement = function() {
@ -45,28 +45,28 @@ function startTest(test, token) {
v.play();
}
setTimeout(appendAndPlayElement, 2000);
}}(test, v);
}}(test, video);
var finish = function() {
v.finished = true;
removeNodeAndSource(v);
manager.finished(v.token);
video.finished = true;
removeNodeAndSource(video);
manager.finished(video.token);
}
var checkEnded = function(test, v) { return function() {
is(test.name, v.name, test.name + ": Name should match #2");
checkMetadata(test.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, test.name + " checking playback has ended");
var checkEnded = function(t, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #2");
checkMetadata(t.name, v, t);
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended");
finish();
}}(test, v);
}}(test, video);
v.addEventListener("loadedmetadata", check);
v.addEventListener("ended", checkEnded);
video.addEventListener("loadedmetadata", check);
video.addEventListener("ended", checkEnded);
document.body.appendChild(v);
document.body.appendChild(video);
}
manager.runTests(gSmallTests, startTest);

View file

@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=548523
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=548523">Mozilla Bug 548523</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<!-- <button onClick="SimpleTest.finish();">Finish</button> -->
<div>Tests complete: <span id="log" style="font-size: small;"></span></div>
@ -247,7 +247,7 @@ var tests = [
suspend:
function(e) {
var v = e.target;
if (v._gotSuspend)
if (v._gotSuspend)
return; // We can receive multiple suspend events, like the one after download completes.
v._gotSuspend = true;
is(v._gotLoadStart, true, "(7) Must get loadstart.");
@ -262,7 +262,7 @@ var tests = [
function(e) {
ok(true, "(7) Got playback ended");
var v = e.target;
is(v._gotErrorEvent, true, "(7) Should get error event from first source load failure");
is(v._gotErrorEvent, true, "(7) Should get error event from first source load failure");
maybeFinish(v, 7);
},
@ -479,7 +479,6 @@ var tests = [
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
"waiting", "pause"];
function logEvent(e) {
var v = e.target;
info(e.target.token + ": got " + e.type);
}
events.forEach(function(e) {
@ -591,18 +590,18 @@ var tests = [
];
var iterationCount = 0;
function startTest(test, token) {
if (test == tests[0]) {
function startTest(t, token) {
if (t == tests[0]) {
++iterationCount;
info("iterationCount=" + iterationCount);
}
if (iterationCount == 2) {
// Do this series of tests on logically different resources
test.name = baseName + "?" + Math.floor(Math.random()*100000);
t.name = baseName + "?" + Math.floor(Math.random()*100000);
}
var v = document.createElement("video");
v.token = token;
test.setup(v);
t.setup(v);
manager.started(token);
}

View file

@ -20,9 +20,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=975270
a._abort = 0;
a._emptied = 0;
a.preload = "metadata"; // On B2G we default to preload:none.
is(a.networkState, HTMLMediaElement.NETWORK_EMPTY, "Shouldn't be loading");
a.addEventListener("abort", function(e) { a._abort++; });
a.addEventListener("emptied", function(e) { a._emptied++; });
a.addEventListener("loadedmetadata",
@ -31,7 +31,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=975270
is(a._emptied, 0, "Should not have received 'emptied' before 'loadedmetadata");
a.addEventListener("loadstart",
function(e) {
function() {
is(a._abort, 1, "Should have received 'abort' before 'loadstart");
is(a._emptied, 1, "Should have received 'emptied' before 'loadstart");
SimpleTest.finish();
@ -41,9 +41,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=975270
is(a._abort, 0, "Should not have received 'abort' during setting a.src=''");
is(a._emptied, 0, "Should not have received 'emptied' during setting a.src=''");
});
a.src = getPlayableAudio(gSmallTests).name;
</script>
</head>
<body>

View file

@ -35,7 +35,7 @@ function onLoadedData_Audio(e) {
var c = document.getElementsByTagName("canvas")[0].getContext("2d");
try {
c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth);
} catch (e) {
} catch (ex) {
ok(true, t.name + ": Trying to draw to a canvas should throw, since we don't have a frame anymore");
finish(t);
return;

View file

@ -13,68 +13,68 @@
var manager = new MediaTestManager;
function startTest(test, token) {
var v = document.createElement('video');
v.preload = "metadata";
v.token = token;
v.seenSeeking = false;
v.seenEnded = false;
var video = document.createElement('video');
video.preload = "metadata";
video.token = token;
video.seenSeeking = false;
video.seenEnded = false;
var handler = {
"ontimeout": function() {
Log(token, "timed out: ended=" + v.seenEnded);
Log(token, "timed out: ended=" + video.seenEnded);
}
};
manager.started(token, handler);
v.src = test.name;
v.name = test.name;
video.src = test.name;
video.name = test.name;
function callSeekToNextFrame() {
v.seekToNextFrame().then(
video.seekToNextFrame().then(
() => {
if (!v.seenSeeking) {
ok(false, v.token + ": Should have already received seeking event.");
if (!video.seenSeeking) {
ok(false, video.token + ": Should have already received seeking event.");
}
v.seenSeeking = false;
if (!v.ended) {
video.seenSeeking = false;
if (!video.ended) {
callSeekToNextFrame();
}
},
() => {
ok(false, v.token + ": seekToNextFrame() failed.");
ok(false, video.token + ": seekToNextFrame() failed.");
}
);
}
var onLoadedmetadata = function(test, v) { return function() {
var onLoadedmetadata = function(t, v) { return function() {
callSeekToNextFrame();
}}(test, v);
}}(test, video);
var finish = function() {
v.finished = true;
v.removeEventListener("loadedmetadata", onLoadedmetadata);
v.removeEventListener("seeking", onSeeking);
removeNodeAndSource(v);
manager.finished(v.token);
video.finished = true;
video.removeEventListener("loadedmetadata", onLoadedmetadata);
video.removeEventListener("seeking", onSeeking);
removeNodeAndSource(video);
manager.finished(video.token);
}
var onEnded = function(test, v) { return function() {
var onEnded = function(t, v) { return function() {
v.seenEnded = true;
finish();
}}(test, v);
}}(test, video);
var onSeeking = function(test, v) { return function() {
var onSeeking = function(t, v) { return function() {
if (v.seenSeeking) {
ok(false, v.token + ": Should yet receive seeking event.");
}
v.seenSeeking = true;
}}(test, v);
}}(test, video);
v.addEventListener("loadedmetadata", onLoadedmetadata);
v.addEventListener("seeking", onSeeking);
v.addEventListener("ended", onEnded);
video.addEventListener("loadedmetadata", onLoadedmetadata);
video.addEventListener("seeking", onSeeking);
video.addEventListener("ended", onEnded);
document.body.appendChild(v);
document.body.appendChild(video);
}
SimpleTest.waitForExplicitFinish();
@ -92,4 +92,4 @@ SpecialPowers.pushPrefEnv(
</script>
</pre>
</body>
</html>
</html>

View file

@ -36,8 +36,8 @@ function startTest(test, token) {
"loadedmetadata", "loadeddata", "playing", "ended", "error",
"stalled", "emptied", "abort", "waiting", "pause" ];
function logEvent(e) {
var v = e.target;
Log(e.target.token, "got " + e.type + " with currentTime = " + v.currentTime);
var video = e.target;
Log(e.target.token, "got " + e.type + " with currentTime = " + video.currentTime);
}
events.forEach(function(e) {
v.addEventListener(e, logEvent);

View file

@ -13,7 +13,7 @@
var iframes = [];
for (var i=0; i<gSmallTests.length; ++i) {
for (let i=0; i<gSmallTests.length; ++i) {
var test = gSmallTests[i];
// We can't play WAV files in stand alone documents, so just don't
@ -21,8 +21,8 @@ for (var i=0; i<gSmallTests.length; ++i) {
var tag = getMajorMimeType(test.type);
if (tag != "video" || !document.createElement("video").canPlayType(test.type))
continue;
var f = document.createElement("iframe");
let f = document.createElement("iframe");
f.src = test.name;
f._test = test;
f.id = "frame" + i;
@ -37,8 +37,8 @@ function filename(uri) {
function doTest()
{
for (var i=0; i<iframes.length; ++i) {
var f = document.getElementById(iframes[i].id);
for (let i=0; i<iframes.length; ++i) {
let f = document.getElementById(iframes[i].id);
var v = f.contentDocument.body.firstChild;
is(v.tagName.toLowerCase(), "video", "Is video element");
var src = filename(v.currentSrc);

View file

@ -68,8 +68,8 @@ async function startTest(test, token) {
new Promise(r => vout.onended = r),
new Promise(r => v.onended = r),
]),
new Promise((_, r) => vout.onerror = _ => r(new Error(vout.error.message))),
new Promise((_, r) => v.onerror = _ => r(new Error(v.error.message))),
new Promise((res, rej) => vout.onerror = () => rej(new Error(vout.error.message))),
new Promise((res, rej) => v.onerror = () => rej(new Error(v.error.message))),
]);
let duration = test.duration;

View file

@ -19,12 +19,12 @@ var vout = document.getElementById('vout');
var vout_untilended = document.getElementById('vout_untilended');
function dumpEvent(event) {
var v = event.target;
info(v.name + " GOT EVENT " + event.type +
" currentTime=" + v.currentTime +
" paused=" + v.paused +
" ended=" + v.ended +
" readyState=" + v.readyState);
var video = event.target;
info(video.name + " GOT EVENT " + event.type +
" currentTime=" + video.currentTime +
" paused=" + video.paused +
" ended=" + video.ended +
" readyState=" + video.readyState);
}
var events = ["timeupdate", "seeking", "seeked", "ended", "playing", "pause"];

View file

@ -15,12 +15,12 @@ SimpleTest.waitForExplicitFinish();
let v = document.getElementById('v');
function dumpEvent(event) {
let v = event.target;
info(v.name + " GOT EVENT " + event.type +
" currentTime=" + v.currentTime +
" paused=" + v.paused +
" ended=" + v.ended +
" readyState=" + v.readyState);
let video = event.target;
info(video.name + " GOT EVENT " + event.type +
" currentTime=" + video.currentTime +
" paused=" + video.paused +
" ended=" + video.ended +
" readyState=" + video.readyState);
}
let events = ["timeupdate", "seeking", "seeked", "ended", "playing", "pause"];

View file

@ -24,8 +24,8 @@ function ended(e) {
ok(v.counter["timeupdate"] > 0, v._name + " should see at least one timeupdate: " + v.currentTime);
// Rest event counters for we don't allow events after ended.
eventsToLog.forEach(function(e) {
v.counter[e] = 0;
eventsToLog.forEach(function(event) {
v.counter[event] = 0;
});
// Finish the test after 500ms. We shouldn't receive any timeupdate events
@ -39,8 +39,8 @@ function ended(e) {
// invoked when it's removed from a document), and we don't want those
// confusing the test results.
v.removeEventListener("ended", ended);
eventsToLog.forEach(function(e) {
v.removeEventListener(e, logEvent);
eventsToLog.forEach(function(event) {
v.removeEventListener(event, logEvent);
});
removeNodeAndSource(v);
manager.finished(v.token);

View file

@ -19,10 +19,10 @@ var startTest = function(test, token) {
v.src = test.name;
function ended(event) {
var v = event.target;
is(v.getVideoPlaybackQuality().totalVideoFrames, test.totalFrameCount,test.name+ " totalFrames should match!");
removeNodeAndSource(v);
manager.finished(v.token);
var video = event.target;
is(video.getVideoPlaybackQuality().totalVideoFrames, test.totalFrameCount,test.name+ " totalFrames should match!");
removeNodeAndSource(video);
manager.finished(video.token);
}
v.addEventListener("ended", ended);
v.play();