Bug 1477565 [wpt PR 12129] - Fix Python errors in servodriver, a=testonly

Automatic update from web-platform-testsMerge pull request #12129 from web-platform-tests/sync_c9c60ae131b00a17324a5eb3d76279d9a4f8cdc4

Merge pull request #12129 from sync_c9c60ae131b00a17324a5eb3d76279d9a4f8cdc4
--

wpt-commits: 735b5b3cc5bb73f488365339bcadd856d8c42367
wpt-pr: 12129
This commit is contained in:
Servo WPT Sync 2018-07-25 18:39:31 +00:00 committed by James Graham
parent a3bb00c12c
commit 0797284f89
2 changed files with 27 additions and 5 deletions

View File

@ -38,6 +38,7 @@ def browser_kwargs(test_type, run_info_data, **kwargs):
return {
"binary": kwargs["binary"],
"debug_info": kwargs["debug_info"],
"server_config": kwargs["config"],
"user_stylesheets": kwargs.get("user_stylesheets"),
}
@ -73,14 +74,14 @@ class ServoWebDriverBrowser(Browser):
used_ports = set()
def __init__(self, logger, binary, debug_info=None, webdriver_host="127.0.0.1",
user_stylesheets=None):
server_config=None, user_stylesheets=None):
Browser.__init__(self, logger)
self.binary = binary
self.webdriver_host = webdriver_host
self.webdriver_port = None
self.proc = None
self.debug_info = debug_info
self.hosts_path = write_hosts_file()
self.hosts_path = write_hosts_file(server_config)
self.command = None
self.user_stylesheets = user_stylesheets if user_stylesheets else []
@ -151,7 +152,7 @@ class ServoWebDriverBrowser(Browser):
def cleanup(self):
self.stop()
shutil.rmtree(os.path.dirname(self.hosts_file))
os.remove(self.hosts_path)
def executor_browser(self):
assert self.webdriver_port is not None

View File

@ -11,8 +11,10 @@ from .base import (Protocol,
TestharnessExecutor,
strip_server)
from ..testrunner import Stop
from ..webdriver_server import wait_for_service
webdriver = None
ServoCommandExtensions = None
here = os.path.join(os.path.split(__file__)[0])
@ -23,6 +25,26 @@ def do_delayed_imports():
global webdriver
import webdriver
global ServoCommandExtensions
class ServoCommandExtensions(object):
def __init__(self, session):
self.session = session
@webdriver.client.command
def get_prefs(self, *prefs):
body = {"prefs": list(prefs)}
return self.session.send_command("POST", "servo/prefs/get", body)
@webdriver.client.command
def set_prefs(self, prefs):
body = {"prefs": prefs}
return self.session.send_command("POST", "servo/prefs/set", body)
@webdriver.client.command
def reset_prefs(self, *prefs):
body = {"prefs": list(prefs)}
return self.session.send_command("POST", "servo/prefs/reset", body)
class ServoWebDriverProtocol(Protocol):
def __init__(self, executor, browser, capabilities, **kwargs):
@ -35,8 +57,7 @@ class ServoWebDriverProtocol(Protocol):
def connect(self):
"""Connect to browser via WebDriver."""
self.session = webdriver.Session(self.host, self.port,
extension=webdriver.servo.ServoCommandExtensions)
self.session = webdriver.Session(self.host, self.port, extension=ServoCommandExtensions)
self.session.start()
def after_connect(self):