Backed out 4 changesets (bug 1410652) for eslint failure at testing/marionette/element.js: Line 1456 exceeds the maximum line length of 78. r=backout

Backed out changeset 97031d4ea2bd (bug 1410652)
Backed out changeset 66754caa4c52 (bug 1410652)
Backed out changeset 48048929bb17 (bug 1410652)
Backed out changeset 265a168b4e37 (bug 1410652)
This commit is contained in:
Sebastian Hengst 2017-10-30 19:32:43 +01:00
Родитель 8cd7e47451
Коммит 7eb270c395
4 изменённых файлов: 79 добавлений и 85 удалений

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

@ -81,7 +81,7 @@ assert.fennec = function(msg = "") {
};
/**
* Asserts that the current <var>context</var> is content.
* Asserts that the current |context| is content.
*
* @param {string} context
* Context to test.
@ -89,10 +89,10 @@ assert.fennec = function(msg = "") {
* Custom error message.
*
* @return {string}
* <var>context</var> is returned unaltered.
* |context| is returned unaltered.
*
* @throws {UnsupportedOperationError}
* If <var>context</var> is not content.
* If |context| is not content.
*/
assert.content = function(context, msg = "") {
msg = msg || "Only supported in content context";
@ -108,10 +108,10 @@ assert.content = function(context, msg = "") {
* Custom error message.
*
* @return {ChromeWindow}
* <var>win</var> is returned unaltered.
* |win| is returned unaltered.
*
* @throws {NoSuchWindowError}
* If <var>win</var> has been closed.
* If |win| has been closed.
*/
assert.window = function(win, msg = "") {
msg = msg || "Unable to locate window";
@ -161,7 +161,7 @@ assert.noUserPrompt = function(dialog, msg = "") {
};
/**
* Asserts that <var>obj</var> is defined.
* Asserts that |obj| is defined.
*
* @param {?} obj
* Value to test.
@ -169,10 +169,10 @@ assert.noUserPrompt = function(dialog, msg = "") {
* Custom error message.
*
* @return {?}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not defined.
* If |obj| is not defined.
*/
assert.defined = function(obj, msg = "") {
msg = msg || pprint`Expected ${obj} to be defined`;
@ -180,7 +180,7 @@ assert.defined = function(obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is a finite number.
* Asserts that |obj| is a finite number.
*
* @param {?} obj
* Value to test.
@ -188,10 +188,10 @@ assert.defined = function(obj, msg = "") {
* Custom error message.
*
* @return {number}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not a number.
* If |obj| is not a number.
*/
assert.number = function(obj, msg = "") {
msg = msg || pprint`Expected ${obj} to be finite number`;
@ -199,7 +199,7 @@ assert.number = function(obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is callable.
* Asserts that |obj| is callable.
*
* @param {?} obj
* Value to test.
@ -207,10 +207,10 @@ assert.number = function(obj, msg = "") {
* Custom error message.
*
* @return {Function}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not callable.
* If |obj| is not callable.
*/
assert.callable = function(obj, msg = "") {
msg = msg || pprint`${obj} is not callable`;
@ -218,7 +218,7 @@ assert.callable = function(obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is an integer.
* Asserts that |obj| is an integer.
*
* @param {?} obj
* Value to test.
@ -226,10 +226,10 @@ assert.callable = function(obj, msg = "") {
* Custom error message.
*
* @return {number}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not an integer.
* If |obj| is not an integer.
*/
assert.integer = function(obj, msg = "") {
msg = msg || pprint`Expected ${obj} to be an integer`;
@ -237,7 +237,7 @@ assert.integer = function(obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is a positive integer.
* Asserts that |obj| is a positive integer.
*
* @param {?} obj
* Value to test.
@ -245,10 +245,10 @@ assert.integer = function(obj, msg = "") {
* Custom error message.
*
* @return {number}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not a positive integer.
* If |obj| is not a positive integer.
*/
assert.positiveInteger = function(obj, msg = "") {
assert.integer(obj, msg);
@ -257,7 +257,7 @@ assert.positiveInteger = function(obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is a boolean.
* Asserts that |obj| is a boolean.
*
* @param {?} obj
* Value to test.
@ -265,10 +265,10 @@ assert.positiveInteger = function(obj, msg = "") {
* Custom error message.
*
* @return {boolean}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not a boolean.
* If |obj| is not a boolean.
*/
assert.boolean = function(obj, msg = "") {
msg = msg || pprint`Expected ${obj} to be boolean`;
@ -276,7 +276,7 @@ assert.boolean = function(obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is a string.
* Asserts that |obj| is a string.
*
* @param {?} obj
* Value to test.
@ -284,10 +284,10 @@ assert.boolean = function(obj, msg = "") {
* Custom error message.
*
* @return {string}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not a string.
* If |obj| is not a string.
*/
assert.string = function(obj, msg = "") {
msg = msg || pprint`Expected ${obj} to be a string`;
@ -295,7 +295,7 @@ assert.string = function(obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is an object.
* Asserts that |obj| is an object.
*
* @param {?} obj
* Value to test.
@ -303,10 +303,10 @@ assert.string = function(obj, msg = "") {
* Custom error message.
*
* @return {Object}
* obj| is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not an object.
* If |obj| is not an object.
*/
assert.object = function(obj, msg = "") {
msg = msg || pprint`Expected ${obj} to be an object`;
@ -319,21 +319,20 @@ assert.object = function(obj, msg = "") {
};
/**
* Asserts that <var>prop</var> is in <var>obj</var>.
* Asserts that |prop| is in |obj|.
*
* @param {?} prop
* Own property to test if is in <var>obj</var>.
* Own property to test if is in |obj|.
* @param {?} obj
* Object.
* @param {string=} msg
* Custom error message.
*
* @return {?}
* Value of <var>obj</var>'s own property <var>prop</var>.
* Value of |obj|'s own property |prop|.
*
* @throws {InvalidArgumentError}
* If <var>prop</var> is not in <var>obj</var>, or <var>obj</var>
* is not an object.
* If |prop| is not in |obj|, or |obj| is not an object.
*/
assert.in = function(prop, obj, msg = "") {
assert.object(obj, msg);
@ -343,7 +342,7 @@ assert.in = function(prop, obj, msg = "") {
};
/**
* Asserts that <var>obj</var> is an Array.
* Asserts that |obj| is an Array.
*
* @param {?} obj
* Value to test.
@ -351,10 +350,10 @@ assert.in = function(prop, obj, msg = "") {
* Custom error message.
*
* @return {Object}
* <var>obj</var> is returned unaltered.
* |obj| is returned unaltered.
*
* @throws {InvalidArgumentError}
* If <var>obj</var> is not an Array.
* If |obj| is not an Array.
*/
assert.array = function(obj, msg = "") {
msg = msg || pprint`Expected ${obj} to be an Array`;
@ -366,17 +365,17 @@ assert.array = function(obj, msg = "") {
*
* @param {function(?): boolean} predicate
* Evaluated on calling the return value of this function. If its
* return value of the inner function is false, <var>error</var>
* is thrown with <var>message</var>.
* return value of the inner function is false, |error| is thrown
* with |message|.
* @param {string=} message
* Custom error message.
* @param {Error=} error
* Custom error type by its class.
*
* @return {function(?): ?}
* Function that takes and returns the passed in value unaltered,
* and which may throw <var>error</var> with <var>message</var>
* if <var>predicate</var> evaluates to false.
* Function that takes and returns the passed in value unaltered, and
* which may throw |error| with |message| if |predicate| evaluates
* to false.
*/
assert.that = function(
predicate, message = "", error = InvalidArgumentError) {

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

@ -1730,16 +1730,7 @@ GeckoDriver.prototype.switchToFrame = async function(cmd) {
assert.window(this.getCurrentWindow());
assert.noUserPrompt(this.dialog);
let {id, focus} = cmd.parameters;
// TODO(ato): element can be either string (deprecated) or a web
// element JSON Object. Can be removed with Firefox 60.
let byFrame;
if (typeof cmd.parameters.element == "string") {
byFrame = WebElement.fromUUID(cmd.parameters.element, Context.Chrome);
} else if (cmd.parameters.element) {
byFrame = WebElement.fromJSON(cmd.parameters.element);
}
let {id, element, focus} = cmd.parameters;
const otherErrorsExpr = /about:.+(error)|(blocked)\?/;
const checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
@ -1767,7 +1758,7 @@ GeckoDriver.prototype.switchToFrame = async function(cmd) {
let foundFrame = null;
// just focus
if (typeof id == "undefined" && !byFrame) {
if (typeof id == "undefined" && typeof element == "undefined") {
this.curFrame = null;
if (focus) {
this.mainFrame.focus();
@ -1778,8 +1769,9 @@ GeckoDriver.prototype.switchToFrame = async function(cmd) {
}
// by element (HTMLIFrameElement)
if (byFrame) {
let wantedFrame = this.curBrowser.seenEls.get(byFrame);
if (typeof element != "undefined") {
let webEl = WebElement.fromUUID(element, Context.Chrome);
let wantedFrame = this.curBrowser.seenEls.get(webEl);
// Deal with an embedded xul:browser case
if (wantedFrame.tagName == "xul:browser" ||
@ -1882,7 +1874,7 @@ GeckoDriver.prototype.switchToFrame = async function(cmd) {
}
} else if (this.context == Context.Content) {
if (!id && !byFrame &&
if (!id && !element &&
this.curBrowser.frameManager.currentRemoteFrame !== null) {
// We're currently using a ChromeMessageSender for a remote frame,
// so this request indicates we need to switch back to the top-level

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

@ -10,7 +10,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("chrome://marionette/content/assert.js");
Cu.import("chrome://marionette/content/atom.js");
const {
InvalidArgumentError,
InvalidSelectorError,
NoSuchElementError,
StaleElementReferenceError,
@ -96,8 +95,8 @@ element.Strategy = {
* Stores known/seen elements and their associated web element
* references.
*
* Elements are added by calling {@link #add()} or {@link addAll()},
* and may be queried by their web element reference using {@link get()}.
* Elements are added by calling |add(el)| or |addAll(elements)|, and
* may be queried by their web element reference using |get(element)|.
*
* @class
* @memberof element
@ -123,7 +122,7 @@ element.Store = class {
*
* @return {Array.<WebElement>}
* List of the web element references associated with each element
* from <var>els</var>.
* from |els|.
*/
addAll(els) {
let add = this.add.bind(this);
@ -259,11 +258,11 @@ element.Store = class {
* document root or a given node.
*
* If |timeout| is above 0, an implicit search technique is used.
* This will wait for the duration of <var>timeout</var> for the
* element to appear in the DOM.
* This will wait for the duration of |timeout| for the element
* to appear in the DOM.
*
* See the {@link element.Strategy} enum for a full list of supported
* search strategies that can be passed to <var>strategy</var>.
* See the |element.Strategy| enum for a full list of supported
* search strategies that can be passed to |strategy|.
*
* Available flags for <var>opts</var>:
*
@ -777,7 +776,7 @@ element.isSelected = function(el) {
* X- and Y coordinates.
*
* @throws TypeError
* If <var>xOffset</var> or <var>yOffset</var> are not numbers.
* If |xOffset| or |yOffset| are not numbers.
*/
element.coordinates = function(
node, xOffset = undefined, yOffset = undefined) {
@ -814,7 +813,7 @@ element.coordinates = function(
* the target's bounding box.
*
* @return {boolean}
* True if if <var>el</var> is in viewport, false otherwise.
* True if if |el| is in viewport, false otherwise.
*/
element.inViewport = function(el, x = undefined, y = undefined) {
let win = el.ownerGlobal;
@ -1246,7 +1245,7 @@ class WebElement {
* @return {(ContentWebElement|ChromeWebElement)}
* Web element reference for <var>el</var>.
*
* @throws {InvalidArgumentError}
* @throws {TypeError}
* If <var>node</var> is neither a <code>WindowProxy</code>,
* DOM element, or a XUL element.
*/
@ -1264,7 +1263,7 @@ class WebElement {
return new ChromeWebElement(uuid);
}
throw new InvalidArgumentError("Expected DOM window/element " +
throw new TypeError("Expected DOM window/element " +
pprint`or XUL element, got: ${node}`);
}
@ -1281,12 +1280,16 @@ class WebElement {
* @return {WebElement}
* Representation of the web element.
*
* @throws {InvalidArgumentError}
* @throws {TypeError}
* If <var>json</var> is not a web element reference.
*/
static fromJSON(json) {
assert.object(json);
let keys = Object.keys(json);
let keys = [];
try {
keys = Object.keys(json);
} catch (e) {
throw new TypeError(`Expected JSON Object: ${e}`);
}
for (let key of keys) {
switch (key) {
@ -1305,7 +1308,7 @@ class WebElement {
}
}
throw new InvalidArgumentError(
throw new TypeError(
pprint`Expected web element reference, got: ${json}`);
}
@ -1330,8 +1333,9 @@ class WebElement {
* based on <var>context</var>.
*
* @throws {InvalidArgumentError}
* If <var>uuid</var> is not a string or <var>context</var>
* is an invalid context.
* If <var>uuid</var> is not a string.
* @throws {TypeError}
* If <var>context</var> is an invalid context.
*/
static fromUUID(uuid, context) {
assert.string(uuid);
@ -1344,7 +1348,7 @@ class WebElement {
return new ContentWebElement(uuid);
default:
throw new InvalidArgumentError("Unknown context: " + context);
throw new TypeError("Unknown context: " + context);
}
}
@ -1403,7 +1407,7 @@ class ContentWebElement extends WebElement {
const {Identifier, LegacyIdentifier} = ContentWebElement;
if (!(Identifier in json) && !(LegacyIdentifier in json)) {
throw new InvalidArgumentError(
throw new TypeError(
pprint`Expected web element reference, got: ${json}`);
}
@ -1430,7 +1434,7 @@ class ContentWebWindow extends WebElement {
static fromJSON(json) {
if (!(ContentWebWindow.Identifier in json)) {
throw new InvalidArgumentError(
throw new TypeError(
pprint`Expected web window reference, got: ${json}`);
}
let uuid = json[ContentWebWindow.Identifier];
@ -1455,7 +1459,7 @@ class ContentWebFrame extends WebElement {
static fromJSON(json) {
if (!(ContentWebFrame.Identifier in json)) {
throw new InvalidArgumentError(pprint`Expected web frame reference, got: ${json}`);
throw new TypeError(pprint`Expected web frame reference, got: ${json}`);
}
let uuid = json[ContentWebFrame.Identifier];
return new ContentWebFrame(uuid);
@ -1478,7 +1482,7 @@ class ChromeWebElement extends WebElement {
static fromJSON(json) {
if (!(ChromeWebElement.Identifier in json)) {
throw new InvalidArgumentError("Expected chrome element reference " +
throw new TypeError("Expected chrome element reference " +
pprint`for XUL/XBL element, got: ${json}`);
}
let uuid = json[ChromeWebElement.Identifier];

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

@ -12,7 +12,6 @@ const {
element,
WebElement,
} = Cu.import("chrome://marionette/content/element.js", {});
const {InvalidArgumentError} = Cu.import("chrome://marionette/content/error.js", {});
const SVGNS = "http://www.w3.org/2000/svg";
const XBLNS = "http://www.mozilla.org/xbl";
@ -246,7 +245,7 @@ add_test(function test_WebElement_from() {
ok(WebElement.from(domFrame) instanceof ContentWebFrame);
ok(WebElement.from(xulEl) instanceof ChromeWebElement);
Assert.throws(() => WebElement.from({}), InvalidArgumentError);
Assert.throws(() => WebElement.from({}), /Expected DOM window\/element/);
run_next_test();
});
@ -319,8 +318,8 @@ add_test(function test_WebElement_fromJSON_ChromeWebElement() {
});
add_test(function test_WebElement_fromJSON_malformed() {
Assert.throws(() => WebElement.fromJSON({}), InvalidArgumentError);
Assert.throws(() => WebElement.fromJSON(null), InvalidArgumentError);
Assert.throws(() => WebElement.fromJSON({}), /Expected web element reference/);
Assert.throws(() => WebElement.fromJSON(null), /Expected JSON Object/);
run_next_test();
});
@ -333,7 +332,7 @@ add_test(function test_WebElement_fromUUID() {
ok(domWebEl instanceof ContentWebElement);
equal(domWebEl.uuid, "bar");
Assert.throws(() => WebElement.fromUUID("baz", "bah"), InvalidArgumentError);
Assert.throws(() => WebElement.fromUUID("baz", "bah"), /Unknown context/);
run_next_test();
});
@ -390,7 +389,7 @@ add_test(function test_ContentWebElement_fromJSON() {
ok(bothEl instanceof ContentWebElement);
equal(bothEl.uuid, "identifier-uuid");
Assert.throws(() => ContentWebElement.fromJSON({}), InvalidArgumentError);
Assert.throws(() => ContentWebElement.fromJSON({}), /Expected web element reference/);
run_next_test();
});