Skip to content

Commit

Permalink
Bug 1782192 - Fix ESLint no-unused-vars warnings in xpcshell-tests fo…
Browse files Browse the repository at this point in the history
…r toolkit. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D153164
  • Loading branch information
Standard8 committed Jul 29, 2022
1 parent b11d2dc commit f77e072
Show file tree
Hide file tree
Showing 48 changed files with 25 additions and 301 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

"use strict";

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");

const { CookieXPCShellUtils } = ChromeUtils.import(
"resource://testing-common/CookieXPCShellUtils.jsm"
);
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

"use strict";

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");

const { CookieXPCShellUtils } = ChromeUtils.import(
"resource://testing-common/CookieXPCShellUtils.jsm"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

"use strict";

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");

const { CookieXPCShellUtils } = ChromeUtils.import(
"resource://testing-common/CookieXPCShellUtils.jsm"
);
Expand Down
1 change: 0 additions & 1 deletion toolkit/components/captivedetect/test/unit/test_abort.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

const kInterfaceName = "wifi";

var server;
var step = 0;
var loginFinished = false;

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

const kInterfaceName = "wifi";

var server;
var step = 0;
var loginFinished = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const kInterfaceName = "wifi";
const kOtherInterfaceName = "ril";

var server;
var step = 0;
var loginFinished = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const kInterfaceName = "wifi";
const kOtherInterfaceName = "ril";

var server;
var step = 0;
var loginFinished = false;

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

const kInterfaceName = "wifi";

var server;
var step = 0;
var loginFinished = false;

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

const kInterfaceName = "wifi";

var server;
var step = 0;
var attempt = 0;

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

const kInterfaceName = "wifi";

var server;
var step = 0;
var loginFinished = false;
var attempt = 0;

function xhr_handler(metadata, response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const kInterfaceName = "wifi";
const kOtherInterfaceName = "ril";

var server;
var step = 0;
var loginFinished = false;
var loginSuccessCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

const kInterfaceName = "wifi";

var server;
var step = 0;

function xhr_handler(metadata, response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
39 changes: 20 additions & 19 deletions toolkit/components/ctypes/tests/unit/test_finalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/downloads/test/unit/test_DownloadCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/downloads/test/unit/test_DownloadLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions toolkit/components/normandy/test/unit/test_NormandyApi.js
Original file line number Diff line number Diff line change
@@ -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"
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

// Globals

ChromeUtils.defineModuleGetter(
this,
"FileUtils",
"resource://gre/modules/FileUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"NetUtil",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 0 additions & 6 deletions toolkit/components/telemetry/tests/unit/test_ChildEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
Expand Down
3 changes: 0 additions & 3 deletions toolkit/components/telemetry/tests/unit/test_ChildScalars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
Expand Down
Loading

0 comments on commit f77e072

Please sign in to comment.