Bug 1556854 - Enable ESLint for dom/media/test/ - Enable automatically fixable rules. r=jya.

This enables the following rules:

    - dot-notation
    - mozilla/no-useless-parameters
    - no-else-return
    - no-useless-return
    - object-shorthand

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2019-10-24 10:51:01 +00:00
Родитель 7c19d4e5c5
Коммит c34c417518
23 изменённых файлов: 87 добавлений и 138 удалений

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

@ -388,13 +388,10 @@ module.exports = {
], ],
"rules": { "rules": {
"consistent-return": "off", "consistent-return": "off",
"dot-notation": "off",
"mozilla/no-useless-parameters": "off",
"mozilla/use-default-preference-values": "off", "mozilla/use-default-preference-values": "off",
"mozilla/use-services": "off", "mozilla/use-services": "off",
"no-array-constructor": "off", "no-array-constructor": "off",
"no-async-promise-executor": "off", "no-async-promise-executor": "off",
"no-else-return": "off",
"no-redeclare": "off", "no-redeclare": "off",
"no-nested-ternary": "off", "no-nested-ternary": "off",
"no-self-assign": "off", "no-self-assign": "off",
@ -402,8 +399,6 @@ module.exports = {
"no-undef": "off", "no-undef": "off",
"no-unsanitized/property": "off", "no-unsanitized/property": "off",
"no-unused-vars": "off", "no-unused-vars": "off",
"no-useless-return": "off",
"object-shorthand": "off",
} }
}] }]
}; };

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

@ -137,7 +137,7 @@ function GenerateClearKeyLicense(licenseRequest, keyStore) {
return new TextEncoder().encode( return new TextEncoder().encode(
JSON.stringify({ JSON.stringify({
keys: keys, keys,
type: msg.type || "temporary", type: msg.type || "temporary",
}) })
); );
@ -165,9 +165,8 @@ function UpdateSessionFunc(test, token, sessionType, resolve, reject) {
function MaybeCrossOriginURI(test, uri) { function MaybeCrossOriginURI(test, uri) {
if (test.crossOrigin) { if (test.crossOrigin) {
return "https://example.com:443/tests/dom/media/test/allowed.sjs?" + uri; return "https://example.com:443/tests/dom/media/test/allowed.sjs?" + uri;
} else {
return uri;
} }
return uri;
} }
function AppendTrack(test, ms, track, token) { function AppendTrack(test, ms, track, token) {

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

@ -23,7 +23,7 @@
} else if (event.data == "play-muted") { } else if (event.data == "play-muted") {
playAndPostResult(true, event.source); playAndPostResult(true, event.source);
} }
}, false); });
let w = window.opener || window.parent; let w = window.opener || window.parent;
w.postMessage("ready", "*"); w.postMessage("ready", "*");
</script> </script>

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

@ -41,7 +41,7 @@
let p = await element.play().then(() => true, () => false); let p = await element.play().then(() => true, () => false);
ok(p, "Expect to be activated already in " + eventName); ok(p, "Expect to be activated already in " + eventName);
resolve(); resolve();
}, false); });
}); });
}); });

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

@ -1918,9 +1918,8 @@ function getPlayableAudio(candidates) {
function getMajorMimeType(mimetype) { function getMajorMimeType(mimetype) {
if (/^video/.test(mimetype)) { if (/^video/.test(mimetype)) {
return "video"; return "video";
} else {
return "audio";
} }
return "audio";
} }
// Force releasing decoder to avoid timeout in waiting for decoding resource. // Force releasing decoder to avoid timeout in waiting for decoding resource.
@ -1959,10 +1958,10 @@ function once(target, name, cb) {
function nextEvent(video, eventName) { function nextEvent(video, eventName) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
let f = function(event) { let f = function(event) {
video.removeEventListener(eventName, f, false); video.removeEventListener(eventName, f);
resolve(event); resolve(event);
}; };
video.addEventListener(eventName, f, false); video.addEventListener(eventName, f);
}); });
} }
@ -2186,7 +2185,6 @@ function MediaTestManager() {
SimpleTest.finish(); SimpleTest.finish();
}; };
mediaTestCleanup(onCleanup); mediaTestCleanup(onCleanup);
return;
} }
}; };
} }

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

