Bug 1154691: Align Marionette with WebDriver errors

Adds `invalid selector' and `invalid session id' errors to the server,
and aligns the exceptions in the Python client with those in the server.

Some of the exceptions are not in use yet and consequently do not carry
a `code` property.  This is fine because it makes us future-proof when
the server starts using them.

r=dburns

--HG--
extra : source : cc8eb386f147893aaf867797eb9f3c6d8fd0925a
This commit is contained in:
Andreas Tolfsen 2015-04-15 13:38:01 +01:00
Родитель ddcb607014
Коммит 86e4115d5b
4 изменённых файлов: 66 добавлений и 51 удалений

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

@ -11,11 +11,11 @@ import time
import types
import weakref
from b2ginstance import B2GInstance
from marionette_driver.errors import InvalidResponseException
from marionette_driver.marionette import Marionette
from marionette_test import MarionetteTestCase
from marionette_transport import MarionetteTransport
from b2ginstance import B2GInstance
from runtests import MarionetteTestRunner, cli
class B2GUpdateMarionetteClient(MarionetteTransport):
@ -237,16 +237,10 @@ class B2GUpdateTestCase(MarionetteTestCase):
self.print_status(status, os.path.basename(path))
try:
results = self.marionette.execute_async_script(data,
script_args=[self.testvars],
special_powers=True)
self.handle_results(path, stage, results)
except InvalidResponseException, e:
# If the update test causes a restart, we will get an invalid
# response from the socket here.
if not will_restart:
raise e
results = self.marionette.execute_async_script(data,
script_args=[self.testvars],
special_powers=True)
self.handle_results(path, stage, results)
def handle_results(self, path, stage, results):
passed = results['passed']

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

@ -16,8 +16,8 @@ import warnings
from marionette_driver.errors import (
MarionetteException, InstallGeckoError, TimeoutException, InvalidResponseException,
JavascriptException, NoSuchElementException, XPathLookupException, NoSuchWindowException,
MarionetteException, TimeoutException,
JavascriptException, NoSuchElementException, NoSuchWindowException,
StaleElementException, ScriptTimeoutException, ElementNotVisibleException,
NoSuchFrameException, InvalidElementStateException, NoAlertPresentException,
InvalidCookieDomainException, UnableToSetCookieException, InvalidSelectorException,

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

@ -49,8 +49,16 @@ class MarionetteException(Exception):
return "".join(traceback.format_exception(self.__class__, msg, tb))
class InstallGeckoError(MarionetteException):
pass
class ElementNotSelectableException(MarionetteException):
status = "element not selectable"
class InvalidArgumentException(MarionetteException):
status = "invalid argument"
class InvalidSessionIdException(MarionetteException):
status = "invalid session id"
class TimeoutException(MarionetteException):
@ -58,11 +66,6 @@ class TimeoutException(MarionetteException):
status = "timeout"
class InvalidResponseException(MarionetteException):
code = (53,)
status = "invalid response"
class JavascriptException(MarionetteException):
code = (17,)
status = "javascript error"
@ -73,11 +76,6 @@ class NoSuchElementException(MarionetteException):
status = "no such element"
class XPathLookupException(MarionetteException):
code = (19,)
status = "invalid xpath selector"
class NoSuchWindowException(MarionetteException):
code = (23,)
status = "no such window"
@ -159,11 +157,6 @@ class FrameSendFailureError(MarionetteException):
status = "frame send failure"
class UnsupportedOperationException(MarionetteException):
code = (405,)
status = "unsupported operation"
class SessionNotCreatedException(MarionetteException):
code = (33, 71)
status = "session not created"
@ -173,31 +166,50 @@ class UnexpectedAlertOpen(MarionetteException):
code = (26,)
status = "unexpected alert open"
class UnknownCommandException(MarionetteException):
code = (9,)
status = "unknown command"
class UnknownException(MarionetteException):
code = (13,)
status = "unknown error"
class UnsupportedOperationException(MarionetteException):
code = (405,)
status = "unsupported operation"
excs = [
MarionetteException,
TimeoutException,
InvalidResponseException,
JavascriptException,
NoSuchElementException,
XPathLookupException,
NoSuchWindowException,
StaleElementException,
ScriptTimeoutException,
ElementNotVisibleException,
ElementNotAccessibleException,
NoSuchFrameException,
InvalidElementStateException,
NoAlertPresentException,
InvalidCookieDomainException,
UnableToSetCookieException,
InvalidElementCoordinates,
InvalidSelectorException,
MoveTargetOutOfBoundsException,
FrameSendNotInitializedError,
ElementNotSelectableException,
ElementNotVisibleException,
FrameSendFailureError,
UnsupportedOperationException,
FrameSendNotInitializedError,
InvalidArgumentException,
InvalidCookieDomainException,
InvalidElementCoordinates,
InvalidElementStateException,
InvalidSelectorException,
InvalidSessionIdException,
JavascriptException,
MarionetteException,
MoveTargetOutOfBoundsException,
NoAlertPresentException,
NoSuchElementException,
NoSuchFrameException,
NoSuchWindowException,
ScriptTimeoutException,
SessionNotCreatedException,
StaleElementException,
TimeoutException,
UnableToSetCookieException,
UnexpectedAlertOpen,
UnknownCommandException,
UnknownException,
UnsupportedOperationException,
]

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

@ -14,6 +14,7 @@ const errors = [
"IllegalArgumentError",
"InvalidElementStateError",
"InvalidSelectorError",
"InvalidSessionIdError",
"JavaScriptError",
"NoAlertOpenError",
"NoSuchElementError",
@ -211,6 +212,14 @@ this.InvalidSelectorError = function(msg) {
};
InvalidSelectorError.prototype = Object.create(WebDriverError.prototype);
this.InvalidSessionIdError = function(msg) {
WebDriverError.call(this, msg);
this.name = "InvalidSessionIdError";
this.status = "invalid session id";
this.code = 13;
};
InvalidSessionIdError.prototype = Object.create(WebDriverError.prototype);
/**
* Creates an error message for a JavaScript error thrown during
* executeScript or executeAsyncScript.