Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some support for WPT tests in an Android emulator through WebDriver #21213

Merged
merged 15 commits into from Jul 21, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Fix Python errors in servodriver

  • Loading branch information
SimonSapin committed Jul 19, 2018
commit 780e21c970058ff32b00bffbaa457eb37fd3601f
@@ -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 @@ def is_alive(self):

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
@@ -11,8 +11,10 @@
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):

This comment has been minimized.

@jgraham

jgraham Jul 20, 2018

Contributor

Why is this inside do_delayed_imports?

This comment has been minimized.

@SimonSapin

SimonSapin Jul 20, 2018

Author Member

Because it relies on webdriver.client.command, and webdriver is delayed.

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 @@ def __init__(self, executor, browser, capabilities, **kwargs):

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):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.