@ -9,10 +9,10 @@ video.mozRequestDebugInfo().then(debugInfo => {
} }
JSONDebugInfo = JSONDebugInfo.slice(0, JSONDebugInfo.length - 1); JSONDebugInfo = JSONDebugInfo.slice(0, JSONDebugInfo.length - 1);
JSONDebugInfo += "}"; JSONDebugInfo += "}";
result["mozRequestDebugInfo"] = JSON.parse(JSONDebugInfo); result.mozRequestDebugInfo = JSON.parse(JSONDebugInfo);
} catch (err) { } catch (err) {
console.log(`Error '${err.toString()} in JSON.parse(${debugInfo})`); console.log(`Error '${err.toString()} in JSON.parse(${debugInfo})`);
result["mozRequestDebugInfo"] = debugInfo; result.mozRequestDebugInfo = debugInfo;
} }
resolve(result); resolve(result);
}); });

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

@ -5,11 +5,11 @@ var config = {
HD: true, HD: true,
LQ: false, LQ: false,
ID: "auto-hd-lq-for-ytb", ID: "auto-hd-lq-for-ytb",
type: function(t) { type(t) {
config.HD = t === "hd"; config.HD = t === "hd";
config.LQ = t === "lq"; config.LQ = t === "lq";
}, },
quality: function() { quality() {
if (config.HD || config.LQ) { if (config.HD || config.LQ) {
var youtubePlayerListener = function(LQ, HD) { var youtubePlayerListener = function(LQ, HD) {
return function(e) { return function(e) {

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

@ -101,7 +101,7 @@ function createAudioParams(nodeType) {
return [ac.createStereoPanner().pan]; return [ac.createStereoPanner().pan];
default: default:
ok(false, `non-defined node type ${nodeType}.`); ok(false, `non-defined node type ${nodeType}.`);
return;
} }
} }

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

@ -76,6 +76,6 @@
["privacy.reduceTimerPrecision", false] ["privacy.reduceTimerPrecision", false]
], ],
tests: gDecodeSuspendTests, tests: gDecodeSuspendTests,
runTest: runTest runTest
}); });
</script> </script>

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

@ -50,6 +50,6 @@
["media.suspend-bkgnd-video.delay-ms", 1000] ["media.suspend-bkgnd-video.delay-ms", 1000]
], ],
tests: gDecodeSuspendTests, tests: gDecodeSuspendTests,
runTest: runTest runTest
}); });
</script> </script>

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

@ -21,7 +21,7 @@ function onloaded(event) {
var v = event.target; var v = event.target;
v.removeEventListener("loadedmetadata", onloaded); v.removeEventListener("loadedmetadata", onloaded);
v.currentTime = v.duration; v.currentTime = v.duration;
return;
} }
function checkNotPlaying(v) { function checkNotPlaying(v) {

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

@ -26,9 +26,9 @@ function e(id) {
var gLoadError = new Object(); var gLoadError = new Object();
gLoadError['video1'] = 0; gLoadError.video1 = 0;
gLoadError['video2'] = 0; gLoadError.video2 = 0;
gLoadError['video3'] = 0; gLoadError.video3 = 0;
var gErrorCount = 0; var gErrorCount = 0;
@ -45,9 +45,9 @@ function finishTest() {
filename(e('video3').src), filename(e('video3').src),
'video3 currentSrc should match src'); 'video3 currentSrc should match src');
is(gLoadError['video1'], 2, "Expect one error per invalid source child on video1"); is(gLoadError.video1, 2, "Expect one error per invalid source child on video1");
is(gLoadError['video2'], 1, "Expect one error on video2"); is(gLoadError.video2, 1, "Expect one error on video2");
is(gLoadError['video3'], 1, "Expect one error on video3"); is(gLoadError.video3, 1, "Expect one error on video3");
SimpleTest.finish(); SimpleTest.finish();
} }

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

