зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465530 - Enable ESLint rule require-expected-throws-or-rejects for testing/marionette/. r=ato
MozReview-Commit-ID: 2CM4x0vUXbC --HG-- extra : rebase_source : 8b4fb90744b780c42359de173420e699e6d2dd73
This commit is contained in:
Родитель
7cab5a8d5a
Коммит
dd6cb31203
|
@ -54,7 +54,6 @@ module.exports = {
|
|||
"files": [
|
||||
"devtools/client/inspector/extensions/test/head_devtools_inspector_sidebar.js",
|
||||
"storage/test/unit/**",
|
||||
"testing/marionette/test/unit/**",
|
||||
"toolkit/components/extensions/**",
|
||||
"toolkit/mozapps/extensions/test/xpcshell/**"
|
||||
],
|
||||
|
|
|
@ -224,8 +224,8 @@ add_test(function test_array() {
|
|||
|
||||
add_test(function test_that() {
|
||||
equal(1, assert.that(n => n + 1)(1));
|
||||
Assert.throws(() => assert.that(() => false)());
|
||||
Assert.throws(() => assert.that(val => val)(false));
|
||||
Assert.throws(() => assert.that(() => false)(), InvalidArgumentError);
|
||||
Assert.throws(() => assert.that(val => val)(false), InvalidArgumentError);
|
||||
Assert.throws(() => assert.that(val => val, "foo", SessionNotCreatedError)(false),
|
||||
SessionNotCreatedError);
|
||||
|
||||
|
|
|
@ -306,17 +306,17 @@ add_test(function test_coordinates() {
|
|||
deepEqual({x: 10, y: 10}, element.coordinates(domEl, 10, 10));
|
||||
deepEqual({x: -5, y: -5}, element.coordinates(domEl, -5, -5));
|
||||
|
||||
Assert.throws(() => element.coordinates(null));
|
||||
Assert.throws(() => element.coordinates(null), /node is null/);
|
||||
|
||||
Assert.throws(() => element.coordinates(domEl, "string", undefined));
|
||||
Assert.throws(() => element.coordinates(domEl, undefined, "string"));
|
||||
Assert.throws(() => element.coordinates(domEl, "string", "string"));
|
||||
Assert.throws(() => element.coordinates(domEl, {}, undefined));
|
||||
Assert.throws(() => element.coordinates(domEl, undefined, {}));
|
||||
Assert.throws(() => element.coordinates(domEl, {}, {}));
|
||||
Assert.throws(() => element.coordinates(domEl, [], undefined));
|
||||
Assert.throws(() => element.coordinates(domEl, undefined, []));
|
||||
Assert.throws(() => element.coordinates(domEl, [], []));
|
||||
Assert.throws(() => element.coordinates(domEl, "string", undefined), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, undefined, "string"), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, "string", "string"), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, {}, undefined), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, undefined, {}), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, {}, {}), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, [], undefined), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, undefined, []), /Offset must be a number/);
|
||||
Assert.throws(() => element.coordinates(domEl, [], []), /Offset must be a number/);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -326,7 +326,7 @@ add_test(function test_WebElement_ctor() {
|
|||
equal(el.uuid, "foo");
|
||||
|
||||
for (let t of [42, true, [], {}, null, undefined]) {
|
||||
Assert.throws(() => new WebElement(t));
|
||||
Assert.throws(() => new WebElement(t), /to be a string/);
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
|
|
|
@ -94,11 +94,11 @@ add_test(function test_Command_fromPacket() {
|
|||
equal(c1.name, c2.name);
|
||||
equal(c1.parameters, c2.parameters);
|
||||
|
||||
Assert.throws(() => Command.fromPacket([null, 2, "foo", {}]));
|
||||
Assert.throws(() => Command.fromPacket([1, 2, "foo", {}]));
|
||||
Assert.throws(() => Command.fromPacket([0, null, "foo", {}]));
|
||||
Assert.throws(() => Command.fromPacket([0, 2, null, {}]));
|
||||
Assert.throws(() => Command.fromPacket([0, 2, "foo", false]));
|
||||
Assert.throws(() => Command.fromPacket([null, 2, "foo", {}]), /InvalidArgumentError/);
|
||||
Assert.throws(() => Command.fromPacket([1, 2, "foo", {}]), /InvalidArgumentError/);
|
||||
Assert.throws(() => Command.fromPacket([0, null, "foo", {}]), /InvalidArgumentError/);
|
||||
Assert.throws(() => Command.fromPacket([0, 2, null, {}]), /InvalidArgumentError/);
|
||||
Assert.throws(() => Command.fromPacket([0, 2, "foo", false]), /InvalidArgumentError/);
|
||||
|
||||
let nullParams = Command.fromPacket([0, 2, "foo", null]);
|
||||
equal("[object Object]", Object.prototype.toString.call(nullParams.parameters));
|
||||
|
@ -231,10 +231,10 @@ add_test(function test_Response_fromPacket() {
|
|||
equal(r1.error, r2.error);
|
||||
equal(r1.body, r2.body);
|
||||
|
||||
Assert.throws(() => Response.fromPacket([null, 2, "foo", {}]));
|
||||
Assert.throws(() => Response.fromPacket([0, 2, "foo", {}]));
|
||||
Assert.throws(() => Response.fromPacket([1, null, "foo", {}]));
|
||||
Assert.throws(() => Response.fromPacket([1, 2, null, {}]));
|
||||
Assert.throws(() => Response.fromPacket([null, 2, "foo", {}]), InvalidArgumentError);
|
||||
Assert.throws(() => Response.fromPacket([0, 2, "foo", {}]), InvalidArgumentError);
|
||||
Assert.throws(() => Response.fromPacket([1, null, "foo", {}]), InvalidArgumentError);
|
||||
Assert.throws(() => Response.fromPacket([1, 2, null, {}]), InvalidArgumentError);
|
||||
Response.fromPacket([1, 2, "foo", null]);
|
||||
|
||||
run_next_test();
|
||||
|
|
|
@ -432,13 +432,13 @@ add_test(function test_Capabilities_fromJSON() {
|
|||
equal(true, caps.get("acceptInsecureCerts"));
|
||||
caps = fromJSON({acceptInsecureCerts: false});
|
||||
equal(false, caps.get("acceptInsecureCerts"));
|
||||
Assert.throws(() => fromJSON({acceptInsecureCerts: "foo"}));
|
||||
Assert.throws(() => fromJSON({acceptInsecureCerts: "foo"}), InvalidArgumentError);
|
||||
|
||||
for (let strategy of Object.values(session.PageLoadStrategy)) {
|
||||
caps = fromJSON({pageLoadStrategy: strategy});
|
||||
equal(strategy, caps.get("pageLoadStrategy"));
|
||||
}
|
||||
Assert.throws(() => fromJSON({pageLoadStrategy: "foo"}));
|
||||
Assert.throws(() => fromJSON({pageLoadStrategy: "foo"}), InvalidArgumentError);
|
||||
|
||||
let proxyConfig = {proxyType: "manual"};
|
||||
caps = fromJSON({proxy: proxyConfig});
|
||||
|
@ -452,22 +452,24 @@ add_test(function test_Capabilities_fromJSON() {
|
|||
equal(true, caps.get("moz:accessibilityChecks"));
|
||||
caps = fromJSON({"moz:accessibilityChecks": false});
|
||||
equal(false, caps.get("moz:accessibilityChecks"));
|
||||
Assert.throws(() => fromJSON({"moz:accessibilityChecks": "foo"}));
|
||||
Assert.throws(() => fromJSON({"moz:accessibilityChecks": 1}));
|
||||
Assert.throws(() => fromJSON({"moz:accessibilityChecks": "foo"}), InvalidArgumentError);
|
||||
Assert.throws(() => fromJSON({"moz:accessibilityChecks": 1}), InvalidArgumentError);
|
||||
|
||||
caps = fromJSON({"moz:useNonSpecCompliantPointerOrigin": false});
|
||||
equal(false, caps.get("moz:useNonSpecCompliantPointerOrigin"));
|
||||
caps = fromJSON({"moz:useNonSpecCompliantPointerOrigin": true});
|
||||
equal(true, caps.get("moz:useNonSpecCompliantPointerOrigin"));
|
||||
Assert.throws(() => fromJSON({"moz:useNonSpecCompliantPointerOrigin": "foo"}));
|
||||
Assert.throws(() => fromJSON({"moz:useNonSpecCompliantPointerOrigin": 1}));
|
||||
Assert.throws(() => fromJSON({"moz:useNonSpecCompliantPointerOrigin": "foo"}),
|
||||
InvalidArgumentError);
|
||||
Assert.throws(() => fromJSON({"moz:useNonSpecCompliantPointerOrigin": 1}),
|
||||
InvalidArgumentError);
|
||||
|
||||
caps = fromJSON({"moz:webdriverClick": true});
|
||||
equal(true, caps.get("moz:webdriverClick"));
|
||||
caps = fromJSON({"moz:webdriverClick": false});
|
||||
equal(false, caps.get("moz:webdriverClick"));
|
||||
Assert.throws(() => fromJSON({"moz:webdriverClick": "foo"}));
|
||||
Assert.throws(() => fromJSON({"moz:webdriverClick": 1}));
|
||||
Assert.throws(() => fromJSON({"moz:webdriverClick": "foo"}), InvalidArgumentError);
|
||||
Assert.throws(() => fromJSON({"moz:webdriverClick": 1}), InvalidArgumentError);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче