2015-03-17 14:27:20 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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";
|
|
|
|
|
2016-01-29 12:57:46 +00:00
|
|
|
const {interfaces: Ci, utils: Cu} = Components;
|
2015-03-17 14:27:20 +00:00
|
|
|
|
2016-07-08 13:00:56 +00:00
|
|
|
const ERRORS = new Set([
|
2015-04-15 11:18:00 +00:00
|
|
|
"ElementNotAccessibleError",
|
2015-03-17 14:27:20 +00:00
|
|
|
"ElementNotVisibleError",
|
2016-11-06 18:00:18 +00:00
|
|
|
"InsecureCertificateError",
|
2015-04-17 17:43:05 +00:00
|
|
|
"InvalidArgumentError",
|
2015-03-31 17:00:32 +00:00
|
|
|
"InvalidElementStateError",
|
2015-04-15 11:18:00 +00:00
|
|
|
"InvalidSelectorError",
|
2015-04-15 12:38:01 +00:00
|
|
|
"InvalidSessionIdError",
|
2015-03-17 14:27:20 +00:00
|
|
|
"JavaScriptError",
|
|
|
|
"NoAlertOpenError",
|
|
|
|
"NoSuchElementError",
|
|
|
|
"NoSuchFrameError",
|
|
|
|
"NoSuchWindowError",
|
|
|
|
"ScriptTimeoutError",
|
|
|
|
"SessionNotCreatedError",
|
2015-04-15 11:18:00 +00:00
|
|
|
"StaleElementReferenceError",
|
2015-03-17 14:27:20 +00:00
|
|
|
"TimeoutError",
|
2015-04-20 12:53:51 +00:00
|
|
|
"UnableToSetCookieError",
|
2015-03-17 14:27:20 +00:00
|
|
|
"UnknownCommandError",
|
|
|
|
"UnknownError",
|
|
|
|
"UnsupportedOperationError",
|
|
|
|
"WebDriverError",
|
2016-07-08 13:00:56 +00:00
|
|
|
]);
|
2015-03-17 14:27:20 +00:00
|
|
|
|
2016-07-08 12:58:04 +00:00
|
|
|
const BUILTIN_ERRORS = new Set([
|
|
|
|
"Error",
|
|
|
|
"EvalError",
|
|
|
|
"InternalError",
|
|
|
|
"RangeError",
|
|
|
|
"ReferenceError",
|
|
|
|
"SyntaxError",
|
|
|
|
"TypeError",
|
|
|
|
"URIError",
|
|
|
|
]);
|
|
|
|
|
2016-07-08 13:00:56 +00:00
|
|
|
this.EXPORTED_SYMBOLS = ["error"].concat(Array.from(ERRORS));
|
2015-03-17 14:27:20 +00:00
|
|
|
|
|
|
|
this.error = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if obj is an instance of the Error prototype in a safe manner.
|
|
|
|
* Prefer using this over using instanceof since the Error prototype
|
2016-01-07 14:37:06 +00:00
|
|
|
* isn't unique across browsers, and XPCOM nsIException's are special
|
2015-03-17 14:27:20 +00:00
|
|
|
* snowflakes.
|
2015-04-15 11:18:00 +00:00
|
|
|
*
|
|
|
|
* @param {*} val
|
|
|
|
* Any value that should be undergo the test for errorness.
|
|
|
|
* @return {boolean}
|
|
|
|
* True if error, false otherwise.
|
2015-03-17 14:27:20 +00:00
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.isError = function (val) {
|
2015-04-15 11:18:00 +00:00
|
|
|
if (val === null || typeof val != "object") {
|
2015-03-17 14:27:20 +00:00
|
|
|
return false;
|
2016-01-07 14:37:06 +00:00
|
|
|
} else if (val instanceof Ci.nsIException) {
|
2015-03-17 14:27:20 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
2016-07-08 12:58:04 +00:00
|
|
|
// DOMRectList errors on string comparison
|
|
|
|
try {
|
|
|
|
let proto = Object.getPrototypeOf(val);
|
|
|
|
return BUILTIN_ERRORS.has(proto.toString());
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-03-17 14:27:20 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if obj is an object in the WebDriverError prototypal chain.
|
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.isWebDriverError = function (obj) {
|
2015-03-17 14:27:20 +00:00
|
|
|
return error.isError(obj) &&
|
2016-07-08 13:00:56 +00:00
|
|
|
("name" in obj && ERRORS.has(obj.name));
|
2016-02-03 18:43:37 +00:00
|
|
|
};
|
|
|
|
|
Bug 1123506 - Evaluate scripts in content with lasting side-effects; r=automatedtester
In order to achieve WebDriver parity, Marionette needs the ability to
evaluate scripts in content space with lasting side-effects. This means
that state modifications should affect behaviour and state of the browsing
context, and such transgress the boundaries of the sandbox.
This patch brings a new script evaluation module that is shared between
code in chrome- and content space. This brings the number of unique
script evaluation implementations in Marionette down from six to one.
evaluate.sandbox provides the main entry-point for execution. It is
compatible with existing Marionette uses of Execute Script and Execute
Async Script commands in Mozilla clients, but also provides a new stateful
sandbox for evaluation that should have lasting side-effects.
It is not expected that Mozilla clients, such as testing/marionette/client
and the Node.js client in Gaia, should have to change as a consequence
of this change.
A substantial change to the script's runtime environment is that many
globals that previously existed are now only exposed whenever needed.
This means for example that Simple Test harness functionality (waitFor,
ok, isnot, is, &c.) is only available when using a sandbox augmented
with a Simple Test harness adapter.
Conversely, this patch does not expose marionetteScriptFinished as a
callback to asynchronous scripts for sandboxes which sandboxName parameter
is undefined, because this is what determines if the script should be
evaluated under WebDriver conformance constraints. In all other cases
where sandboxName _is_ defined, the traditional marionetteScriptFinished
et al. runtime environment is preserved.
MozReview-Commit-ID: 8FZ6rNVImuC
2016-02-26 14:36:39 +00:00
|
|
|
/**
|
|
|
|
* Wraps an Error as a WebDriverError type. If the given error is already
|
|
|
|
* in the WebDriverError prototype chain, this function acts as a no-op.
|
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.wrap = function (err) {
|
Bug 1123506 - Evaluate scripts in content with lasting side-effects; r=automatedtester
In order to achieve WebDriver parity, Marionette needs the ability to
evaluate scripts in content space with lasting side-effects. This means
that state modifications should affect behaviour and state of the browsing
context, and such transgress the boundaries of the sandbox.
This patch brings a new script evaluation module that is shared between
code in chrome- and content space. This brings the number of unique
script evaluation implementations in Marionette down from six to one.
evaluate.sandbox provides the main entry-point for execution. It is
compatible with existing Marionette uses of Execute Script and Execute
Async Script commands in Mozilla clients, but also provides a new stateful
sandbox for evaluation that should have lasting side-effects.
It is not expected that Mozilla clients, such as testing/marionette/client
and the Node.js client in Gaia, should have to change as a consequence
of this change.
A substantial change to the script's runtime environment is that many
globals that previously existed are now only exposed whenever needed.
This means for example that Simple Test harness functionality (waitFor,
ok, isnot, is, &c.) is only available when using a sandbox augmented
with a Simple Test harness adapter.
Conversely, this patch does not expose marionetteScriptFinished as a
callback to asynchronous scripts for sandboxes which sandboxName parameter
is undefined, because this is what determines if the script should be
evaluated under WebDriver conformance constraints. In all other cases
where sandboxName _is_ defined, the traditional marionetteScriptFinished
et al. runtime environment is preserved.
MozReview-Commit-ID: 8FZ6rNVImuC
2016-02-26 14:36:39 +00:00
|
|
|
if (error.isWebDriverError(err)) {
|
|
|
|
return err;
|
|
|
|
}
|
2017-02-09 19:28:30 +00:00
|
|
|
return new WebDriverError(`${err.name}: ${err.message}`, err.stacktrace);
|
Bug 1123506 - Evaluate scripts in content with lasting side-effects; r=automatedtester
In order to achieve WebDriver parity, Marionette needs the ability to
evaluate scripts in content space with lasting side-effects. This means
that state modifications should affect behaviour and state of the browsing
context, and such transgress the boundaries of the sandbox.
This patch brings a new script evaluation module that is shared between
code in chrome- and content space. This brings the number of unique
script evaluation implementations in Marionette down from six to one.
evaluate.sandbox provides the main entry-point for execution. It is
compatible with existing Marionette uses of Execute Script and Execute
Async Script commands in Mozilla clients, but also provides a new stateful
sandbox for evaluation that should have lasting side-effects.
It is not expected that Mozilla clients, such as testing/marionette/client
and the Node.js client in Gaia, should have to change as a consequence
of this change.
A substantial change to the script's runtime environment is that many
globals that previously existed are now only exposed whenever needed.
This means for example that Simple Test harness functionality (waitFor,
ok, isnot, is, &c.) is only available when using a sandbox augmented
with a Simple Test harness adapter.
Conversely, this patch does not expose marionetteScriptFinished as a
callback to asynchronous scripts for sandboxes which sandboxName parameter
is undefined, because this is what determines if the script should be
evaluated under WebDriver conformance constraints. In all other cases
where sandboxName _is_ defined, the traditional marionetteScriptFinished
et al. runtime environment is preserved.
MozReview-Commit-ID: 8FZ6rNVImuC
2016-02-26 14:36:39 +00:00
|
|
|
};
|
|
|
|
|
2015-03-17 14:27:20 +00:00
|
|
|
/**
|
|
|
|
* Unhandled error reporter. Dumps the error and its stacktrace to console,
|
|
|
|
* and reports error to the Browser Console.
|
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.report = function (err) {
|
2015-03-17 14:27:20 +00:00
|
|
|
let msg = `Marionette threw an error: ${error.stringify(err)}`;
|
|
|
|
dump(msg + "\n");
|
|
|
|
if (Cu.reportError) {
|
|
|
|
Cu.reportError(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prettifies an instance of Error and its stacktrace to a string.
|
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.stringify = function (err) {
|
2015-03-17 14:27:20 +00:00
|
|
|
try {
|
|
|
|
let s = err.toString();
|
|
|
|
if ("stack" in err) {
|
|
|
|
s += "\n" + err.stack;
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
} catch (e) {
|
|
|
|
return "<unprintable error>";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-31 22:00:21 +00:00
|
|
|
/**
|
|
|
|
* Pretty-print values passed to template strings.
|
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
*
|
|
|
|
* let input = {value: true};
|
|
|
|
* error.pprint`Expected boolean, got ${input}`;
|
|
|
|
* => "Expected boolean, got [object Object] {"value": true}"
|
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.pprint = function (strings, ...values) {
|
2016-10-31 22:00:21 +00:00
|
|
|
let res = [];
|
|
|
|
for (let i = 0; i < strings.length; i++) {
|
|
|
|
res.push(strings[i]);
|
|
|
|
if (i < values.length) {
|
|
|
|
let val = values[i];
|
|
|
|
res.push(Object.prototype.toString.call(val));
|
|
|
|
let s = JSON.stringify(val);
|
|
|
|
if (s && s.length > 0) {
|
|
|
|
res.push(" ");
|
|
|
|
res.push(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res.join("");
|
|
|
|
};
|
|
|
|
|
2015-09-26 16:12:01 +00:00
|
|
|
/**
|
2016-01-29 12:57:46 +00:00
|
|
|
* Marshal a WebDriverError prototype to a JSON dictionary.
|
2015-09-26 16:12:01 +00:00
|
|
|
*
|
2016-01-29 12:57:46 +00:00
|
|
|
* @param {WebDriverError} err
|
|
|
|
* Error to serialise.
|
2015-09-26 16:12:01 +00:00
|
|
|
*
|
|
|
|
* @return {Object.<string, Object>}
|
2016-01-29 12:57:46 +00:00
|
|
|
* JSON dictionary with the keys "error", "message", and "stacktrace".
|
|
|
|
* @throws {TypeError}
|
|
|
|
* If error type is not serialisable.
|
2015-09-26 16:12:01 +00:00
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.toJson = function (err) {
|
2016-01-29 12:57:46 +00:00
|
|
|
if (!error.isWebDriverError(err)) {
|
|
|
|
throw new TypeError(`Unserialisable error type: ${err}`);
|
|
|
|
}
|
|
|
|
|
2015-09-26 16:12:01 +00:00
|
|
|
let json = {
|
|
|
|
error: err.status,
|
2016-05-23 16:46:04 +00:00
|
|
|
message: err.message || "",
|
|
|
|
stacktrace: err.stack || "",
|
2015-09-26 16:12:01 +00:00
|
|
|
};
|
|
|
|
return json;
|
|
|
|
};
|
|
|
|
|
2016-01-29 12:57:46 +00:00
|
|
|
/**
|
|
|
|
* Unmarshal a JSON dictionary to a WebDriverError prototype.
|
|
|
|
*
|
|
|
|
* @param {Object.<string, string>} json
|
|
|
|
* JSON dictionary with the keys "error", "message", and "stacktrace".
|
|
|
|
*
|
|
|
|
* @return {WebDriverError}
|
|
|
|
* Deserialised error prototype.
|
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
error.fromJson = function (json) {
|
2016-01-29 12:57:46 +00:00
|
|
|
if (!statusLookup.has(json.error)) {
|
|
|
|
throw new TypeError(`Undeserialisable error type: ${json.error}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
let errCls = statusLookup.get(json.error);
|
|
|
|
let err = new errCls(json.message);
|
|
|
|
if ("stacktrace" in json) {
|
|
|
|
err.stack = json.stacktrace;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
};
|
|
|
|
|
2015-03-17 14:27:20 +00:00
|
|
|
/**
|
|
|
|
* WebDriverError is the prototypal parent of all WebDriver errors.
|
|
|
|
* It should not be used directly, as it does not correspond to a real
|
|
|
|
* error in the specification.
|
2016-12-30 11:26:30 +00:00
|
|
|
*
|
|
|
|
* @param {(string|Error)=} err
|
|
|
|
* Optional string describing error situation or Error instance
|
|
|
|
* to propagate.
|
2015-03-17 14:27:20 +00:00
|
|
|
*/
|
2016-12-30 11:26:30 +00:00
|
|
|
this.WebDriverError = function (err) {
|
2016-12-30 13:07:54 +00:00
|
|
|
const proto = Error.call(this, err);
|
2015-03-17 14:27:20 +00:00
|
|
|
this.name = "WebDriverError";
|
2015-04-02 19:07:20 +00:00
|
|
|
this.status = "webdriver error";
|
2016-12-30 11:26:30 +00:00
|
|
|
|
|
|
|
if (error.isError(err)) {
|
|
|
|
this.message = err.message;
|
|
|
|
this.stack = err.stack;
|
|
|
|
} else {
|
|
|
|
this.message = err;
|
2016-12-30 13:07:54 +00:00
|
|
|
this.stack = proto.stack;
|
2016-12-30 11:26:30 +00:00
|
|
|
}
|
2015-03-17 14:27:20 +00:00
|
|
|
};
|
|
|
|
WebDriverError.prototype = Object.create(Error.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.ElementNotAccessibleError = function (msg) {
|
2015-04-15 11:18:00 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "ElementNotAccessibleError";
|
|
|
|
this.status = "element not accessible";
|
|
|
|
};
|
|
|
|
ElementNotAccessibleError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.ElementNotVisibleError = function (msg) {
|
2015-03-17 14:27:20 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "ElementNotVisibleError";
|
|
|
|
this.status = "element not visible";
|
|
|
|
};
|
|
|
|
ElementNotVisibleError.prototype = Object.create(WebDriverError.prototype);
|
2015-03-31 17:00:32 +00:00
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.InsecureCertificateError = function (msg) {
|
2016-11-06 18:00:18 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "InsecureCertificateError";
|
|
|
|
this.status = "insecure certificate";
|
|
|
|
};
|
|
|
|
InsecureCertificateError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.InvalidArgumentError = function (msg) {
|
2015-04-02 14:16:00 +00:00
|
|
|
WebDriverError.call(this, msg);
|
2015-04-17 17:43:05 +00:00
|
|
|
this.name = "InvalidArgumentError";
|
|
|
|
this.status = "invalid argument";
|
2015-04-02 14:16:00 +00:00
|
|
|
};
|
2015-04-17 17:43:05 +00:00
|
|
|
InvalidArgumentError.prototype = Object.create(WebDriverError.prototype);
|
2015-04-02 14:16:00 +00:00
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.InvalidElementStateError = function (msg) {
|
2015-03-17 14:27:20 +00:00
|
|
|
WebDriverError.call(this, msg);
|
2015-03-31 17:00:32 +00:00
|
|
|
this.name = "InvalidElementStateError";
|
|
|
|
this.status = "invalid element state";
|
2015-03-17 14:27:20 +00:00
|
|
|
};
|
2015-03-31 17:00:32 +00:00
|
|
|
InvalidElementStateError.prototype = Object.create(WebDriverError.prototype);
|
2015-03-17 14:27:20 +00:00
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.InvalidSelectorError = function (msg) {
|
2015-04-15 11:18:00 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "InvalidSelectorError";
|
|
|
|
this.status = "invalid selector";
|
|
|
|
};
|
|
|
|
InvalidSelectorError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.InvalidSessionIdError = function (msg) {
|
2015-04-15 12:38:01 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "InvalidSessionIdError";
|
|
|
|
this.status = "invalid session id";
|
|
|
|
};
|
|
|
|
InvalidSessionIdError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2015-03-17 14:27:20 +00:00
|
|
|
/**
|
|
|
|
* Creates an error message for a JavaScript error thrown during
|
|
|
|
* executeScript or executeAsyncScript.
|
|
|
|
*
|
|
|
|
* @param {Error} err
|
|
|
|
* An Error object passed to a catch block or a message.
|
2016-01-18 18:55:52 +00:00
|
|
|
* @param {string=} fnName
|
2015-03-17 14:27:20 +00:00
|
|
|
* The name of the function to use in the stack trace message
|
|
|
|
* (e.g. execute_script).
|
2016-01-18 18:55:52 +00:00
|
|
|
* @param {string=} file
|
2015-03-17 14:27:20 +00:00
|
|
|
* The filename of the test file containing the Marionette
|
|
|
|
* command that caused this error to occur.
|
2016-01-18 18:55:52 +00:00
|
|
|
* @param {number=} line
|
2015-03-17 14:27:20 +00:00
|
|
|
* The line number of the above test file.
|
|
|
|
* @param {string=} script
|
|
|
|
* The JS script being executed in text form.
|
|
|
|
*/
|
2016-12-04 11:42:52 +00:00
|
|
|
this.JavaScriptError = function (
|
2016-01-18 18:55:52 +00:00
|
|
|
err, fnName = null, file = null, line = null, script = null) {
|
2015-03-17 14:27:20 +00:00
|
|
|
let msg = String(err);
|
|
|
|
let trace = "";
|
|
|
|
|
2016-01-18 18:55:52 +00:00
|
|
|
if (fnName) {
|
|
|
|
trace += fnName;
|
|
|
|
if (file) {
|
|
|
|
trace += ` @${file}`;
|
|
|
|
if (line) {
|
|
|
|
trace += `, line ${line}`;
|
|
|
|
}
|
2015-03-17 14:27:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof err == "object" && "name" in err && "stack" in err) {
|
|
|
|
let jsStack = err.stack.split("\n");
|
|
|
|
let match = jsStack[0].match(/:(\d+):\d+$/);
|
|
|
|
let jsLine = match ? parseInt(match[1]) : 0;
|
|
|
|
if (script) {
|
|
|
|
let src = script.split("\n")[jsLine];
|
|
|
|
trace += "\n" +
|
|
|
|
"inline javascript, line " + jsLine + "\n" +
|
|
|
|
"src: \"" + src + "\"";
|
|
|
|
}
|
2015-09-29 10:02:48 +00:00
|
|
|
trace += "\nStack:\n" + String(err.stack);
|
2015-03-17 14:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "JavaScriptError";
|
|
|
|
this.status = "javascript error";
|
|
|
|
this.stack = trace;
|
|
|
|
};
|
|
|
|
JavaScriptError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.NoAlertOpenError = function (msg) {
|
2015-03-17 14:27:20 +00:00
|
|
|
WebDriverError.call(this, msg);
|
2015-03-31 17:00:32 +00:00
|
|
|
this.name = "NoAlertOpenError";
|
|
|
|
this.status = "no such alert";
|
2015-09-26 16:12:01 +00:00
|
|
|
};
|
2015-03-31 17:00:32 +00:00
|
|
|
NoAlertOpenError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.NoSuchElementError = function (msg) {
|
2015-03-31 17:00:32 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "NoSuchElementError";
|
|
|
|
this.status = "no such element";
|
2015-03-17 14:27:20 +00:00
|
|
|
};
|
2015-03-31 17:00:32 +00:00
|
|
|
NoSuchElementError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.NoSuchFrameError = function (msg) {
|
2015-03-31 17:00:32 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "NoSuchFrameError";
|
|
|
|
this.status = "no such frame";
|
|
|
|
};
|
|
|
|
NoSuchFrameError.prototype = Object.create(WebDriverError.prototype);
|
2015-03-17 14:27:20 +00:00
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.NoSuchWindowError = function (msg) {
|
2015-03-17 14:27:20 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "NoSuchWindowError";
|
|
|
|
this.status = "no such window";
|
|
|
|
};
|
|
|
|
NoSuchWindowError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.ScriptTimeoutError = function (msg) {
|
2015-03-17 14:27:20 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "ScriptTimeoutError";
|
|
|
|
this.status = "script timeout";
|
|
|
|
};
|
|
|
|
ScriptTimeoutError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.SessionNotCreatedError = function (msg) {
|
2015-03-17 14:27:20 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "SessionNotCreatedError";
|
|
|
|
this.status = "session not created";
|
2015-04-15 11:18:00 +00:00
|
|
|
};
|
2015-03-17 14:27:20 +00:00
|
|
|
SessionNotCreatedError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.StaleElementReferenceError = function (msg) {
|
2015-04-15 11:18:00 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "StaleElementReferenceError";
|
|
|
|
this.status = "stale element reference";
|
|
|
|
};
|
|
|
|
StaleElementReferenceError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.TimeoutError = function (msg) {
|
2015-03-31 17:00:32 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "TimeoutError";
|
|
|
|
this.status = "timeout";
|
2015-03-17 14:27:20 +00:00
|
|
|
};
|
2015-03-31 17:00:32 +00:00
|
|
|
TimeoutError.prototype = Object.create(WebDriverError.prototype);
|
2015-03-17 14:27:20 +00:00
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.UnableToSetCookieError = function (msg) {
|
2015-04-20 12:53:51 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "UnableToSetCookieError";
|
|
|
|
this.status = "unable to set cookie";
|
|
|
|
};
|
|
|
|
UnableToSetCookieError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.UnknownCommandError = function (msg) {
|
2015-03-31 17:00:32 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "UnknownCommandError";
|
|
|
|
this.status = "unknown command";
|
2015-03-17 14:27:20 +00:00
|
|
|
};
|
2015-03-31 17:00:32 +00:00
|
|
|
UnknownCommandError.prototype = Object.create(WebDriverError.prototype);
|
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.UnknownError = function (msg) {
|
2015-03-31 17:00:32 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "UnknownError";
|
|
|
|
this.status = "unknown error";
|
|
|
|
};
|
|
|
|
UnknownError.prototype = Object.create(WebDriverError.prototype);
|
2015-03-17 14:27:20 +00:00
|
|
|
|
2016-12-04 11:42:52 +00:00
|
|
|
this.UnsupportedOperationError = function (msg) {
|
2015-03-17 14:27:20 +00:00
|
|
|
WebDriverError.call(this, msg);
|
|
|
|
this.name = "UnsupportedOperationError";
|
|
|
|
this.status = "unsupported operation";
|
|
|
|
};
|
|
|
|
UnsupportedOperationError.prototype = Object.create(WebDriverError.prototype);
|
2016-01-29 12:57:46 +00:00
|
|
|
|
|
|
|
const nameLookup = new Map();
|
|
|
|
const statusLookup = new Map();
|
2016-02-03 18:41:37 +00:00
|
|
|
for (let s of ERRORS) {
|
2016-01-29 12:57:46 +00:00
|
|
|
let cls = this[s];
|
|
|
|
let inst = new cls();
|
|
|
|
nameLookup.set(inst.name, cls);
|
|
|
|
statusLookup.set(inst.status, cls);
|
|
|
|
};
|