@ -117,7 +117,7 @@
session.generateRequest(event.initDataType, event.initData); session.generateRequest(event.initDataType, event.initData);
} }
video.addEventListener("encrypted", handleEncrypted, false); video.addEventListener("encrypted", handleEncrypted);
video.addEventListener("ended", () => { video.addEventListener("ended", () => {
let expectedEncryptedEvents = let expectedEncryptedEvents =

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

@ -116,7 +116,7 @@ function startTest(test, token) {
removeNodeAndSource(v); removeNodeAndSource(v);
m.finished(v.token); m.finished(v.token);
}}(video, manager); }}(video, manager);
window['test_fragment_noplay'](video, test.start, test.end, localIs, localOk, localFinish); window.test_fragment_noplay(video, test.start, test.end, localIs, localOk, localFinish);
} }
manager.runTests(createTestArray(), startTest); manager.runTests(createTestArray(), startTest);

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

@ -80,7 +80,7 @@ function startTest(test, token) {
removeNodeAndSource(v); removeNodeAndSource(v);
m.finished(v.token); m.finished(v.token);
}}(video, manager); }}(video, manager);
window['test_fragment_play'](video, test.start, test.end, localIs, localOk, localFinish); window.test_fragment_play(video, test.start, test.end, localIs, localOk, localFinish);
} }
manager.runTests(createTestArray(), startTest); manager.runTests(createTestArray(), startTest);

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

