forked from mirrors/gecko-dev
Bug 1367235 - Enable eslint on testing/xpcshell - mechanical updates; r=Standard8
This commit is contained in:
parent
4e7a503b65
commit
6fe3dae59f
14 changed files with 87 additions and 91 deletions
|
|
@ -37,7 +37,6 @@ python/**
|
||||||
rdf/**
|
rdf/**
|
||||||
servo/**
|
servo/**
|
||||||
startupcache/**
|
startupcache/**
|
||||||
testing/**
|
|
||||||
tools/update-packaging/**
|
tools/update-packaging/**
|
||||||
uriloader/**
|
uriloader/**
|
||||||
view/**
|
view/**
|
||||||
|
|
@ -295,6 +294,19 @@ security/nss/**
|
||||||
services/sync/modules/constants.js
|
services/sync/modules/constants.js
|
||||||
services/sync/services-sync.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
|
# Third party services
|
||||||
services/common/kinto-http-client.js
|
services/common/kinto-http-client.js
|
||||||
services/common/kinto-offline-client.js
|
services/common/kinto-offline-client.js
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
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", {});
|
||||||
|
|
@ -19,8 +19,7 @@ const { BrowserTabList } = devtools.require("devtools/server/actors/webbrowser")
|
||||||
* Construct a root actor appropriate for use in a server running xpcshell
|
* Construct a root actor appropriate for use in a server running xpcshell
|
||||||
* tests. <snip boilerplate> :)
|
* tests. <snip boilerplate> :)
|
||||||
*/
|
*/
|
||||||
function createRootActor(connection)
|
function createRootActor(connection) {
|
||||||
{
|
|
||||||
let parameters = {
|
let parameters = {
|
||||||
tabList: new XPCSTTabList(connection),
|
tabList: new XPCSTTabList(connection),
|
||||||
globalActorFactories: DebuggerServer.globalActorFactories,
|
globalActorFactories: DebuggerServer.globalActorFactories,
|
||||||
|
|
@ -37,8 +36,7 @@ function createRootActor(connection)
|
||||||
* A "stub" TabList implementation that provides no tabs.
|
* A "stub" TabList implementation that provides no tabs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function XPCSTTabList(connection)
|
function XPCSTTabList(connection) {
|
||||||
{
|
|
||||||
BrowserTabList.call(this, connection);
|
BrowserTabList.call(this, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
testing/xpcshell/example/unit/.eslintrc.js
Normal file
7
testing/xpcshell/example/unit/.eslintrc.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
"extends": [
|
||||||
|
"plugin:mozilla/xpcshell-test"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
var {classes: Cc, interfaces: Ci} = Components;
|
var {classes: Cc, interfaces: Ci} = Components;
|
||||||
|
|
||||||
function check_profile_dir(profd)
|
function check_profile_dir(profd) {
|
||||||
{
|
|
||||||
Assert.ok(profd.exists());
|
Assert.ok(profd.exists());
|
||||||
Assert.ok(profd.isDirectory());
|
Assert.ok(profd.isDirectory());
|
||||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
||||||
|
|
@ -17,8 +16,7 @@ function check_profile_dir(profd)
|
||||||
Assert.ok(profd.equals(profd2));
|
Assert.ok(profd.equals(profd2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_do_get_profile(fireProfileAfterChange)
|
function check_do_get_profile(fireProfileAfterChange) {
|
||||||
{
|
|
||||||
const observedTopics = new Map([
|
const observedTopics = new Map([
|
||||||
["profile-do-change", 0],
|
["profile-do-change", 0],
|
||||||
["profile-after-change", 0],
|
["profile-after-change", 0],
|
||||||
|
|
@ -27,7 +25,7 @@ function check_do_get_profile(fireProfileAfterChange)
|
||||||
|
|
||||||
const obs = Cc["@mozilla.org/observer-service;1"]
|
const obs = Cc["@mozilla.org/observer-service;1"]
|
||||||
.getService(Ci.nsIObserverService);
|
.getService(Ci.nsIObserverService);
|
||||||
for (let [topic,] of observedTopics) {
|
for (let [topic, ] of observedTopics) {
|
||||||
obs.addObserver(() => {
|
obs.addObserver(() => {
|
||||||
let val = observedTopics.get(topic) + 1;
|
let val = observedTopics.get(topic) + 1;
|
||||||
observedTopics.set(topic, val);
|
observedTopics.set(topic, val);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
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);
|
||||||
do_check_throws_nsIException(function () {
|
do_check_throws_nsIException(function() {
|
||||||
env.QueryInterface(Components.interfaces.nsIFile);
|
env.QueryInterface(Components.interfaces.nsIFile);
|
||||||
}, "NS_NOINTERFACE");
|
}, "NS_NOINTERFACE");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
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");
|
||||||
}, "NS_NOINTERFACE");
|
}, "NS_NOINTERFACE");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
do_check_matches({x:1}, {x:1});
|
do_check_matches({x: 1}, {x: 1});
|
||||||
|
|
||||||
// Property order is irrelevant.
|
// Property order is irrelevant.
|
||||||
do_check_matches({x:"foo", y:"bar"}, {y:"bar", x:"foo"});// pass
|
do_check_matches({x: "foo", y: "bar"}, {y: "bar", x: "foo"});// pass
|
||||||
|
|
||||||
// Patterns nest.
|
// Patterns nest.
|
||||||
do_check_matches({a:1, b:{c:2,d:3}}, {a:1, b:{c:2,d:3}});
|
do_check_matches({a: 1, b: {c: 2, d: 3}}, {a: 1, b: {c: 2, d: 3}});
|
||||||
|
|
||||||
do_check_matches([3,4,5], [3,4,5]);
|
do_check_matches([3, 4, 5], [3, 4, 5]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
do_check_matches({x:1}, {}); // fail: all pattern props required
|
do_check_matches({x: 1}, {}); // fail: all pattern props required
|
||||||
do_check_matches({x:1}, {x:2}); // fail: values must match
|
do_check_matches({x: 1}, {x: 2}); // fail: values must match
|
||||||
do_check_matches({x:undefined}, {});
|
do_check_matches({x: undefined}, {});
|
||||||
|
|
||||||
// 'length' property counts, even if non-enumerable.
|
// 'length' property counts, even if non-enumerable.
|
||||||
do_check_matches([3,4,5], [3,5,5]); // fail; value doesn't match
|
do_check_matches([3, 4, 5], [3, 5, 5]); // fail; value doesn't match
|
||||||
do_check_matches([3,4,5], [3,4,5,6]);// fail; length doesn't match
|
do_check_matches([3, 4, 5], [3, 4, 5, 6]);// fail; length doesn't match
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
do_check_true(typeof(this['MODULE_IMPORTED']) == "undefined");
|
do_check_true(typeof(this["MODULE_IMPORTED"]) == "undefined");
|
||||||
do_check_true(typeof(this['MODULE_URI']) == "undefined");
|
do_check_true(typeof(this["MODULE_URI"]) == "undefined");
|
||||||
let uri = "resource://test/import_module.jsm";
|
let uri = "resource://test/import_module.jsm";
|
||||||
Components.utils.import(uri);
|
Components.utils.import(uri);
|
||||||
do_check_true(MODULE_URI == uri);
|
do_check_true(MODULE_URI == uri);
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,8 @@ function run_test() {
|
||||||
try {
|
try {
|
||||||
load("file_that_does_not_exist.js");
|
load("file_that_does_not_exist.js");
|
||||||
subscriptLoaded = true;
|
subscriptLoaded = true;
|
||||||
}
|
} catch (ex) {
|
||||||
catch (ex) {
|
do_check_eq(ex.message.substring(0, 16), "cannot open file");
|
||||||
do_check_eq(ex.message.substring(0,16), "cannot open file");
|
|
||||||
}
|
}
|
||||||
do_check_false(subscriptLoaded, "load() should throw an error");
|
do_check_false(subscriptLoaded, "load() should throw an error");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,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/. */
|
||||||
|
|
||||||
function run_test()
|
function run_test() {
|
||||||
{
|
|
||||||
load("check_profile.js");
|
load("check_profile.js");
|
||||||
check_do_get_profile(false);
|
check_do_get_profile(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,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/. */
|
||||||
|
|
||||||
function run_test()
|
function run_test() {
|
||||||
{
|
|
||||||
load("check_profile.js");
|
load("check_profile.js");
|
||||||
check_do_get_profile(true);
|
check_do_get_profile(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +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/. */
|
||||||
|
|
||||||
/* This is the most basic testcase. It makes some trivial assertions,
|
/* This is the most basic testcase. It makes some trivial assertions,
|
||||||
* then sets a timeout, and exits the test harness when that timeout
|
* then sets a timeout, and exits the test harness when that timeout
|
||||||
* fires. This is meant to demonstrate that there is a complete event
|
* fires. This is meant to demonstrate that there is a complete event
|
||||||
* system available to test scripts.
|
* system available to test scripts.
|
||||||
* Available functions are described at:
|
* Available functions are described at:
|
||||||
* http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests
|
* http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,13 @@ var Assert = new AssertCls(function(err, message, stack) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var _add_params = function (params) {
|
var _add_params = function(params) {
|
||||||
if (typeof _XPCSHELL_PROCESS != "undefined") {
|
if (typeof _XPCSHELL_PROCESS != "undefined") {
|
||||||
params.xpcshell_process = _XPCSHELL_PROCESS;
|
params.xpcshell_process = _XPCSHELL_PROCESS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var _dumpLog = function (raw_msg) {
|
var _dumpLog = function(raw_msg) {
|
||||||
dump("\n" + JSON.stringify(raw_msg) + "\n");
|
dump("\n" + JSON.stringify(raw_msg) + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,8 +66,7 @@ try {
|
||||||
runningInParent = Components.classes["@mozilla.org/xre/runtime;1"].
|
runningInParent = Components.classes["@mozilla.org/xre/runtime;1"].
|
||||||
getService(Components.interfaces.nsIXULRuntime).processType
|
getService(Components.interfaces.nsIXULRuntime).processType
|
||||||
== Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
== Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||||
}
|
} catch (e) { }
|
||||||
catch (e) { }
|
|
||||||
|
|
||||||
// Only if building of places is enabled.
|
// Only if building of places is enabled.
|
||||||
if (runningInParent &&
|
if (runningInParent &&
|
||||||
|
|
@ -93,8 +92,7 @@ try {
|
||||||
prefs.setCharPref("network.dns.ipv4OnlyDomains", "localhost");
|
prefs.setCharPref("network.dns.ipv4OnlyDomains", "localhost");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (e) { }
|
||||||
catch (e) { }
|
|
||||||
|
|
||||||
// Configure crash reporting, if possible
|
// Configure crash reporting, if possible
|
||||||
// We rely on the Python harness to set MOZ_CRASHREPORTER,
|
// We rely on the Python harness to set MOZ_CRASHREPORTER,
|
||||||
|
|
@ -110,8 +108,7 @@ try {
|
||||||
crashReporter.UpdateCrashEventsDir();
|
crashReporter.UpdateCrashEventsDir();
|
||||||
crashReporter.minidumpPath = do_get_minidumpdir();
|
crashReporter.minidumpPath = do_get_minidumpdir();
|
||||||
}
|
}
|
||||||
}
|
} catch (e) { }
|
||||||
catch (e) { }
|
|
||||||
|
|
||||||
// Configure a console listener so messages sent to it are logged as part
|
// Configure a console listener so messages sent to it are logged as part
|
||||||
// of the test.
|
// of the test.
|
||||||
|
|
@ -122,14 +119,14 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
let listener = {
|
let listener = {
|
||||||
QueryInterface : function(iid) {
|
QueryInterface: function(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: function(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());
|
||||||
}
|
}
|
||||||
|
|
@ -240,8 +237,7 @@ var _fakeIdleService = {
|
||||||
return this.registrar.contractIDToCID(this.contractID);
|
return this.registrar.contractIDToCID(this.contractID);
|
||||||
},
|
},
|
||||||
|
|
||||||
activate: function FIS_activate()
|
activate: function FIS_activate() {
|
||||||
{
|
|
||||||
if (!this.originalFactory) {
|
if (!this.originalFactory) {
|
||||||
// Save original factory.
|
// Save original factory.
|
||||||
this.originalFactory =
|
this.originalFactory =
|
||||||
|
|
@ -256,8 +252,7 @@ var _fakeIdleService = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function FIS_deactivate()
|
deactivate: function FIS_deactivate() {
|
||||||
{
|
|
||||||
if (this.originalFactory) {
|
if (this.originalFactory) {
|
||||||
// Unregister the mock.
|
// Unregister the mock.
|
||||||
this.registrar.unregisterFactory(this.CID, this.factory);
|
this.registrar.unregisterFactory(this.CID, this.factory);
|
||||||
|
|
@ -270,14 +265,13 @@ var _fakeIdleService = {
|
||||||
|
|
||||||
factory: {
|
factory: {
|
||||||
// nsIFactory
|
// nsIFactory
|
||||||
createInstance: function (aOuter, aIID)
|
createInstance: function(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: function(aLock) {
|
||||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||||
},
|
},
|
||||||
QueryInterface: function(aIID) {
|
QueryInterface: function(aIID) {
|
||||||
|
|
@ -293,8 +287,8 @@ var _fakeIdleService = {
|
||||||
get idleTime() {
|
get idleTime() {
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
addIdleObserver: function () {},
|
addIdleObserver: function() {},
|
||||||
removeIdleObserver: function () {},
|
removeIdleObserver: function() {},
|
||||||
|
|
||||||
QueryInterface: function(aIID) {
|
QueryInterface: function(aIID) {
|
||||||
// Useful for testing purposes, see test_get_idle.js.
|
// Useful for testing purposes, see test_get_idle.js.
|
||||||
|
|
@ -448,7 +442,7 @@ function _setupDebuggerServer(breakpointFiles, callback) {
|
||||||
|
|
||||||
function _initDebugging(port) {
|
function _initDebugging(port) {
|
||||||
let initialized = false;
|
let initialized = false;
|
||||||
let DebuggerServer = _setupDebuggerServer(_TEST_FILE, () => {initialized = true;});
|
let DebuggerServer = _setupDebuggerServer(_TEST_FILE, () => { initialized = true; });
|
||||||
|
|
||||||
do_print("");
|
do_print("");
|
||||||
do_print("*******************************************************************");
|
do_print("*******************************************************************");
|
||||||
|
|
@ -505,7 +499,7 @@ function _execute_test() {
|
||||||
_PromiseTestUtils.Assert = Assert;
|
_PromiseTestUtils.Assert = Assert;
|
||||||
|
|
||||||
let coverageCollector = null;
|
let coverageCollector = null;
|
||||||
if (typeof _JSCOV_DIR === 'string') {
|
if (typeof _JSCOV_DIR === "string") {
|
||||||
let _CoverageCollector = Components.utils.import("resource://testing-common/CoverageUtils.jsm", {}).CoverageCollector;
|
let _CoverageCollector = Components.utils.import("resource://testing-common/CoverageUtils.jsm", {}).CoverageCollector;
|
||||||
coverageCollector = new _CoverageCollector(_JSCOV_DIR);
|
coverageCollector = new _CoverageCollector(_JSCOV_DIR);
|
||||||
}
|
}
|
||||||
|
|
@ -522,7 +516,7 @@ function _execute_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_gTestHasOnly) {
|
if (_gTestHasOnly) {
|
||||||
_gTests = _gTests.filter(([props,]) => {
|
_gTests = _gTests.filter(([props, ]) => {
|
||||||
return ("_only" in props) && props._only;
|
return ("_only" in props) && props._only;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -666,7 +660,7 @@ function _wrap_with_quotes_if_necessary(val) {
|
||||||
return typeof val == "string" ? '"' + val + '"' : val;
|
return typeof val == "string" ? '"' + val + '"' : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************** Functions to be used from the tests **************/
|
/* ************* Functions to be used from the tests ************* */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a message to the output log.
|
* Prints a message to the output log.
|
||||||
|
|
@ -711,14 +705,13 @@ function do_execute_soon(callback, aName) {
|
||||||
let stack = e.stack ? _format_stack(e.stack) : null;
|
let stack = e.stack ? _format_stack(e.stack) : null;
|
||||||
_testLogger.testStatus(_TEST_NAME,
|
_testLogger.testStatus(_TEST_NAME,
|
||||||
funcName,
|
funcName,
|
||||||
'FAIL',
|
"FAIL",
|
||||||
'PASS',
|
"PASS",
|
||||||
_exception_message(e),
|
_exception_message(e),
|
||||||
stack);
|
stack);
|
||||||
_do_quit();
|
_do_quit();
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
do_test_finished(funcName);
|
do_test_finished(funcName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -930,7 +923,7 @@ function do_check_null(condition, stack) {
|
||||||
Assert.equal(condition, null);
|
Assert.equal(condition, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function todo_check_null(condition, stack=Components.stack.caller) {
|
function todo_check_null(condition, stack = Components.stack.caller) {
|
||||||
todo_check_eq(condition, null, stack);
|
todo_check_eq(condition, null, stack);
|
||||||
}
|
}
|
||||||
function do_check_matches(pattern, value) {
|
function do_check_matches(pattern, value) {
|
||||||
|
|
@ -940,10 +933,9 @@ function do_check_matches(pattern, value) {
|
||||||
// Check that |func| throws an nsIException that has
|
// Check that |func| throws an nsIException that has
|
||||||
// |Components.results[resultName]| as the value of its 'result' property.
|
// |Components.results[resultName]| as the value of its 'result' property.
|
||||||
function do_check_throws_nsIException(func, resultName,
|
function do_check_throws_nsIException(func, resultName,
|
||||||
stack=Components.stack.caller, todo=false)
|
stack = Components.stack.caller, todo = false) {
|
||||||
{
|
|
||||||
let expected = Components.results[resultName];
|
let expected = Components.results[resultName];
|
||||||
if (typeof expected !== 'number') {
|
if (typeof expected !== "number") {
|
||||||
do_throw("do_check_throws_nsIException requires a Components.results" +
|
do_throw("do_check_throws_nsIException requires a Components.results" +
|
||||||
" property name, not " + uneval(resultName), stack);
|
" 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
|
// Produce a human-readable form of |exception|. This looks up
|
||||||
// Components.results values, tries toString methods, and so on.
|
// Components.results values, tries toString methods, and so on.
|
||||||
function legible_exception(exception)
|
function legible_exception(exception) {
|
||||||
{
|
|
||||||
switch (typeof exception) {
|
switch (typeof exception) {
|
||||||
case 'object':
|
case "object":
|
||||||
if (exception instanceof Components.interfaces.nsIException) {
|
if (exception instanceof Components.interfaces.nsIException) {
|
||||||
return "nsIException instance: " + uneval(exception.toString());
|
return "nsIException instance: " + uneval(exception.toString());
|
||||||
}
|
}
|
||||||
return exception.toString();
|
return exception.toString();
|
||||||
|
|
||||||
case 'number':
|
case "number":
|
||||||
for (let name in Components.results) {
|
for (let name in Components.results) {
|
||||||
if (exception === Components.results[name]) {
|
if (exception === Components.results[name]) {
|
||||||
return "Components.results." + name;
|
return "Components.results." + name;
|
||||||
|
|
@ -995,14 +986,14 @@ function legible_exception(exception)
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_check_instanceof(value, constructor,
|
function do_check_instanceof(value, constructor,
|
||||||
stack=Components.stack.caller, todo=false) {
|
stack = Components.stack.caller, todo = false) {
|
||||||
do_report_result(value instanceof constructor,
|
do_report_result(value instanceof constructor,
|
||||||
"value should be an instance of " + constructor.name,
|
"value should be an instance of " + constructor.name,
|
||||||
stack, todo);
|
stack, todo);
|
||||||
}
|
}
|
||||||
|
|
||||||
function todo_check_instanceof(value, constructor,
|
function todo_check_instanceof(value, constructor,
|
||||||
stack=Components.stack.caller) {
|
stack = Components.stack.caller) {
|
||||||
do_check_instanceof(value, constructor, stack, true);
|
do_check_instanceof(value, constructor, stack, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1047,8 +1038,7 @@ function do_get_file(path, allowNonexistent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return lf;
|
return lf;
|
||||||
}
|
} catch (ex) {
|
||||||
catch (ex) {
|
|
||||||
do_throw(ex.toString(), Components.stack.caller);
|
do_throw(ex.toString(), Components.stack.caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1090,7 +1080,7 @@ function do_parse_document(aPath, aType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let file = do_get_file(aPath),
|
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),
|
.getService(Components.interfaces.nsIIOService),
|
||||||
url = ios.newFileURI(file).spec;
|
url = ios.newFileURI(file).spec;
|
||||||
file = null;
|
file = null;
|
||||||
|
|
@ -1113,8 +1103,7 @@ function do_parse_document(aPath, aType) {
|
||||||
* @param aFunction
|
* @param aFunction
|
||||||
* The function to be called when the test harness has finished running.
|
* 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);
|
_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
|
* (Note that you may use sendCommand without calling this function first; you
|
||||||
* simply won't have any of the functions in this file available.)
|
* 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
|
// Make sure this isn't called from child process
|
||||||
if (!runningInParent) {
|
if (!runningInParent) {
|
||||||
do_throw("run_test_in_child cannot be called from child!");
|
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 _JSDEBUGGER_PORT=0; "
|
||||||
+ "const _XPCSHELL_PROCESS='child';";
|
+ "const _XPCSHELL_PROCESS='child';";
|
||||||
|
|
||||||
if (typeof _JSCOV_DIR === 'string') {
|
if (typeof _JSCOV_DIR === "string") {
|
||||||
command += " const _JSCOV_DIR=" + uneval(_JSCOV_DIR) + ";";
|
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();
|
* complete. If provided, the function must call do_test_finished();
|
||||||
* @return Promise Resolved when the test in the child is complete.
|
* @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) => {
|
return new Promise((resolve) => {
|
||||||
var callback = () => {
|
var callback = () => {
|
||||||
resolve();
|
resolve();
|
||||||
if (typeof optionalCallback == 'undefined') {
|
if (typeof optionalCallback == "undefined") {
|
||||||
do_test_finished();
|
do_test_finished();
|
||||||
} else {
|
} else {
|
||||||
optionalCallback();
|
optionalCallback();
|
||||||
|
|
@ -1317,8 +1304,7 @@ function run_test_in_child(testFile, optionalCallback)
|
||||||
* the function must call do_test_finished().
|
* the function must call do_test_finished().
|
||||||
* @return Promise Promise that is resolved when the message is received.
|
* @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) => {
|
return new Promise((resolve) => {
|
||||||
var listener = {
|
var listener = {
|
||||||
receiveMessage: function(message) {
|
receiveMessage: function(message) {
|
||||||
|
|
@ -1354,10 +1340,10 @@ function do_send_remote_message(name) {
|
||||||
var sender;
|
var sender;
|
||||||
if (runningInParent) {
|
if (runningInParent) {
|
||||||
mm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIMessageBroadcaster);
|
mm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIMessageBroadcaster);
|
||||||
sender = 'broadcastAsyncMessage';
|
sender = "broadcastAsyncMessage";
|
||||||
} else {
|
} else {
|
||||||
mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender);
|
mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender);
|
||||||
sender = 'sendAsyncMessage';
|
sender = "sendAsyncMessage";
|
||||||
}
|
}
|
||||||
mm[sender](name);
|
mm[sender](name);
|
||||||
}
|
}
|
||||||
|
|
@ -1518,21 +1504,19 @@ var _gRunningTest = null;
|
||||||
var _gTestIndex = 0; // The index of the currently running test.
|
var _gTestIndex = 0; // The index of the currently running test.
|
||||||
var _gTaskRunning = false;
|
var _gTaskRunning = false;
|
||||||
var _gTestHasOnly = false;
|
var _gTestHasOnly = false;
|
||||||
function run_next_test()
|
function run_next_test() {
|
||||||
{
|
|
||||||
if (_gTaskRunning) {
|
if (_gTaskRunning) {
|
||||||
throw new Error("run_next_test() called from an add_task() test function. " +
|
throw new Error("run_next_test() called from an add_task() test function. " +
|
||||||
"run_next_test() should not be called from inside add_task() " +
|
"run_next_test() should not be called from inside add_task() " +
|
||||||
"under any circumstances!");
|
"under any circumstances!");
|
||||||
}
|
}
|
||||||
|
|
||||||
function _run_next_test()
|
function _run_next_test() {
|
||||||
{
|
|
||||||
if (_gTestIndex < _gTests.length) {
|
if (_gTestIndex < _gTests.length) {
|
||||||
// Check for uncaught rejections as early and often as possible.
|
// Check for uncaught rejections as early and often as possible.
|
||||||
_PromiseTestUtils.assertNoUncaughtRejections();
|
_PromiseTestUtils.assertNoUncaughtRejections();
|
||||||
let _properties;
|
let _properties;
|
||||||
[_properties, _gRunningTest,] = _gTests[_gTestIndex++];
|
[_properties, _gRunningTest, ] = _gTests[_gTestIndex++];
|
||||||
if (typeof(_properties.skip_if) == "function" && _properties.skip_if()) {
|
if (typeof(_properties.skip_if) == "function" && _properties.skip_if()) {
|
||||||
let _condition = _properties.skip_if.toSource().replace(/\(\)\s*=>\s*/, "");
|
let _condition = _properties.skip_if.toSource().replace(/\(\)\s*=>\s*/, "");
|
||||||
let _message = _gRunningTest.name
|
let _message = _gRunningTest.name
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue