Bug 1782192 - Fix ESLint no-unused-vars warnings in xpcshell-tests for toolkit. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D153164
This commit is contained in:
Mark Banner 2022-07-29 21:54:32 +00:00
Родитель b11d2dcbf8
Коммит f77e072cc5
48 изменённых файлов: 25 добавлений и 301 удалений

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

@ -226,8 +226,6 @@ module.exports = {
"dom/**",
"netwerk/**",
"security/manager/ssl/tests/unit/**",
"toolkit/components/**",
"toolkit/modules/**",
],
rules: {
// No declaring variables that are never used

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

@ -1,9 +1,5 @@
"use strict";
const { RemoteSettings } = ChromeUtils.import(
"resource://services-settings/remote-settings.js"
);
do_get_profile();
// Let's use XPCShellContentUtils to open/close tabs.

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

@ -4,8 +4,6 @@
"use strict";
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { CookieXPCShellUtils } = ChromeUtils.import(
"resource://testing-common/CookieXPCShellUtils.jsm"
);
@ -55,19 +53,6 @@ let observer = channel => {
};
Services.obs.addObserver(observer, "http-on-modify-request");
function makeChan(url, loadingUrl) {
var principal = Services.scriptSecurityManager.createContentPrincipal(
Services.io.newURI(loadingUrl),
{}
);
return NetUtil.newChannel({
uri: url,
loadingPrincipal: principal,
securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
});
}
add_task(async () => {
do_get_profile();

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

@ -4,8 +4,6 @@
"use strict";
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { CookieXPCShellUtils } = ChromeUtils.import(
"resource://testing-common/CookieXPCShellUtils.jsm"
);

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

@ -4,8 +4,6 @@
"use strict";
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { CookieXPCShellUtils } = ChromeUtils.import(
"resource://testing-common/CookieXPCShellUtils.jsm"
);

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

@ -6,7 +6,6 @@
const kInterfaceName = "wifi";
var server;
var step = 0;
var loginFinished = false;

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

@ -6,7 +6,6 @@
const kInterfaceName = "wifi";
var server;
var step = 0;
var loginFinished = false;

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

@ -7,7 +7,6 @@
const kInterfaceName = "wifi";
const kOtherInterfaceName = "ril";
var server;
var step = 0;
var loginFinished = false;

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

@ -7,7 +7,6 @@
const kInterfaceName = "wifi";
const kOtherInterfaceName = "ril";
var server;
var step = 0;
var loginFinished = false;

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

@ -6,7 +6,6 @@
const kInterfaceName = "wifi";
var server;
var step = 0;
var loginFinished = false;

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

@ -6,7 +6,6 @@
const kInterfaceName = "wifi";
var server;
var step = 0;
var attempt = 0;

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

@ -6,9 +6,7 @@
const kInterfaceName = "wifi";
var server;
var step = 0;
var loginFinished = false;
var attempt = 0;
function xhr_handler(metadata, response) {

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

@ -7,7 +7,6 @@
const kInterfaceName = "wifi";
const kOtherInterfaceName = "ril";
var server;
var step = 0;
var loginFinished = false;
var loginSuccessCount = 0;

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

@ -6,7 +6,6 @@
const kInterfaceName = "wifi";
var server;
var step = 0;
function xhr_handler(metadata, response) {

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

@ -2,8 +2,6 @@
* 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/. */
let global = this;
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");

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

@ -5,9 +5,6 @@
const { Corroborate } = ChromeUtils.import(
"resource://gre/modules/Corroborate.jsm"
);
const { FileUtils } = ChromeUtils.import(
"resource://gre/modules/FileUtils.jsm"
);
add_task(async function test_various_jars() {
let result = await Corroborate.verifyJar(do_get_file("data/unsigned.xpi"));

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

@ -315,27 +315,28 @@ function run_test() {
// If only I could have Promises to test this :)
// There is only so much we can do at this stage,
// if we want to avoid tests overlapping.
function test_cycles(size, tc) {
// Now, restart this with unreferenced cycles
for (let i = 0; i < size / 2; ++i) {
let a = {
a: ctypes.CDataFinalizer(tc.acquire(i * 2), tc.release),
b: {
b: ctypes.CDataFinalizer(tc.acquire(i * 2 + 1), tc.release),
},
};
a.b.a = a;
}
do_test_pending();
// Deactivated - see comment above.
// function test_cycles(size, tc) {
// // Now, restart this with unreferenced cycles
// for (let i = 0; i < size / 2; ++i) {
// let a = {
// a: ctypes.CDataFinalizer(tc.acquire(i * 2), tc.release),
// b: {
// b: ctypes.CDataFinalizer(tc.acquire(i * 2 + 1), tc.release),
// },
// };
// a.b.a = a;
// }
// do_test_pending();
Cu.schedulePreciseGC(function after_gc() {
// Check that _something_ has been finalized
Assert.ok(count_finalized(size, tc) > 0);
do_test_finished();
});
// Cu.schedulePreciseGC(function after_gc() {
// // Check that _something_ has been finalized
// Assert.ok(count_finalized(size, tc) > 0);
// do_test_finished();
// });
do_timeout(10000, do_throw);
}
// do_timeout(10000, do_throw);
// }
function count_finalized(size, tc) {
let finalizedItems = 0;

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

@ -8,10 +8,7 @@ var acquire,
dispose,
reset_errno,
dispose_errno,
acquire_ptr,
dispose_ptr,
acquire_void_ptr,
dispose_void_ptr,
acquire_string,
dispose_string;
@ -53,12 +50,6 @@ function run_test() {
ctypes.void_t,
ctypes.size_t
);
acquire_ptr = library.declare(
"test_finalizer_acq_int32_ptr_t",
ctypes.default_abi,
ctypes.int32_t.ptr,
ctypes.size_t
);
dispose_ptr = library.declare(
"test_finalizer_rel_int32_ptr_t",
ctypes.default_abi,

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

@ -17,6 +17,8 @@ ChromeUtils.defineModuleGetter(
// Execution of common tests
// This is used in common_test_Download.js
// eslint-disable-next-line no-unused-vars
var gUseLegacySaver = false;
var scriptFile = do_get_file("common_test_Download.js");

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

@ -11,6 +11,8 @@
// Execution of common tests
// This is used in common_test_Download.js
// eslint-disable-next-line no-unused-vars
var gUseLegacySaver = true;
var scriptFile = do_get_file("common_test_Download.js");

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

@ -3,13 +3,9 @@
"use strict";
const { FeatureGate } = ChromeUtils.import(
"resource://featuregates/FeatureGate.jsm"
);
const { FeatureGateImplementation } = ChromeUtils.import(
"resource://featuregates/FeatureGateImplementation.jsm"
);
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
const kDefinitionDefaults = {
id: "test-feature",
@ -26,43 +22,6 @@ function definitionFactory(override = {}) {
return Object.assign({}, kDefinitionDefaults, override);
}
class DefinitionServer {
constructor(definitionOverrides = []) {
this.server = new HttpServer();
this.server.registerPathHandler("/definitions.json", this);
this.definitions = {};
for (const override of definitionOverrides) {
this.addDefinition(override);
}
this.server.start();
registerCleanupFunction(
() => new Promise(resolve => this.server.stop(resolve))
);
}
// for nsIHttpRequestHandler
handle(request, response) {
// response.setHeader("Content-Type", "application/json");
response.write(JSON.stringify(this.definitions));
}
get definitionsUrl() {
const { primaryScheme, primaryHost, primaryPort } = this.server.identity;
return `${primaryScheme}://${primaryHost}:${primaryPort}/definitions.json`;
}
addDefinition(overrides = {}) {
const definition = definitionFactory(overrides);
// convert targeted values, used by fromId
definition.isPublic = { default: definition.isPublic };
definition.defaultValue = { default: definition.defaultValue };
this.definitions[definition.id] = definition;
return definition;
}
}
// getValue should work
add_task(async function testGetValue() {
const preference = "test.pref";

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

@ -47,11 +47,6 @@ const FAKE_FEATURE_MANIFEST = {
},
},
};
const FAKE_FEATURE_REMOTE_VALUE = {
value: {
enabled: true,
},
};
/**
* FOG requires a little setup in order to test it

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

@ -1,9 +1,6 @@
/* globals sinon */
"use strict";
const { CanonicalJSON } = ChromeUtils.import(
"resource://gre/modules/CanonicalJSON.jsm"
);
const { PromiseUtils } = ChromeUtils.import(
"resource://gre/modules/PromiseUtils.jsm"
);

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

@ -1,9 +1,6 @@
/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
const { Subprocess } = ChromeUtils.import(

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

@ -10,11 +10,6 @@
// Globals
ChromeUtils.defineModuleGetter(
this,
"FileUtils",
"resource://gre/modules/FileUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"NetUtil",

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

@ -8,9 +8,6 @@
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { TestUtils } = ChromeUtils.import(
"resource://testing-common/TestUtils.jsm"
);
const { updateAppInfo } = ChromeUtils.import(
"resource://testing-common/AppInfo.jsm"

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

@ -5,12 +5,6 @@
const { TelemetryController } = ChromeUtils.import(
"resource://gre/modules/TelemetryController.jsm"
);
const { TelemetrySession } = ChromeUtils.import(
"resource://gre/modules/TelemetrySession.jsm"
);
const { PromiseUtils } = ChromeUtils.import(
"resource://gre/modules/PromiseUtils.jsm"
);
const { ContentTaskUtils } = ChromeUtils.import(
"resource://testing-common/ContentTaskUtils.jsm"
);

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

@ -4,9 +4,6 @@ const { TelemetryController } = ChromeUtils.import(
const { TelemetrySession } = ChromeUtils.import(
"resource://gre/modules/TelemetrySession.jsm"
);
const { PromiseUtils } = ChromeUtils.import(
"resource://gre/modules/PromiseUtils.jsm"
);
const { ContentTaskUtils } = ChromeUtils.import(
"resource://testing-common/ContentTaskUtils.jsm"
);

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

@ -8,9 +8,6 @@ const { TelemetryController } = ChromeUtils.import(
const { TelemetrySession } = ChromeUtils.import(
"resource://gre/modules/TelemetrySession.jsm"
);
const { PromiseUtils } = ChromeUtils.import(
"resource://gre/modules/PromiseUtils.jsm"
);
const { ContentTaskUtils } = ChromeUtils.import(
"resource://testing-common/ContentTaskUtils.jsm"
);

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

@ -4,10 +4,6 @@
"use strict";
const { TelemetryArchiveTesting } = ChromeUtils.import(
"resource://testing-common/TelemetryArchiveTesting.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"TelemetryEventPing",

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

@ -7,9 +7,6 @@
"use strict";
const { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
const { PromiseUtils } = ChromeUtils.import(
"resource://gre/modules/PromiseUtils.jsm"
);

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

@ -25,10 +25,6 @@ const REASON_DAILY = "daily";
const REASON_ENVIRONMENT_CHANGE = "environment-change";
const REASON_SHUTDOWN = "shutdown";
XPCOMUtils.defineLazyGetter(this, "DATAREPORTING_PATH", function() {
return OS.Path.join(OS.Constants.Path.profileDir, "datareporting");
});
var promiseValidateArchivedPings = async function(aExpectedReasons) {
// The list of ping reasons which mark the session end (and must reset the subsession
// count).

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

@ -9,9 +9,6 @@ const { TelemetryController } = ChromeUtils.import(
const { TelemetryStorage } = ChromeUtils.import(
"resource://gre/modules/TelemetryStorage.jsm"
);
const { TelemetrySend } = ChromeUtils.import(
"resource://gre/modules/TelemetrySend.jsm"
);
const { TelemetryUtils } = ChromeUtils.import(
"resource://gre/modules/TelemetryUtils.jsm"
);
@ -19,7 +16,6 @@ const { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
const PING_FORMAT_VERSION = 4;
const DELETION_REQUEST_PING_TYPE = "deletion-request";
const TEST_PING_TYPE = "test-ping-type";

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

@ -15,7 +15,6 @@ const { TelemetrySend } = ChromeUtils.import(
const { AsyncShutdown } = ChromeUtils.import(
"resource://gre/modules/AsyncShutdown.jsm"
);
const { httpd } = ChromeUtils.import("resource://testing-common/httpd.js");
function contentHandler(metadata, response) {
dump("contentHandler called for path: " + metadata._path + "\n");

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

@ -3,10 +3,6 @@
const INT_MAX = 0x7fffffff;
const { TelemetryUtils } = ChromeUtils.import(
"resource://gre/modules/TelemetryUtils.jsm"
);
// Return an array of numbers from lower up to, excluding, upper
function numberRange(lower, upper) {
let a = [];
@ -16,28 +12,6 @@ function numberRange(lower, upper) {
return a;
}
function expect_fail(f) {
let failed = false;
try {
f();
failed = false;
} catch (e) {
failed = true;
}
Assert.ok(failed);
}
function expect_success(f) {
let succeeded = false;
try {
f();
succeeded = true;
} catch (e) {
succeeded = false;
}
Assert.ok(succeeded);
}
function check_histogram(histogram_type, name, min, max, bucket_count) {
var h = Telemetry.getHistogramById(name);
h.add(0);

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

@ -9,7 +9,6 @@
const { TelemetryReportingPolicy } = ChromeUtils.import(
"resource://gre/modules/TelemetryReportingPolicy.jsm"
);
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
const { UpdateUtils } = ChromeUtils.import(
"resource://gre/modules/UpdateUtils.jsm"
);

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

@ -2,11 +2,6 @@
http://creativecommons.org/publicdomain/zero/1.0/
*/
const UINT_SCALAR = "telemetry.test.unsigned_int_kind";
const STRING_SCALAR = "telemetry.test.string_kind";
const BOOLEAN_SCALAR = "telemetry.test.boolean_kind";
const KEYED_UINT_SCALAR = "telemetry.test.keyed_unsigned_int";
const { CommonUtils } = ChromeUtils.import(
"resource://services-common/utils.js"
);

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

@ -14,11 +14,9 @@ const {
} = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const PING_SAVE_FOLDER = "saved-telemetry-pings";
const PING_TIMEOUT_LENGTH = 5000;
const OLD_FORMAT_PINGS = 4;
const RECENT_PINGS = 4;
var gCreatedPings = 0;
var gSeenPings = 0;
/**
@ -52,7 +50,6 @@ var createSavedPings = async function(aPingInfos) {
let filePath = getSavePathForPingId(pingId);
await File.setDates(filePath, null, age);
}
gCreatedPings++;
pingIds.push(pingId);
}
}
@ -60,18 +57,6 @@ var createSavedPings = async function(aPingInfos) {
return pingIds;
};
/**
* Deletes locally saved pings if they exist.
*
* @param aPingIds an Array of ping ids to delete.
* @returns Promise
*/
var clearPings = async function(aPingIds) {
for (let pingId of aPingIds) {
await TelemetryStorage.removePendingPing(pingId);
}
};
/**
* Fakes the pending pings storage quota.
* @param {Integer} aPendingQuota The new quota, in bytes.
@ -103,25 +88,6 @@ function assertReceivedPings(aExpectedNum) {
Assert.equal(gSeenPings, aExpectedNum);
}
/**
* Throws if any pings with the id in aPingIds is saved locally.
*
* @param aPingIds an Array of pings ids to check.
* @returns Promise
*/
var assertNotSaved = async function(aPingIds) {
let saved = 0;
for (let id of aPingIds) {
let filePath = getSavePathForPingId(id);
if (await File.exists(filePath)) {
saved++;
}
}
if (saved > 0) {
do_throw("Found " + saved + " unexpected saved pings.");
}
};
/**
* Our handler function for the HttpServer that simply
* increments the gSeenPings global when it successfully

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

@ -36,7 +36,6 @@ const REASON_TEST_PING = "test-ping";
const REASON_DAILY = "daily";
const REASON_ENVIRONMENT_CHANGE = "environment-change";
const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED";
const IGNORE_CLONED_HISTOGRAM = "test::ignore_me_also";
// Add some unicode characters here to ensure that sending them works correctly.
const SHUTDOWN_TIME = 10000;
@ -95,21 +94,6 @@ function setupTestData() {
k1.add("b");
}
function getSavedPingFile(basename) {
let tmpDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
let pingFile = tmpDir.clone();
pingFile.append(basename);
if (pingFile.exists()) {
pingFile.remove(true);
}
registerCleanupFunction(function() {
try {
pingFile.remove(true);
} catch (e) {}
});
return pingFile;
}
function checkPingFormat(aPing, aType, aHasClientId, aHasEnvironment) {
const MANDATORY_PING_FIELDS = [
"type",

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

@ -1,9 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const { ObjectUtils } = ChromeUtils.import(
"resource://gre/modules/ObjectUtils.jsm"
);
const { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);

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

@ -6,9 +6,8 @@
// Test that the Shutdown Terminator reloads durations correctly
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
var { Path, File, Constants } = OS;
var { Path, Constants } = OS;
var PATH;

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

@ -2,11 +2,6 @@ const { CanonicalJSON } = ChromeUtils.import(
"resource://gre/modules/CanonicalJSON.jsm"
);
function stringRepresentation(obj) {
const clone = JSON.parse(JSON.stringify(obj));
return JSON.stringify(clone);
}
add_task(async function test_canonicalJSON_should_preserve_array_order() {
const input = ["one", "two", "three"];
// No sorting should be done on arrays.

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

@ -36,7 +36,6 @@ const principalPrivilegedMozilla = ssm.createContentPrincipal(
);
const {
DEFAULT_REMOTE_TYPE,
EXTENSION_REMOTE_TYPE,
FILE_REMOTE_TYPE,
FISSION_WEB_REMOTE_TYPE,

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

@ -1,8 +1,6 @@
/* Any copyright do_check_eq dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
var Cm = Components.manager;
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
);

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

@ -3,11 +3,6 @@
"use strict";
const kSearchEngineID1 = "ignorelist_test_engine1";
const kSearchEngineURL1 =
"http://example.com/?search={searchTerms}&ignore=true";
const kExtensionID = "searchignore@mozilla.com";
XPCOMUtils.defineLazyModuleGetters(this, {
IgnoreLists: "resource://gre/modules/IgnoreLists.jsm",
PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",

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

@ -10,16 +10,6 @@ ChromeUtils.defineModuleGetter(
"AsyncShutdown",
"resource://gre/modules/AsyncShutdown.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"DownloadPaths",
"resource://gre/modules/DownloadPaths.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"FileUtils",
"resource://gre/modules/FileUtils.jsm"
);
ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
ChromeUtils.defineModuleGetter(
this,

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

@ -10,14 +10,6 @@ registerCleanupFunction(() => {
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
});
var testFormatter = {
format: function format(message) {
return (
message.loggerName + "\t" + message.levelDesc + "\t" + message.message
);
},
};
class MockAppender extends Log.Appender {
constructor(formatter) {
super(formatter);
@ -65,31 +57,6 @@ add_task(function test_Logger_parent() {
Assert.ok(gpAppender.messages[0].indexOf("child info test") > 0);
});
/*
* A utility method for checking object equivalence.
* Fields with a reqular expression value in expected will be tested
* against the corresponding value in actual. Otherwise objects
* are expected to have the same keys and equal values.
*/
function checkObjects(expected, actual) {
Assert.ok(expected instanceof Object);
Assert.ok(actual instanceof Object);
for (let key in expected) {
Assert.notEqual(actual[key], undefined);
if (expected[key] instanceof RegExp) {
Assert.ok(expected[key].test(actual[key].toString()));
} else if (expected[key] instanceof Object) {
checkObjects(expected[key], actual[key]);
} else {
Assert.equal(expected[key], actual[key]);
}
}
for (let key in actual) {
Assert.notEqual(expected[key], undefined);
}
}
/*
* Test parameter formatting.
*/

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

@ -1,8 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
var Cm = Components.manager;
const { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);