Bug 1367235 - Additional changes for eslint on testing/xpcshell; r=Standard8

This commit is contained in:
Geoff Brown 2017-05-25 07:32:44 -06:00
Родитель 6fe3dae59f
Коммит 0da0034332
11 изменённых файлов: 63 добавлений и 35 удалений

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

@ -4,6 +4,8 @@
"use strict"; "use strict";
/* import-globals-from ../../devtools/server/main.js */
const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {}); const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
var { Services } = Cu.import("resource://gre/modules/Services.jsm", {}); var { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {}); const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});

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

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals __URI__ */
// Module used by test_import_module.js // Module used by test_import_module.js
const EXPORTED_SYMBOLS = [ "MODULE_IMPORTED", "MODULE_URI", "SUBMODULE_IMPORTED", "same_scope", "SUBMODULE_IMPORTED_TO_SCOPE" ]; const EXPORTED_SYMBOLS = [ "MODULE_IMPORTED", "MODULE_URI", "SUBMODULE_IMPORTED", "same_scope", "SUBMODULE_IMPORTED_TO_SCOPE" ];
@ -14,8 +16,8 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.importRelative(this, "import_sub_module.jsm"); XPCOMUtils.importRelative(this, "import_sub_module.jsm");
// Prepare two scopes that we can import the submodule into. // Prepare two scopes that we can import the submodule into.
var scope1 = { __URI__: __URI__ }; var scope1 = { __URI__ };
var scope2 = { __URI__: __URI__ }; var scope2 = { __URI__ };
// First one is the regular path. // First one is the regular path.
XPCOMUtils.importRelative(scope1, "import_sub_module.jsm"); XPCOMUtils.importRelative(scope1, "import_sub_module.jsm");
scope1.test_obj.i++; scope1.test_obj.i++;

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

@ -2,4 +2,5 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals subscriptLoaded:true */
subscriptLoaded = true; subscriptLoaded = true;

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