@ -89,16 +89,14 @@ function prependSource(src, type) {
var gTests = [ var gTests = [
{ {
// Test 0: adding video to doc, then setting src should load implicitly. // Test 0: adding video to doc, then setting src should load implicitly.
create: create(src, type) {
function(src, type) {
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
gMedia.src = src; gMedia.src = src;
}, },
expectedEvents: ['loadstart', 'durationchange', 'loadedmetadata', 'loadeddata'] expectedEvents: ['loadstart', 'durationchange', 'loadedmetadata', 'loadeddata']
}, { }, {
// Test 1: adding video to doc, then adding source. // Test 1: adding video to doc, then adding source.
create: create(src, type) {
function(src, type) {
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
addSource(src, type); addSource(src, type);
}, },
@ -106,8 +104,7 @@ var gTests = [
},{ },{
// Test 2: video with multiple source, the first of which are bad, we should load the last, // Test 2: video with multiple source, the first of which are bad, we should load the last,
// and receive error events for failed loads on the source children. // and receive error events for failed loads on the source children.
create: create(src, type) {
function(src, type) {
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
addSource("404a", type); addSource("404a", type);
addSource("404b", type); addSource("404b", type);
@ -116,8 +113,7 @@ var gTests = [
expectedEvents: ['loadstart', 'source_error', 'source_error', 'durationchange', 'loadedmetadata', 'loadeddata'] expectedEvents: ['loadstart', 'source_error', 'source_error', 'durationchange', 'loadedmetadata', 'loadeddata']
}, { }, {
// Test 3: video with bad src, good <source>, ensure that <source> aren't used. // Test 3: video with bad src, good <source>, ensure that <source> aren't used.
create: create(src, type) {
function(src, type) {
gMedia.src = "404a"; gMedia.src = "404a";
addSource(src, type); addSource(src, type);
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
@ -126,8 +122,7 @@ var gTests = [
}, { }, {
// Test 4: video with only bad source, loading, then adding a good source // Test 4: video with only bad source, loading, then adding a good source
// - should resume load. // - should resume load.
create: create(src, type) {
function(src, type) {
addSource("404a", type); addSource("404a", type);
var s2 = addSource("404b", type); var s2 = addSource("404b", type);
s2.addEventListener("error", s2.addEventListener("error",
@ -143,8 +138,7 @@ var gTests = [
// a good <source> to the video, it shouldn't be selected, because the // a good <source> to the video, it shouldn't be selected, because the
// "pointer" should be after the last child - the bad source. // "pointer" should be after the last child - the bad source.
prepended: false, prepended: false,
create: create(src, type) {
function(src, type) {
var prepended = false; var prepended = false;
addSource("404a", type); addSource("404a", type);
var s2 = addSource("404b", type); var s2 = addSource("404b", type);
@ -162,8 +156,7 @@ var gTests = [
}, { }, {
// Test 6: (Bug 1165203) preload="none" then followed by an explicit // Test 6: (Bug 1165203) preload="none" then followed by an explicit
// call to load() should load metadata // call to load() should load metadata
create: create(src, type) {
function(src, type) {
gMedia.preload = "none"; gMedia.preload = "none";
gMedia.src = src; gMedia.src = src;
document.body.appendChild(gMedia); document.body.appendChild(gMedia);

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

@ -34,12 +34,12 @@
element.addEventListener("loadedmetadata", ()=>{ element.addEventListener("loadedmetadata", ()=>{
resolve(true); resolve(true);
removeNodeAndSource(element); removeNodeAndSource(element);
}, false); });
element.addEventListener("error", ()=>{ element.addEventListener("error", ()=>{
resolve(false); resolve(false);
removeNodeAndSource(element); removeNodeAndSource(element);
}, false); });
var noise = Math.floor(Math.random() * 100000000); var noise = Math.floor(Math.random() * 100000000);
// Note: request redirect before the end of metadata, otherwise we won't // Note: request redirect before the end of metadata, otherwise we won't

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

@ -32,7 +32,7 @@ function check_full_file_played(element) {
var tests = [ var tests = [
// Without playing, check that player.played.length == 0. // Without playing, check that player.played.length == 0.
{ {
setup : function(element) { setup(element) {
element.addEventListener("loadedmetadata", function() { element.addEventListener("loadedmetadata", function() {
is(element.played.length, 0, element.token + ": initial played.length equals zero"); is(element.played.length, 0, element.token + ": initial played.length equals zero");
finish_test(element); finish_test(element);
@ -42,7 +42,7 @@ var tests = [
}, },
// Play the file, test the range we have. // Play the file, test the range we have.
{ {
setup : function(element) { setup(element) {
check_full_file_played(element); check_full_file_played(element);
element.play(); element.play();
}, },
@ -52,7 +52,7 @@ var tests = [
// Play the second half of the file, pause, play // Play the second half of the file, pause, play
// an check we have only one range. // an check we have only one range.
{ {
setup : function (element) { setup (element) {
element.onended = function (e) { element.onended = function (e) {
var t = e.target; var t = e.target;
t.onended = null; t.onended = null;
@ -72,7 +72,7 @@ var tests = [
// Play the first half of the file, seek back, while // Play the first half of the file, seek back, while
// continuing to play. We shall have only one range. // continuing to play. We shall have only one range.
{ {
setup : function (element) { setup (element) {
let onTimeUpdate = function() { let onTimeUpdate = function() {
if (element.currentTime > element.duration / 2) { if (element.currentTime > element.duration / 2) {
info(element.token + ": currentTime=" + element.currentTime + ", duration=" + element.duration); info(element.token + ": currentTime=" + element.currentTime + ", duration=" + element.duration);
@ -95,7 +95,7 @@ var tests = [
// Play and seek to have two ranges, and check that, as well a // Play and seek to have two ranges, and check that, as well a
// boundaries. // boundaries.
{ {
setup : function (element) { setup (element) {
let seekTarget = 0; let seekTarget = 0;
let onTimeUpdate = function() { let onTimeUpdate = function() {
if (element.currentTime > element.duration / 2) { if (element.currentTime > element.duration / 2) {
@ -132,7 +132,7 @@ var tests = [
// Play to create two ranges, in the reverse order. check that they are sorted. // Play to create two ranges, in the reverse order. check that they are sorted.
{ {
setup : function (element) { setup (element) {
function end() { function end() {
element.pause(); element.pause();
let p = element.played; let p = element.played;
@ -178,7 +178,7 @@ var tests = [
}, },
// Seek repeatedly without playing. No range should appear. // Seek repeatedly without playing. No range should appear.
{ {
setup : function(element) { setup(element) {
let index = 1; let index = 1;
element.addEventListener('seeked', function() { element.addEventListener('seeked', function() {

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

@ -65,8 +65,7 @@ var tests = [
// after receiving a suspend event. Should not receive loaded events until after we call load(). // after receiving a suspend event. Should not receive loaded events until after we call load().
// Note the suspend event is explictly sent by our "stop the load" code, but other tests can't rely // Note the suspend event is explictly sent by our "stop the load" code, but other tests can't rely
// on it for the preload:metadata case, as there can be multiple suspend events when loading metadata. // on it for the preload:metadata case, as there can be multiple suspend events when loading metadata.
suspend: suspend(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(1) Must get loadstart."); is(v._gotLoadStart, true, "(1) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(1) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(1) Must not get loadedmetadata.");
@ -76,8 +75,7 @@ var tests = [
maybeFinish(v, 1); maybeFinish(v, 1);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -93,8 +91,7 @@ var tests = [
{ {
// 2. Add preload:metadata video with src to document. Should halt with NETWORK_IDLE, HAVE_CURRENT_DATA // 2. Add preload:metadata video with src to document. Should halt with NETWORK_IDLE, HAVE_CURRENT_DATA
// after suspend event and after loadedmetadata. // after suspend event and after loadedmetadata.
loadeddata: loadeddata(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(2) Must get loadstart."); is(v._gotLoadStart, true, "(2) Must get loadstart.");
is(v._gotLoadedMetaData, true, "(2) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(2) Must get loadedmetadata.");
@ -104,8 +101,7 @@ var tests = [
maybeFinish(v, 2); maybeFinish(v, 2);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "metadata"; v.preload = "metadata";
@ -121,16 +117,14 @@ var tests = [
}, },
{ {
// 3. Add preload:auto to document. Should receive canplaythrough eventually. // 3. Add preload:auto to document. Should receive canplaythrough eventually.
canplaythrough: canplaythrough(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(3) Must get loadstart."); is(v._gotLoadStart, true, "(3) Must get loadstart.");
is(v._gotLoadedMetaData, true, "(3) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(3) Must get loadedmetadata.");
maybeFinish(v, 3); maybeFinish(v, 3);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "auto"; v.preload = "auto";
@ -145,8 +139,7 @@ var tests = [
}, },
{ {
// 4. Add preload:none video to document. Call play(), should load then play through. // 4. Add preload:none video to document. Call play(), should load then play through.
suspend: suspend(e) {
function(e) {
var v = e.target; var v = e.target;
if (v._gotSuspend) { if (v._gotSuspend) {
return; // We can receive multiple suspend events, like the one after download completes. return; // We can receive multiple suspend events, like the one after download completes.
@ -160,14 +153,12 @@ var tests = [
v.play(); // Should load and play through. v.play(); // Should load and play through.
}, },
ended: ended(e) {
function(e) {
ok(true, "(4) Got playback ended"); ok(true, "(4) Got playback ended");
maybeFinish(e.target, 4); maybeFinish(e.target, 4);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v._gotSuspend = false; v._gotSuspend = false;
@ -185,8 +176,7 @@ var tests = [
{ {
// 5. preload:none video without resource, add to document, will implicitly start a // 5. preload:none video without resource, add to document, will implicitly start a
// preload:none load. Add a src, it shouldn't load. // preload:none load. Add a src, it shouldn't load.
suspend: suspend(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(5) Must get loadstart."); is(v._gotLoadStart, true, "(5) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(5) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(5) Must not get loadedmetadata.");
@ -196,8 +186,7 @@ var tests = [
maybeFinish(v, 5); maybeFinish(v, 5);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -213,8 +202,7 @@ var tests = [
{ {
// 6. preload:none video without resource, add to document, will implicitly start a // 6. preload:none video without resource, add to document, will implicitly start a
// preload:none load. Add a source, it shouldn't load. // preload:none load. Add a source, it shouldn't load.
suspend: suspend(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(6) Must get loadstart."); is(v._gotLoadStart, true, "(6) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(6) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(6) Must not get loadedmetadata.");
@ -224,8 +212,7 @@ var tests = [
maybeFinish(v, 6); maybeFinish(v, 6);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -244,8 +231,7 @@ var tests = [
{ {
// 7. create a preload:none document with multiple sources, the first of which is invalid. // 7. create a preload:none document with multiple sources, the first of which is invalid.
// Add to document, then play. It should load and play through the second source. // Add to document, then play. It should load and play through the second source.
suspend: suspend(e) {
function(e) {
var v = e.target; var v = e.target;
if (v._gotSuspend) if (v._gotSuspend)
return; // We can receive multiple suspend events, like the one after download completes. return; // We can receive multiple suspend events, like the one after download completes.
@ -258,16 +244,14 @@ var tests = [
v.play(); // Should load and play through. v.play(); // Should load and play through.
}, },
ended: ended(e) {
function(e) {
ok(true, "(7) Got playback ended"); ok(true, "(7) Got playback ended");
var v = e.target; 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); maybeFinish(v, 7);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -292,8 +276,7 @@ var tests = [
}, },
{ {
// 8. Change preload value from none to metadata should cause metadata to be loaded. // 8. Change preload value from none to metadata should cause metadata to be loaded.
loadeddata: loadeddata(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadedMetaData, true, "(8) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(8) Must get loadedmetadata.");
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(8) ReadyState must be >= HAVE_CURRENT_DATA on suspend."); ok(v.readyState >= v.HAVE_CURRENT_DATA, "(8) ReadyState must be >= HAVE_CURRENT_DATA on suspend.");
@ -302,8 +285,7 @@ var tests = [
maybeFinish(v, 8); maybeFinish(v, 8);
}, },
setup: setup(v) {
function(v) {
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
v.addEventListener("loadstart", function(e){v.preload = "metadata";}); v.addEventListener("loadstart", function(e){v.preload = "metadata";});
@ -342,15 +324,13 @@ var tests = [
},*/ },*/
{ {
// 10. Change preload value from none to auto should cause entire media to be loaded. // 10. Change preload value from none to auto should cause entire media to be loaded.
canplaythrough: canplaythrough(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadedMetaData, true, "(10) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(10) Must get loadedmetadata.");
maybeFinish(v, 10); maybeFinish(v, 10);
}, },
setup: setup(v) {
function(v) {
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
v.addEventListener("loadstart", function(e){v.preload = "auto";}); v.addEventListener("loadstart", function(e){v.preload = "auto";});
@ -364,8 +344,7 @@ var tests = [
}, },
{ {
// 11. Change preload value from none to metadata should cause metadata to load. // 11. Change preload value from none to metadata should cause metadata to load.
loadeddata: loadeddata(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadedMetaData, true, "(11) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(11) Must get loadedmetadata.");
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(11) ReadyState must be >= HAVE_CURRENT_DATA."); ok(v.readyState >= v.HAVE_CURRENT_DATA, "(11) ReadyState must be >= HAVE_CURRENT_DATA.");
@ -374,8 +353,7 @@ var tests = [
maybeFinish(v, 11); maybeFinish(v, 11);
}, },
setup: setup(v) {
function(v) {
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
v.addEventListener("loadstart", function(e){v.preload = "metadata";}); v.addEventListener("loadstart", function(e){v.preload = "metadata";});
@ -390,8 +368,7 @@ var tests = [
{ {
// 13. Change preload value from auto to none after specifying a src // 13. Change preload value from auto to none after specifying a src
// should load according to preload none, no buffering should have taken place // should load according to preload none, no buffering should have taken place
suspend: suspend(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(13) Must get loadstart."); is(v._gotLoadStart, true, "(13) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(13) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(13) Must not get loadedmetadata.");
@ -401,8 +378,7 @@ var tests = [
maybeFinish(v, 13); maybeFinish(v, 13);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "auto"; v.preload = "auto";
@ -419,8 +395,7 @@ var tests = [
}, },
{ {
// 14. Add preload:metadata video with src to document. Play(), should play through. // 14. Add preload:metadata video with src to document. Play(), should play through.
loadeddata: loadeddata(e) {
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(14) Must get loadstart."); is(v._gotLoadStart, true, "(14) Must get loadstart.");
is(v._gotLoadedMetaData, true, "(14) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(14) Must get loadedmetadata.");
@ -430,15 +405,13 @@ var tests = [
v.play(); v.play();
}, },
ended: ended(e) {
function(e) {
ok(true, "(14) Got playback ended"); ok(true, "(14) Got playback ended");
var v = e.target; var v = e.target;
maybeFinish(v, 14); maybeFinish(v, 14);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "metadata"; v.preload = "metadata";
@ -455,15 +428,13 @@ var tests = [
}, },
{ {
// 15. Autoplay should override preload:none. // 15. Autoplay should override preload:none.
ended: ended(e) {
function(e) {
ok(true, "(15) Got playback ended."); ok(true, "(15) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 15); maybeFinish(v, 15);
}, },
setup: setup(v) {
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -490,15 +461,13 @@ var tests = [
}, },
{ {
// 16. Autoplay should override preload:metadata. // 16. Autoplay should override preload:metadata.
ended: ended(e) {
function(e) {
ok(true, "(16) Got playback ended."); ok(true, "(16) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 16); maybeFinish(v, 16);
}, },
setup: setup(v) {
function(v) {
v.preload = "metadata"; v.preload = "metadata";
v.autoplay = true; v.autoplay = true;
v.addEventListener("ended", this.ended); v.addEventListener("ended", this.ended);
@ -510,15 +479,13 @@ var tests = [
}, },
{ {
// 17. On a preload:none video, adding autoplay should disable preload none, i.e. don't break autoplay! // 17. On a preload:none video, adding autoplay should disable preload none, i.e. don't break autoplay!
ended: ended(e) {
function(e) {
ok(true, "(17) Got playback ended."); ok(true, "(17) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 17); maybeFinish(v, 17);
}, },
setup: setup(v) {
function(v) {
v.addEventListener("ended", this.ended); v.addEventListener("ended", this.ended);
v.preload = "none"; v.preload = "none";
document.body.appendChild(v); // Causes implicit load, which will be halted due to preload:none. document.body.appendChild(v); // Causes implicit load, which will be halted due to preload:none.
@ -531,15 +498,13 @@ var tests = [
{ {
// 18. On a preload='none' video, call play() before load algorithms's sync // 18. On a preload='none' video, call play() before load algorithms's sync
// has run, the play() call should override preload='none'. // has run, the play() call should override preload='none'.
ended: ended(e) {
function(e) {
ok(true, "(18) Got playback ended."); ok(true, "(18) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 18); maybeFinish(v, 18);
}, },
setup: setup(v) {
function(v) {
v.addEventListener("ended", this.ended); v.addEventListener("ended", this.ended);
v.preload = "none"; v.preload = "none";
v.src = test.name; // Schedules async section to continue load algorithm. v.src = test.name; // Schedules async section to continue load algorithm.
@ -552,8 +517,7 @@ var tests = [
{ {
// 19. Set preload='auto' on first video source then switching preload='none' and swapping the video source to another. // 19. Set preload='auto' on first video source then switching preload='none' and swapping the video source to another.
// The second video should not start playing as it's preload state has been changed to 'none' from 'auto' // The second video should not start playing as it's preload state has been changed to 'none' from 'auto'
setup: setup(v) {
function(v) {
v.preload = "auto"; v.preload = "auto";
v.src = test.name; v.src = test.name;
// add a listener for when the video has loaded, so we know preload auto has worked // add a listener for when the video has loaded, so we know preload auto has worked

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

@ -29,7 +29,7 @@ var tests = [
name: 'v1', name: 'v1',
preload: 'none', preload: 'none',
expectedSuspendCount: 2, expectedSuspendCount: 2,
onsuspend: function(evt) { onsuspend(evt) {
checkSuspendCount(evt); checkSuspendCount(evt);
if (evt.target.suspendCount == 1) { if (evt.target.suspendCount == 1) {
evt.target.preload = 'auto'; evt.target.preload = 'auto';
@ -53,7 +53,7 @@ var tests = [
name: 'v4', name: 'v4',
preload: 'none', preload: 'none',
expectedSuspendCount: 2, expectedSuspendCount: 2,
onsuspend: function(evt) { onsuspend(evt) {
checkSuspendCount(evt); checkSuspendCount(evt);
if (evt.target.suspendCount == 1) { if (evt.target.suspendCount == 1) {
evt.target.play(); evt.target.play();
@ -76,7 +76,7 @@ var tests = [
name: 'v6', name: 'v6',
preload: 'none', preload: 'none',
expectedSuspendCount: 2, expectedSuspendCount: 2,
onsuspend: function(evt) { onsuspend(evt) {
checkSuspendCount(evt); checkSuspendCount(evt);
if (evt.target.suspendCount == 1) { if (evt.target.suspendCount == 1) {
evt.target.autoplay = true; evt.target.autoplay = true;

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

@ -23,7 +23,7 @@ function finish_test(element) {
var tests = [ var tests = [
// Test using a finite media stream, and a server supporting range requests // Test using a finite media stream, and a server supporting range requests
{ {
setup : function(element) { setup(element) {
is(element.seekable.length, 0, "seekable.length should be initialy 0."); is(element.seekable.length, 0, "seekable.length should be initialy 0.");
element.addEventListener("loadedmetadata", function() { element.addEventListener("loadedmetadata", function() {
is(element.seekable.length, 1, "seekable.length should be 1 for a server supporting range requests."); is(element.seekable.length, 1, "seekable.length should be 1 for a server supporting range requests.");

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

@ -31,9 +31,9 @@ function newSource(filter) {
e.type = candidates[0].type; e.type = candidates[0].type;
e.src = candidates[0].name; e.src = candidates[0].name;
return e; return e;
} else {
return null
} }
return null
} }
var audioLoaded = false; var audioLoaded = false;

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

@ -19,9 +19,9 @@ var manager = new MediaTestManager;
function ended(e) { function ended(e) {
var v = e.target; var v = e.target;
++v.counter["ended"]; ++v.counter.ended;
is(v.counter["ended"], 1, v._name + " should see ended only once"); is(v.counter.ended, 1, v._name + " should see ended only once");
ok(v.counter["timeupdate"] > 0, v._name + " should see at least one timeupdate: " + v.currentTime); 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. // Rest event counters for we don't allow events after ended.
eventsToLog.forEach(function(event) { eventsToLog.forEach(function(event) {
@ -55,7 +55,7 @@ var eventsToLog = ["play", "canplay", "canplaythrough", "loadstart", "loadedmeta
function logEvent(event) { function logEvent(event) {
var v = event.target; var v = event.target;
++v.counter[event.type]; ++v.counter[event.type];
if (v.counter["ended"] > 0) { if (v.counter.ended > 0) {
is(v.counter[event.type], 0, v._name + " got unexpected " + event.type + " after ended"); is(v.counter[event.type], 0, v._name + " got unexpected " + event.type + " after ended");
} }
} }
@ -75,7 +75,7 @@ function startTest(test, token) {
v.counter[e] = 0; v.counter[e] = 0;
}); });
v.addEventListener("ended", ended); v.addEventListener("ended", ended);
v.counter["ended"] = 0; v.counter.ended = 0;
document.body.appendChild(v); document.body.appendChild(v);
v.play(); v.play();
} }