Bug 1367235 - Enable eslint on testing/xpcshell - mechanical updates; r=Standard8

This commit is contained in:
Geoff Brown 2017-05-25 07:32:42 -06:00
parent 4e7a503b65
commit 6fe3dae59f
14 changed files with 87 additions and 91 deletions

View file

@ -37,7 +37,6 @@ python/**
rdf/**
servo/**
startupcache/**
testing/**
tools/update-packaging/**
uriloader/**
view/**
@ -295,6 +294,19 @@ security/nss/**
services/sync/modules/constants.js
services/sync/services-sync.js
# testing/ exclusions
testing/firefox-ui/**
testing/marionette/**
testing/mochitest/**
testing/modules/**
testing/mozbase/**
testing/profiles/**
testing/specialpowers/**
testing/talos/**
testing/web-platform/**
testing/xpcshell/moz-http2/**
testing/xpcshell/node-http2/**
# Third party services
services/common/kinto-http-client.js
services/common/kinto-offline-client.js

View file

@ -2,7 +2,7 @@
* 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/. */
'use strict';
"use strict";
const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
var { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
@ -19,8 +19,7 @@ const { BrowserTabList } = devtools.require("devtools/server/actors/webbrowser")
* Construct a root actor appropriate for use in a server running xpcshell
* tests. <snip boilerplate> :)
*/
function createRootActor(connection)
{
function createRootActor(connection) {
let parameters = {
tabList: new XPCSTTabList(connection),
globalActorFactories: DebuggerServer.globalActorFactories,
@ -37,8 +36,7 @@ function createRootActor(connection)
* A "stub" TabList implementation that provides no tabs.
*/
function XPCSTTabList(connection)
{
function XPCSTTabList(connection) {
BrowserTabList.call(this, connection);
}

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"plugin:mozilla/xpcshell-test"
]
};

View file

@ -4,8 +4,7 @@
var {classes: Cc, interfaces: Ci} = Components;
function check_profile_dir(profd)
{
function check_profile_dir(profd) {
Assert.ok(profd.exists());
Assert.ok(profd.isDirectory());
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
@ -17,8 +16,7 @@ function check_profile_dir(profd)
Assert.ok(profd.equals(profd2));
}
function check_do_get_profile(fireProfileAfterChange)
{
function check_do_get_profile(fireProfileAfterChange) {
const observedTopics = new Map([
["profile-do-change", 0],
["profile-after-change", 0],

View file

@ -10,8 +10,8 @@
*/
function run_test() {
do_check_true(typeof(this['MODULE_IMPORTED']) == "undefined");
do_check_true(typeof(this['MODULE_URI']) == "undefined");
do_check_true(typeof(this["MODULE_IMPORTED"]) == "undefined");
do_check_true(typeof(this["MODULE_URI"]) == "undefined");
let uri = "resource://test/import_module.jsm";
Components.utils.import(uri);
do_check_true(MODULE_URI == uri);

View file

@ -13,8 +13,7 @@ function run_test() {
try {
load("file_that_does_not_exist.js");
subscriptLoaded = true;
}
catch (ex) {
} catch (ex) {
do_check_eq(ex.message.substring(0, 16), "cannot open file");
}
do_check_false(subscriptLoaded, "load() should throw an error");

View file

@ -4,8 +4,7 @@
* 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/. */
function run_test()
{
function run_test() {
load("check_profile.js");
check_do_get_profile(false);
}

View file

@ -4,8 +4,7 @@
* 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/. */
function run_test()
{
function run_test() {
load("check_profile.js");
check_do_get_profile(true);
}

View file

@ -66,8 +66,7 @@ try {
runningInParent = Components.classes["@mozilla.org/xre/runtime;1"].
getService(Components.interfaces.nsIXULRuntime).processType
== Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
}
catch (e) { }
} catch (e) { }
// Only if building of places is enabled.
if (runningInParent &&
@ -93,8 +92,7 @@ try {
prefs.setCharPref("network.dns.ipv4OnlyDomains", "localhost");
}
}
}
catch (e) { }
} catch (e) { }
// Configure crash reporting, if possible
// We rely on the Python harness to set MOZ_CRASHREPORTER,
@ -110,8 +108,7 @@ try {
crashReporter.UpdateCrashEventsDir();
crashReporter.minidumpPath = do_get_minidumpdir();
}
}
catch (e) { }
} catch (e) { }
// Configure a console listener so messages sent to it are logged as part
// of the test.
@ -240,8 +237,7 @@ var _fakeIdleService = {
return this.registrar.contractIDToCID(this.contractID);
},
activate: function FIS_activate()
{
activate: function FIS_activate() {
if (!this.originalFactory) {
// Save original factory.
this.originalFactory =
@ -256,8 +252,7 @@ var _fakeIdleService = {
}
},
deactivate: function FIS_deactivate()
{
deactivate: function FIS_deactivate() {
if (this.originalFactory) {
// Unregister the mock.
this.registrar.unregisterFactory(this.CID, this.factory);
@ -270,8 +265,7 @@ var _fakeIdleService = {
factory: {
// nsIFactory
createInstance: function (aOuter, aIID)
{
createInstance: function(aOuter, aIID) {
if (aOuter) {
throw Components.results.NS_ERROR_NO_AGGREGATION;
}
@ -505,7 +499,7 @@ function _execute_test() {
_PromiseTestUtils.Assert = Assert;
let coverageCollector = null;
if (typeof _JSCOV_DIR === 'string') {
if (typeof _JSCOV_DIR === "string") {
let _CoverageCollector = Components.utils.import("resource://testing-common/CoverageUtils.jsm", {}).CoverageCollector;
coverageCollector = new _CoverageCollector(_JSCOV_DIR);
}
@ -711,14 +705,13 @@ function do_execute_soon(callback, aName) {
let stack = e.stack ? _format_stack(e.stack) : null;
_testLogger.testStatus(_TEST_NAME,
funcName,
'FAIL',
'PASS',
"FAIL",
"PASS",
_exception_message(e),
stack);
_do_quit();
}
}
finally {
} finally {
do_test_finished(funcName);
}
}
@ -940,10 +933,9 @@ function do_check_matches(pattern, value) {
// Check that |func| throws an nsIException that has
// |Components.results[resultName]| as the value of its 'result' property.
function do_check_throws_nsIException(func, resultName,
stack=Components.stack.caller, todo=false)
{
stack = Components.stack.caller, todo = false) {
let expected = Components.results[resultName];
if (typeof expected !== 'number') {
if (typeof expected !== "number") {
do_throw("do_check_throws_nsIException requires a Components.results" +
" property name, not " + uneval(resultName), stack);
}
@ -972,16 +964,15 @@ function do_check_throws_nsIException(func, resultName,
// Produce a human-readable form of |exception|. This looks up
// Components.results values, tries toString methods, and so on.
function legible_exception(exception)
{
function legible_exception(exception) {
switch (typeof exception) {
case 'object':
case "object":
if (exception instanceof Components.interfaces.nsIException) {
return "nsIException instance: " + uneval(exception.toString());
}
return exception.toString();
case 'number':
case "number":
for (let name in Components.results) {
if (exception === Components.results[name]) {
return "Components.results." + name;
@ -1047,8 +1038,7 @@ function do_get_file(path, allowNonexistent) {
}
return lf;
}
catch (ex) {
} catch (ex) {
do_throw(ex.toString(), Components.stack.caller);
}
@ -1090,7 +1080,7 @@ function do_parse_document(aPath, aType) {
}
let file = do_get_file(aPath),
ios = Components.classes['@mozilla.org/network/io-service;1']
ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService),
url = ios.newFileURI(file).spec;
file = null;
@ -1113,8 +1103,7 @@ function do_parse_document(aPath, aType) {
* @param aFunction
* The function to be called when the test harness has finished running.
*/
function do_register_cleanup(aFunction)
{
function do_register_cleanup(aFunction) {
_cleanupFunctions.push(aFunction);
}
@ -1236,8 +1225,7 @@ function do_get_profile(notifyProfileAfterChange = false) {
* (Note that you may use sendCommand without calling this function first; you
* simply won't have any of the functions in this file available.)
*/
function do_load_child_test_harness()
{
function do_load_child_test_harness() {
// Make sure this isn't called from child process
if (!runningInParent) {
do_throw("run_test_in_child cannot be called from child!");
@ -1259,7 +1247,7 @@ function do_load_child_test_harness()
+ "const _JSDEBUGGER_PORT=0; "
+ "const _XPCSHELL_PROCESS='child';";
if (typeof _JSCOV_DIR === 'string') {
if (typeof _JSCOV_DIR === "string") {
command += " const _JSCOV_DIR=" + uneval(_JSCOV_DIR) + ";";
}
@ -1284,12 +1272,11 @@ function do_load_child_test_harness()
* complete. If provided, the function must call do_test_finished();
* @return Promise Resolved when the test in the child is complete.
*/
function run_test_in_child(testFile, optionalCallback)
{
function run_test_in_child(testFile, optionalCallback) {
return new Promise((resolve) => {
var callback = () => {
resolve();
if (typeof optionalCallback == 'undefined') {
if (typeof optionalCallback == "undefined") {
do_test_finished();
} else {
optionalCallback();
@ -1317,8 +1304,7 @@ function run_test_in_child(testFile, optionalCallback)
* the function must call do_test_finished().
* @return Promise Promise that is resolved when the message is received.
*/
function do_await_remote_message(name, optionalCallback)
{
function do_await_remote_message(name, optionalCallback) {
return new Promise((resolve) => {
var listener = {
receiveMessage: function(message) {
@ -1354,10 +1340,10 @@ function do_send_remote_message(name) {
var sender;
if (runningInParent) {
mm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIMessageBroadcaster);
sender = 'broadcastAsyncMessage';
sender = "broadcastAsyncMessage";
} else {
mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender);
sender = 'sendAsyncMessage';
sender = "sendAsyncMessage";
}
mm[sender](name);
}
@ -1518,16 +1504,14 @@ var _gRunningTest = null;
var _gTestIndex = 0; // The index of the currently running test.
var _gTaskRunning = false;
var _gTestHasOnly = false;
function run_next_test()
{
function run_next_test() {
if (_gTaskRunning) {
throw new Error("run_next_test() called from an add_task() test function. " +
"run_next_test() should not be called from inside add_task() " +
"under any circumstances!");
}
function _run_next_test()
{
function _run_next_test() {
if (_gTestIndex < _gTests.length) {
// Check for uncaught rejections as early and often as possible.
_PromiseTestUtils.assertNoUncaughtRejections();