@ -2,5 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals __LOCATION__ */
// Gets loaded via test_location.js // Gets loaded via test_location.js
do_check_eq(__LOCATION__.leafName, "location_load.js"); do_check_eq(__LOCATION__.leafName, "location_load.js");

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

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from ../../head.js */
function run_test() { function run_test() {
let env = Components.classes["@mozilla.org/process/environment;1"] let env = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment); .getService(Components.interfaces.nsIEnvironment);

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

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from ../../head.js */
function run_test() { function run_test() {
do_check_throws_nsIException(function() { do_check_throws_nsIException(function() {
throw Error("I find your relaxed dishabille unpalatable"); throw Error("I find your relaxed dishabille unpalatable");

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

@ -4,6 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from import_module.jsm */
/* import-globals-from import_sub_module.jsm */
/** /**
* Ensures that tests can import a module in the same folder through: * Ensures that tests can import a module in the same folder through:
* Components.utils.import("resource://test/module.jsm"); * Components.utils.import("resource://test/module.jsm");

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

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals __LOCATION__ */
function run_test() { function run_test() {
do_check_eq(__LOCATION__.leafName, "test_location.js"); do_check_eq(__LOCATION__.leafName, "test_location.js");
// also check that __LOCATION__ works via load() // also check that __LOCATION__ works via load()

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

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() { function run_test() {
/* import-globals-from check_profile.js */
load("check_profile.js"); load("check_profile.js");
check_do_get_profile(false); check_do_get_profile(false);
} }

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

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() { function run_test() {
/* import-globals-from check_profile.js */
load("check_profile.js"); load("check_profile.js");
check_do_get_profile(true); check_do_get_profile(true);
} }

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

@ -10,6 +10,20 @@
* for more information. * for more information.
*/ */
/* defined by the harness */
/* globals _HEAD_FILES, _HEAD_JS_PATH, _JSDEBUGGER_PORT, _JSCOV_DIR,
_MOZINFO_JS_PATH, _TEST_FILE, _TEST_NAME, _TESTING_MODULES_DIR,
_XPCSHELL_PROCESS:true */
/* defined by XPCShellImpl.cpp */
/* globals load, sendCommand */
/* must be defined by tests using do_await_remote_message/do_send_remote_message */
/* globals Cc, Ci */
/* may be defined in test files */
/* globals run_test */
var _quit = false; var _quit = false;
var _passed = true; var _passed = true;
var _tests_pending = 0; var _tests_pending = 0;
@ -119,14 +133,14 @@ try {
} }
let listener = { let listener = {
QueryInterface: function(iid) { QueryInterface(iid) {
if (!iid.equals(Components.interfaces.nsISupports) && if (!iid.equals(Components.interfaces.nsISupports) &&
!iid.equals(Components.interfaces.nsIConsoleListener)) { !iid.equals(Components.interfaces.nsIConsoleListener)) {
throw Components.results.NS_NOINTERFACE; throw Components.results.NS_NOINTERFACE;
} }
return this; return this;
}, },
observe: function(msg) { observe(msg) {
if (typeof do_print === "function") if (typeof do_print === "function")
do_print("CONSOLE_MESSAGE: (" + levelNames[msg.logLevel] + ") " + msg.toString()); do_print("CONSOLE_MESSAGE: (" + levelNames[msg.logLevel] + ") " + msg.toString());
} }
@ -163,7 +177,7 @@ function _Timer(func, delay) {
_pendingTimers.push(timer); _pendingTimers.push(timer);
} }
_Timer.prototype = { _Timer.prototype = {
QueryInterface: function(iid) { QueryInterface(iid) {
if (iid.equals(Components.interfaces.nsITimerCallback) || if (iid.equals(Components.interfaces.nsITimerCallback) ||
iid.equals(Components.interfaces.nsISupports)) iid.equals(Components.interfaces.nsISupports))
return this; return this;
@ -171,7 +185,7 @@ _Timer.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE; throw Components.results.NS_ERROR_NO_INTERFACE;
}, },
notify: function(timer) { notify(timer) {
_pendingTimers.splice(_pendingTimers.indexOf(timer), 1); _pendingTimers.splice(_pendingTimers.indexOf(timer), 1);
// The current nsITimer implementation can undershoot, but even if it // The current nsITimer implementation can undershoot, but even if it
@ -265,16 +279,16 @@ var _fakeIdleService = {
factory: { factory: {
// nsIFactory // nsIFactory
createInstance: function(aOuter, aIID) { createInstance(aOuter, aIID) {
if (aOuter) { if (aOuter) {
throw Components.results.NS_ERROR_NO_AGGREGATION; throw Components.results.NS_ERROR_NO_AGGREGATION;
} }
return _fakeIdleService.QueryInterface(aIID); return _fakeIdleService.QueryInterface(aIID);
}, },
lockFactory: function(aLock) { lockFactory(aLock) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED; throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}, },
QueryInterface: function(aIID) { QueryInterface(aIID) {
if (aIID.equals(Components.interfaces.nsIFactory) || if (aIID.equals(Components.interfaces.nsIFactory) ||
aIID.equals(Components.interfaces.nsISupports)) { aIID.equals(Components.interfaces.nsISupports)) {
return this; return this;
@ -287,10 +301,10 @@ var _fakeIdleService = {
get idleTime() { get idleTime() {
return 0; return 0;
}, },
addIdleObserver: function() {}, addIdleObserver() {},
removeIdleObserver: function() {}, removeIdleObserver() {},
QueryInterface: function(aIID) { QueryInterface(aIID) {
// Useful for testing purposes, see test_get_idle.js. // Useful for testing purposes, see test_get_idle.js.
if (aIID.equals(Components.interfaces.nsIFactory)) { if (aIID.equals(Components.interfaces.nsIFactory)) {
return this.factory; return this.factory;
@ -599,8 +613,7 @@ function _execute_test() {
} }
} }
_cleanupFunctions = []; _cleanupFunctions = [];
}.bind(this)).catch(reportCleanupError) }).catch(reportCleanupError).then(() => complete = true);
.then(() => complete = true);
let thr = Components.classes["@mozilla.org/thread-manager;1"] let thr = Components.classes["@mozilla.org/thread-manager;1"]
.getService().currentThread; .getService().currentThread;
while (!complete) { while (!complete) {
@ -692,7 +705,7 @@ function do_execute_soon(callback, aName) {
.getService(Components.interfaces.nsIThreadManager); .getService(Components.interfaces.nsIThreadManager);
tm.dispatchToMainThread({ tm.dispatchToMainThread({
run: function() { run() {
try { try {
callback(); callback();
} catch (e) { } catch (e) {
@ -858,22 +871,20 @@ function do_report_result(passed, text, stack, todo) {
"PASS", "PASS",
message); message);
} }
} else if (todo) {
_testLogger.testStatus(_TEST_NAME,
name,
"FAIL",
"FAIL",
message);
} else { } else {
if (todo) { _testLogger.testStatus(_TEST_NAME,
_testLogger.testStatus(_TEST_NAME, name,
name, "FAIL",
"FAIL", "PASS",
"FAIL", message,
message); _format_stack(stack));
} else { _abort_failed_test();
_testLogger.testStatus(_TEST_NAME,
name,
"FAIL",
"PASS",
message,
_format_stack(stack));
_abort_failed_test();
}
} }
} }
@ -1139,9 +1150,8 @@ function do_get_minidumpdir() {
.createInstance(Components.interfaces.nsILocalFile); .createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(path); file.initWithPath(path);
return file; return file;
} else {
return do_get_tempdir();
} }
return do_get_tempdir();
} }
/** /**
@ -1168,7 +1178,7 @@ function do_get_profile(notifyProfileAfterChange = false) {
let dirSvc = Components.classes["@mozilla.org/file/directory_service;1"] let dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties); .getService(Components.interfaces.nsIProperties);
let provider = { let provider = {
getFile: function(prop, persistent) { getFile(prop, persistent) {
persistent.value = true; persistent.value = true;
if (prop == "ProfD" || prop == "ProfLD" || prop == "ProfDS" || if (prop == "ProfD" || prop == "ProfLD" || prop == "ProfDS" ||
prop == "ProfLDS" || prop == "TmpD") { prop == "ProfLDS" || prop == "TmpD") {
@ -1176,7 +1186,7 @@ function do_get_profile(notifyProfileAfterChange = false) {
} }
return null; return null;
}, },
QueryInterface: function(iid) { QueryInterface(iid) {
if (iid.equals(Components.interfaces.nsIDirectoryServiceProvider) || if (iid.equals(Components.interfaces.nsIDirectoryServiceProvider) ||
iid.equals(Components.interfaces.nsISupports)) { iid.equals(Components.interfaces.nsISupports)) {
return this; return this;
@ -1307,7 +1317,7 @@ function run_test_in_child(testFile, optionalCallback) {
function do_await_remote_message(name, optionalCallback) { function do_await_remote_message(name, optionalCallback) {
return new Promise((resolve) => { return new Promise((resolve) => {
var listener = { var listener = {
receiveMessage: function(message) { receiveMessage(message) {
if (message.name == name) { if (message.name == name) {
mm.removeMessageListener(name, listener); mm.removeMessageListener(name, listener);
resolve(); resolve();