Skip to content

Commit

Permalink
Bug 1556854 - Enable ESLint for dom/media/test/ - Enable ESLint rules…
Browse files Browse the repository at this point in the history
… no-undef and no-unused-vars. r=jya

Differential Revision: https://phabricator.services.mozilla.com/D50132
  • Loading branch information
Standard8 committed Oct 24, 2019
1 parent 6f18d1e commit 7808c97
Show file tree
Hide file tree
Showing 79 changed files with 116 additions and 108 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,7 @@ module.exports = {
"no-nested-ternary": "off",
"no-self-assign": "off",
"no-new-object": "off",
"no-undef": "off",
"no-unsanitized/property": "off",
"no-unused-vars": "off",
}
}]
};
2 changes: 2 additions & 0 deletions dom/media/test/AutoplayTestUtils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* import-globals-from manifest.js */

function playAndPostResult(muted, parent_window) {
let element = document.createElement("video");
element.preload = "auto";
Expand Down
6 changes: 4 additions & 2 deletions dom/media/test/background_video.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* jshint esversion: 6, -W097 */
/* globals SimpleTest, SpecialPowers, document, info, is, manager, ok */

// This file expects manager to be defined in the global scope.
/* global manager */
/* import-globals-from manifest.js */

"use strict";

Expand Down
8 changes: 0 additions & 8 deletions dom/media/test/can_play_type_webm.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ async function check_webm(v, enabled) {
check("video/webm; codecs=xyz,vorbis", "");
check("video/webm; codecs=vorbis,xyz", "");

function getPref(name) {
var pref = false;
try {
pref = SpecialPowers.getBoolPref(name);
} catch (ex) {}
return pref;
}

await SpecialPowers.pushPrefEnv({ set: [["media.av1.enabled", true]] });
check('video/webm; codecs="av1"', "probably");

Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/chromeHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* eslint-env mozilla/frame-script */

"use strict";

const dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(
Expand Down
4 changes: 2 additions & 2 deletions dom/media/test/eme.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* import-globals-from manifest.js */

const CLEARKEY_KEYSYSTEM = "org.w3.clearkey";

const gCencMediaKeySystemConfig = [
Expand Down Expand Up @@ -173,15 +175,13 @@ function AppendTrack(test, ms, track, token) {
return new Promise(function(resolve, reject) {
var sb;
var curFragment = 0;
var resolved = false;
var fragments = track.fragments;
var fragmentFile;

function addNextFragment() {
if (curFragment >= fragments.length) {
Log(token, track.name + ": end of track");
resolve();
resolved = true;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion dom/media/test/gUM_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function pushGetUserMediaTestPrefs({
// names already set in the prefs. If no loopback device name can be found then
// prefs are setup such that a fake device is used.
async function setupGetUserMediaTestPrefs() {
prefRequests = {};
let prefRequests = {};
let audioLoopDev = SpecialPowers.getCharPref("media.audio_loopback_dev", "");
if (audioLoopDev) {
prefRequests.fakeAudio = false;
Expand Down
4 changes: 2 additions & 2 deletions dom/media/test/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2194,12 +2194,12 @@ function MediaTestManager() {
// stacks.
function mediaTestCleanup(callback) {
var V = document.getElementsByTagName("video");
for (i = 0; i < V.length; i++) {
for (let i = 0; i < V.length; i++) {
removeNodeAndSource(V[i]);
V[i] = null;
}
var A = document.getElementsByTagName("audio");
for (i = 0; i < A.length; i++) {
for (let i = 0; i < A.length; i++) {
removeNodeAndSource(A[i]);
A[i] = null;
}
Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/marionette/yttest/debug_info.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global video, result, resolve */

video.mozRequestDebugInfo().then(debugInfo => {
// The parsing won't be necessary once we have bug 1542674
try {
Expand Down
1 change: 1 addition & 0 deletions dom/media/test/marionette/yttest/video_playback_quality.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* global video */
var result = { getVideoPlaybackQuality: video.getVideoPlaybackQuality() };
4 changes: 4 additions & 0 deletions dom/media/test/seek_support.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This file expects manifest.js to be included in the same scope.
/* import-globals-from manifest.js */
// This file expects SEEK_TEST_NUMBER to be defined by the test.
/* global SEEK_TEST_NUMBER */
var manager = new MediaTestManager();

function createTestArray() {
Expand Down
2 changes: 1 addition & 1 deletion dom/media/test/test_autoplay_policy_activation.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
let child_url = "file_autoplay_policy_activation_window.html";

async function runTest() {
for (test_case of test_cases) {
for (const test_case of test_cases) {
// Run each test in a new window, to ensure its user gesture
// activation state isn't tainted by preceeding tests.
let child = window.open(child_url, "", "width=500,height=500");
Expand Down
4 changes: 2 additions & 2 deletions dom/media/test/test_autoplay_policy_eventdown_activation.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load");
child.postMessage("run keydown test", window.origin);
let result = await nextWindowMessage();
await nextWindowMessage();
child.close();
}

{
let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load");
child.postMessage("run mousedown test", window.origin);
let result = await nextWindowMessage();
await nextWindowMessage();
child.close();
}

Expand Down
2 changes: 1 addition & 1 deletion dom/media/test/test_autoplay_policy_key_blacklist.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load");
child.postMessage("run test", window.origin);
let result = await nextWindowMessage();
await nextWindowMessage();
child.close();
SimpleTest.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
let child_url = "file_autoplay_policy_play_before_loadedmetadata.html";

async function runTest() {
for (testCase of testCases) {
for (const testCase of testCases) {
// Run each test in a new window, to ensure its user gesture
// activation state isn't tainted by preceeding tests.
let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load");
child.postMessage(testCase, window.origin);
let result = await nextWindowMessage();
await nextWindowMessage();
child.close();
}
SimpleTest.finish();
Expand Down
4 changes: 2 additions & 2 deletions dom/media/test/test_autoplay_policy_unmute_pauses.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
let child_url = "file_autoplay_policy_unmute_pauses.html";

async function runTest() {
for (testCase of testCases) {
for (const testCase of testCases) {
// Run each test in a new window, to ensure its user gesture
// activation state isn't tainted by preceeding tests.
let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load");
child.postMessage(testCase, window.origin);
let result = await nextWindowMessage();
await nextWindowMessage();
child.close();
}
SimpleTest.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
}

function createAudioContext() {
/* global ac */
window.ac = new AudioContext();

ac.allowedToStart = new Promise(resolve => {
Expand Down Expand Up @@ -101,7 +102,7 @@
return [ac.createStereoPanner().pan];
default:
ok(false, `non-defined node type ${nodeType}.`);

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
}

function createAudioContexts() {
/* global ac1, ac2 */
window.ac1 = new AudioContext();
window.ac2 = new AudioContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
}

function createAudioContext() {
/* global ac */
window.ac = new AudioContext();

ac.allowedToStart = new Promise(resolve => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
}

async function createAudioContext() {
/* global ac */
window.ac = new AudioContext();
await once(ac, "blocked");
is(ac.state, "suspended", `AudioContext is blocked.`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

function drawVideoToCanvas(v) {
console.log('drawVideoToCanvas');
let w = v.width,
h = v.height,
c = document.createElement('canvas');
let c = document.createElement('canvas');
c.width = 4;
c.height = 4;
c.style.width = 64;
Expand Down Expand Up @@ -75,4 +73,4 @@
});
}
});
</script>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var manager = new MediaTestManager;

function captureVideoAsStream(v) {
let stream = v.mozCaptureStream();
v.mozCaptureStream();
}

startTest({
Expand Down Expand Up @@ -43,4 +43,4 @@
});
}
});
</script>
</script>
1 change: 1 addition & 0 deletions dom/media/test/test_bug1248229.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SimpleTest.waitForExplicitFinish();

function doTest() {
/* global v */
window.oak = v.mozCaptureStreamUntilEnded();
v.mozCaptureStreamUntilEnded();
v.play();
Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/test_bug1431810_opus_downmix_to_mono.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
SimpleTest.waitForExplicitFinish();

/* global a, b */

function areChannelsInverted(b1, b2) {
for (var i = 0; i < b1.length; i++) {
if (Math.abs(b1[i] + b2[i]) > 9e-2) {
Expand Down
2 changes: 1 addition & 1 deletion dom/media/test/test_bug1512958.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
a.src = test.name;
a.name = test.name;
const ac = new AudioContext();
const src = ac.createMediaElementSource(a);
ac.createMediaElementSource(a);
a.play();
do {
await new Promise(r => a.ontimeupdate = r);
Expand Down
4 changes: 2 additions & 2 deletions dom/media/test/test_bug463162.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463162
-->
<head>
<title>Test for Bug 463162</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"/>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
Expand Down
1 change: 1 addition & 0 deletions dom/media/test/test_bug895305.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
var audio = document.createElement("audio");

// Check leaking on TextTrackList objects.
/* global ttl, ttc */
window.ttl = audio.textTracks;
ttl.addEventListener("click", function(){});

Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/test_cloneElementVisually_ended_video.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ <h1>Results</h1>

<script type="application/javascript">

/* import-globals-from cloneElementVisually_helpers.js */

/**
* Test that when we start cloning a video that has already ended, the
* clone displays the last frame from the video.
Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/test_cloneElementVisually_mediastream.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ <h1>Results</h1>

<script type="application/javascript">

/* import-globals-from cloneElementVisually_helpers.js */

/**
* Test that we can clone a video that is playing a MediaStream.
*/
Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/test_cloneElementVisually_no_suspend.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ <h1>Results</h1>

<script type="application/javascript">

/* import-globals-from cloneElementVisually_helpers.js */

/**
* Tests that cloning a video prevents the decoder from being suspended
* if the original video stops being visible.
Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/test_cloneElementVisually_paused.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ <h1>Results</h1>

<script type="application/javascript">

/* import-globals-from cloneElementVisually_helpers.js */

/**
* Test that when we start cloning a paused video, the clone displays
* the first paused frame.
Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/test_cloneElementVisually_poster.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ <h1>Results</h1>

<script type="application/javascript">

/* import-globals-from cloneElementVisually_helpers.js */

/**
* Test that when we start cloning a paused video, the clone displays
* the first paused frame.
Expand Down
2 changes: 2 additions & 0 deletions dom/media/test/test_cloneElementVisually_resource_change.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ <h1>Results</h1>

<script type="application/javascript">

/* import-globals-from cloneElementVisually_helpers.js */

/**
* Tests that cloning survives changes to the underlying video resource.
*/
Expand Down
2 changes: 0 additions & 2 deletions dom/media/test/test_cueless_webm_seek-3.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
var v = e.target;
v.removeEventListener('loadeddata', testWebM3);

var startPassed = false;
var completed = false;
var gotTimeupdate = false;

Expand All @@ -58,7 +57,6 @@
return;

v.addEventListener("timeupdate", timeupdate);
startPassed = true;
}

function seekEnded() {
Expand Down
1 change: 1 addition & 0 deletions dom/media/test/test_eme_autoplay.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager;

var EMEmanifest = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<pre id="test">
<video id="v" controls></video>
<script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager;

var EMEmanifest = [
Expand Down
Loading

0 comments on commit 7808c97

Please sign in to comment.