Commit 6dd578e2 authored by Luke Zielinski's avatar Luke Zielinski Committed by Chromium LUCI CQ

Roll WPT tooling.

This rolls up to 79d2debce531d115566192dccf70f5d8fb9ced53.
Only one change is pulled in to support Shadow Root in webdriver.

Cq-Include-Trybots: luci.chromium.try:linux-wpt-identity-fyi-rel,linux-wpt-input-fyi-rel
Change-Id: Iccc7e81c85b3f387e1cca1e2dfd588ec230c61a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2636692
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Auto-Submit: Luke Z <lpz@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845160}
parent 8053977b
......@@ -22,7 +22,7 @@ Local Modifications: None
Name: web-platform-tests - Test Suites for Web Platform specifications
Short Name: wpt
URL: https://github.com/web-platform-tests/wpt/
Version: f333959abe07e6c4cfb388f4f7a03a0a109b38a5
Version: 79d2debce531d115566192dccf70f5d8fb9ced53
License: LICENSES FOR W3C TEST SUITES (https://www.w3.org/Consortium/Legal/2008/03-bsd-license.html)
License File: wpt/wpt/LICENSE.md
Security Critical: no
......
......@@ -9,7 +9,7 @@ cd $DIR
TARGET_DIR=$DIR/wpt
REMOTE_REPO="https://github.com/web-platform-tests/wpt.git"
WPT_HEAD=f333959abe07e6c4cfb388f4f7a03a0a109b38a5
WPT_HEAD=79d2debce531d115566192dccf70f5d8fb9ced53
function clone {
# Remove existing repo if already exists.
......
......@@ -6,6 +6,7 @@ from .client import (
Find,
Frame,
Session,
ShadowRoot,
Timeouts,
Window)
from .error import (
......
......@@ -372,6 +372,42 @@ class Frame(object):
return cls(uuid, session)
class ShadowRoot(object):
identifier = "shadow-075b-4da1-b6ba-e579c2d3230a"
def __init__(self, session, id):
"""
Construct a new shadow root representation.
:param id: Shadow root UUID which must be unique across
all browsing contexts.
:param session: Current ``webdriver.Session``.
"""
self.id = id
self.session = session
@classmethod
def from_json(cls, json, session):
uuid = json[ShadowRoot.identifier]
return cls(uuid, session)
def send_shadow_command(self, method, uri, body=None):
url = "shadow/{}/{}".format(self.id, uri)
return self.session.send_session_command(method, url, body)
@command
def find_element(self, strategy, selector):
body = {"using": strategy,
"value": selector}
return self.send_shadow_command("POST", "element", body)
@command
def find_elements(self, strategy, selector):
body = {"using": strategy,
"value": selector}
return self.send_shadow_command("POST", "elements", body)
class Find(object):
def __init__(self, session):
self.session = session
......@@ -804,6 +840,11 @@ class Element(object):
def screenshot(self):
return self.send_element_command("GET", "screenshot")
@property
@command
def shadow_root(self):
return self.send_element_command("GET", "shadow")
@command
def attribute(self, name):
return self.send_element_command("GET", "attribute/%s" % name)
......
......@@ -34,6 +34,11 @@ class WebDriverException(Exception):
return message
class DetachedShadowRootException(WebDriverException):
http_status = 404
status_code = "detached shadow root"
class ElementClickInterceptedException(WebDriverException):
http_status = 400
status_code = "element click intercepted"
......@@ -114,6 +119,11 @@ class NoSuchFrameException(WebDriverException):
status_code = "no such frame"
class NoSuchShadowRootException(WebDriverException):
http_status = 404
status_code = "no such shadow root"
class NoSuchWindowException(WebDriverException):
http_status = 404
status_code = "no such window"
......
......@@ -22,6 +22,8 @@ class Encoder(json.JSONEncoder):
return {webdriver.Frame.identifier: obj.id}
elif isinstance(obj, webdriver.Window):
return {webdriver.Frame.identifier: obj.id}
elif isinstance(obj, webdriver.ShadowRoot):
return {webdriver.ShadowRoot.identifier: obj.id}
return super(Encoder, self).default(obj)
......@@ -40,6 +42,8 @@ class Decoder(json.JSONDecoder):
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) and webdriver.ShadowRoot.identifier in payload:
return webdriver.ShadowRoot.from_json(payload, self.session)
elif isinstance(payload, dict):
return {k: self.object_hook(v) for k, v in iteritems(payload)}
return payload
......@@ -75,7 +75,10 @@ def start_server(address=None, authkey=None, mp_context=None):
manager = ServerDictManager(address, authkey, **kwargs)
manager.start()
return (manager, manager._address, manager._authkey)
address = manager._address
if isinstance(address, bytes):
address = address.decode("ascii")
return (manager, address, manager._authkey)
class LockWrapper(object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment