mirror of
https://github.com/servo/servo.git
synced 2025-08-25 23:28:21 +01:00
Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d
This commit is contained in:
parent
c45192614c
commit
775b784f79
2144 changed files with 58115 additions and 29658 deletions
|
@ -1,5 +1,13 @@
|
|||
# flake8: noqa (not ideal, but nicer than adding noqa: F401 to every line!)
|
||||
from client import Cookies, Element, Find, Session, Timeouts, Window
|
||||
# flake8: noqa
|
||||
|
||||
from client import (
|
||||
Cookies,
|
||||
Element,
|
||||
Find,
|
||||
Frame,
|
||||
Session,
|
||||
Timeouts,
|
||||
Window)
|
||||
from error import (
|
||||
ElementNotSelectableException,
|
||||
ElementNotVisibleException,
|
||||
|
|
|
@ -16,7 +16,6 @@ def command(func):
|
|||
|
||||
if session.session_id is None:
|
||||
session.start()
|
||||
assert session.session_id is not None
|
||||
|
||||
return func(self, *args, **kwargs)
|
||||
|
||||
|
@ -234,6 +233,8 @@ class Actions(object):
|
|||
|
||||
|
||||
class Window(object):
|
||||
identifier = "window-fcc6-11e5-b4f8-330a88ab9d7f"
|
||||
|
||||
def __init__(self, session):
|
||||
self.session = session
|
||||
|
||||
|
@ -284,6 +285,23 @@ class Window(object):
|
|||
def fullscreen(self):
|
||||
return self.session.send_session_command("POST", "window/fullscreen")
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json, session):
|
||||
uuid = json[Window.identifier]
|
||||
return cls(uuid, session)
|
||||
|
||||
|
||||
class Frame(object):
|
||||
identifier = "frame-075b-4da1-b6ba-e579c2d3230a"
|
||||
|
||||
def __init__(self, session):
|
||||
self.session = session
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json, session):
|
||||
uuid = json[Frame.identifier]
|
||||
return cls(uuid, session)
|
||||
|
||||
|
||||
class Find(object):
|
||||
def __init__(self, session):
|
||||
|
@ -352,7 +370,8 @@ class Session(object):
|
|||
extension=None):
|
||||
self.transport = transport.HTTPWireProtocol(
|
||||
host, port, url_prefix, timeout=timeout)
|
||||
self.capabilities = capabilities
|
||||
self.requested_capabilities = capabilities
|
||||
self.capabilities = None
|
||||
self.session_id = None
|
||||
self.timeouts = None
|
||||
self.window = None
|
||||
|
@ -390,8 +409,8 @@ class Session(object):
|
|||
|
||||
body = {}
|
||||
|
||||
if self.capabilities is not None:
|
||||
body["capabilities"] = self.capabilities
|
||||
if self.requested_capabilities is not None:
|
||||
body["capabilities"] = self.requested_capabilities
|
||||
|
||||
value = self.send_command("POST", "session", body=body)
|
||||
self.session_id = value["sessionId"]
|
||||
|
@ -435,7 +454,13 @@ class Session(object):
|
|||
session=self)
|
||||
|
||||
if response.status != 200:
|
||||
raise error.from_response(response)
|
||||
err = error.from_response(response)
|
||||
|
||||
if isinstance(err, error.SessionNotCreatedException):
|
||||
# The driver could have already been deleted the session.
|
||||
self.session_id = None
|
||||
|
||||
raise err
|
||||
|
||||
if "value" in response.body:
|
||||
value = response.body["value"]
|
||||
|
@ -639,7 +664,8 @@ class Element(object):
|
|||
self.id = id
|
||||
self.session = session
|
||||
|
||||
assert id not in self.session._element_cache
|
||||
if id in self.session._element_cache:
|
||||
raise ValueError("Element already in cache: %s" % id)
|
||||
self.session._element_cache[self.id] = self
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -651,7 +677,6 @@ class Element(object):
|
|||
|
||||
@classmethod
|
||||
def from_json(cls, json, session):
|
||||
assert Element.identifier in json
|
||||
uuid = json[Element.identifier]
|
||||
if uuid in session._element_cache:
|
||||
return session._element_cache[uuid]
|
||||
|
@ -677,7 +702,7 @@ class Element(object):
|
|||
|
||||
@command
|
||||
def clear(self):
|
||||
self.send_element_command("POST", self.url("clear"), {})
|
||||
self.send_element_command("POST", "clear", {})
|
||||
|
||||
@command
|
||||
def send_keys(self, text):
|
||||
|
|
|
@ -6,7 +6,7 @@ class WebDriverException(Exception):
|
|||
http_status = None
|
||||
status_code = None
|
||||
|
||||
def __init__(self, message, stacktrace=None):
|
||||
def __init__(self, message=None, stacktrace=None):
|
||||
super(WebDriverException, self)
|
||||
self.message = message
|
||||
self.stacktrace = stacktrace
|
||||
|
@ -15,12 +15,15 @@ class WebDriverException(Exception):
|
|||
return "<%s http_status=%s>" % (self.__class__.__name__, self.http_status)
|
||||
|
||||
def __str__(self):
|
||||
message = "%s (%s): %s\n" % (self.status_code, self.http_status, self.message)
|
||||
message = "%s (%s)" % (self.status_code, self.http_status)
|
||||
|
||||
if self.message is not None:
|
||||
message += ": %s" % self.message
|
||||
message += "\n"
|
||||
|
||||
if self.stacktrace:
|
||||
message += ("\n"
|
||||
"Remote-end stacktrace:\n"
|
||||
"\n"
|
||||
"%s" % self.stacktrace)
|
||||
message += ("\nRemote-end stacktrace:\n\n%s" % self.stacktrace)
|
||||
|
||||
return message
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@ class Encoder(json.JSONEncoder):
|
|||
return [self.default(x) for x in obj]
|
||||
elif isinstance(obj, webdriver.Element):
|
||||
return {webdriver.Element.identifier: obj.id}
|
||||
elif isinstance(obj, webdriver.Frame):
|
||||
return {webdriver.Frame.identifier: obj.id}
|
||||
elif isinstance(obj, webdriver.Window):
|
||||
return {webdriver.Frame.identifier: obj.id}
|
||||
return super(Encoder, self).default(obj)
|
||||
|
||||
|
||||
|
@ -30,6 +34,10 @@ class Decoder(json.JSONDecoder):
|
|||
return [self.object_hook(x) for x in payload]
|
||||
elif isinstance(payload, dict) and webdriver.Element.identifier in payload:
|
||||
return webdriver.Element.from_json(payload, self.session)
|
||||
elif isinstance(payload, dict) and webdriver.Frame.identifier in payload:
|
||||
return webdriver.Frame.from_json(payload, self.session)
|
||||
elif isinstance(payload, dict) and webdriver.Window.identifier in payload:
|
||||
return webdriver.Window.from_json(payload, self.session)
|
||||
elif isinstance(payload, dict):
|
||||
return {k: self.object_hook(v) for k, v in payload.iteritems()}
|
||||
return payload
|
||||
|
|
|
@ -50,8 +50,9 @@ class HTTPWireProtocol(object):
|
|||
Transports messages (commands and responses) over the WebDriver
|
||||
wire protocol.
|
||||
|
||||
Complex objects, such as ``webdriver.Element``, are by default
|
||||
not marshaled to enable use of `session.transport.send` in WPT tests::
|
||||
Complex objects, such as ``webdriver.Element``, ``webdriver.Frame``,
|
||||
and ``webdriver.Window`` are by default not marshaled to enable
|
||||
use of `session.transport.send` in WPT tests::
|
||||
|
||||
session = webdriver.Session("127.0.0.1", 4444)
|
||||
response = transport.send("GET", "element/active", None)
|
||||
|
@ -100,8 +101,9 @@ class HTTPWireProtocol(object):
|
|||
|
||||
The request `body` must be JSON serialisable unless a
|
||||
custom `encoder` has been provided. This means complex
|
||||
objects such as ``webdriver.Element`` are not automatically
|
||||
made into JSON. This behaviour is, however, provided by
|
||||
objects such as ``webdriver.Element``, ``webdriver.Frame``,
|
||||
and `webdriver.Window`` are not automatically made
|
||||
into JSON. This behaviour is, however, provided by
|
||||
``webdriver.protocol.Encoder``, should you want it.
|
||||
|
||||
Similarly, the response body is returned au natural
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue