Skip to content
Permalink
Browse files

Update to latest wptrunner.

  • Loading branch information
jgraham committed Oct 27, 2015
1 parent bccede0 commit 5998742e5d7acd42aabc6f442c2f110361e941c9
@@ -27,7 +27,8 @@ def check_args(**kwargs):
def browser_kwargs(**kwargs):
return {"binary": kwargs["binary"],
"debug_info": kwargs["debug_info"],
"user_stylesheets": kwargs.get("user_stylesheets")}
"user_stylesheets": kwargs.get("user_stylesheets"),
"render_backend": kwargs.get("servo_backend")}


def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
@@ -46,14 +47,21 @@ def env_options():
"supports_debugger": True}


def render_arg(render_backend):
return {"cpu": "--cpu"}[render_backend]


class ServoBrowser(NullBrowser):
def __init__(self, logger, binary, debug_info=None, user_stylesheets=None):
def __init__(self, logger, binary, debug_info=None, user_stylesheets=None,
render_backend="cpu"):
NullBrowser.__init__(self, logger)
self.binary = binary
self.debug_info = debug_info
self.user_stylesheets = user_stylesheets or []
self.render_backend = render_backend

def executor_browser(self):
return ExecutorBrowser, {"binary": self.binary,
"debug_info": self.debug_info,
"user_stylesheets": self.user_stylesheets}
"user_stylesheets": self.user_stylesheets,
"render_backend": self.render_backend}
@@ -9,6 +9,7 @@
from mozprocess import ProcessHandler

from .base import Browser, require_arg, get_free_port, browser_command, ExecutorBrowser
from .servo import render_arg
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorservodriver import (ServoWebDriverTestharnessExecutor,
ServoWebDriverRefTestExecutor)
@@ -39,7 +40,9 @@ def check_args(**kwargs):

def browser_kwargs(**kwargs):
return {"binary": kwargs["binary"],
"debug_info": kwargs["debug_info"]}
"debug_info": kwargs["debug_info"],
"user_stylesheets": kwargs.get("user_stylesheets"),
"render_backend": kwargs.get("servo_backend")}


def executor_kwargs(test_type, server_config, cache_manager, run_info_data, **kwargs):
@@ -66,7 +69,8 @@ def make_hosts_file():
class ServoWebDriverBrowser(Browser):
used_ports = set()

def __init__(self, logger, binary, debug_info=None, webdriver_host="127.0.0.1"):
def __init__(self, logger, binary, debug_info=None, webdriver_host="127.0.0.1",
user_stylesheets=None, render_backend="cpu"):
Browser.__init__(self, logger)
self.binary = binary
self.webdriver_host = webdriver_host
@@ -75,6 +79,8 @@ def __init__(self, logger, binary, debug_info=None, webdriver_host="127.0.0.1"):
self.debug_info = debug_info
self.hosts_path = make_hosts_file()
self.command = None
self.user_stylesheets = user_stylesheets if user_stylesheets else []
self.render_backend = render_backend

def start(self):
self.webdriver_port = get_free_port(4444, exclude=self.used_ports)
@@ -84,11 +90,14 @@ def start(self):
env["HOST_FILE"] = self.hosts_path

debug_args, command = browser_command(self.binary,
["--cpu", "--hard-fail",
[render_arg(self.render_backend), "--hard-fail",
"--webdriver", str(self.webdriver_port),
"about:blank"],
self.debug_info)

for stylesheet in self.user_stylesheets:
command += ["--user-stylesheet", stylesheet]

self.command = command

self.command = debug_args + self.command
@@ -22,6 +22,12 @@
reftest_result_converter)
from .process import ProcessTestExecutor
from ..browsers.base import browser_command
render_arg = None


def do_delayed_imports():
global render_arg
from ..browsers.servo import render_arg

hosts_text = """127.0.0.1 web-platform.test
127.0.0.1 www.web-platform.test
@@ -37,11 +43,13 @@ def make_hosts_file():
f.write(hosts_text)
return hosts_path


class ServoTestharnessExecutor(ProcessTestExecutor):
convert_result = testharness_result_converter

def __init__(self, browser, server_config, timeout_multiplier=1, debug_info=None,
pause_after_test=False):
do_delayed_imports()
ProcessTestExecutor.__init__(self, browser, server_config,
timeout_multiplier=timeout_multiplier,
debug_info=debug_info)
@@ -62,7 +70,8 @@ def do_test(self, test):
self.result_data = None
self.result_flag = threading.Event()

args = ["--cpu", "--hard-fail", "-u", "Servo/wptrunner", "-z", self.test_url(test)]
args = [render_arg(self.browser.render_backend), "--hard-fail", "-u", "Servo/wptrunner",
"-z", self.test_url(test)]
for stylesheet in self.browser.user_stylesheets:
args += ["--user-stylesheet", stylesheet]
for pref in test.environment.get('prefs', {}):
@@ -166,7 +175,7 @@ class ServoRefTestExecutor(ProcessTestExecutor):

def __init__(self, browser, server_config, binary=None, timeout_multiplier=1,
screenshot_cache=None, debug_info=None, pause_after_test=False):

do_delayed_imports()
ProcessTestExecutor.__init__(self,
browser,
server_config,
@@ -193,8 +202,9 @@ def screenshot(self, test):
with TempFilename(self.tempdir) as output_path:
debug_args, command = browser_command(
self.binary,
["--cpu", "--hard-fail", "--exit", "-u", "Servo/wptrunner",
"-Z", "disable-text-aa", "--output=%s" % output_path, full_url],
[render_arg(self.browser.render_backend), "--hard-fail", "--exit",
"-u", "Servo/wptrunner", "-Z", "disable-text-aa",
"--output=%s" % output_path, full_url],
self.debug_info)

for stylesheet in self.browser.user_stylesheets:
@@ -220,12 +220,11 @@ def send(self, method, url, body=None, headers=None, key=None):
except Exception:
# This should probably be more specific
raise IOError
body = resp.read()
resp_body = resp.read()

try:
data = json.loads(body)
data = json.loads(resp_body)
except:
raise
raise WebDriverException("Could not parse response body as JSON: %s" % body)

if resp.status != 200:
@@ -345,6 +344,24 @@ def _find_element(self, strategy, selector, all):
return rv


class Cookies(object):
def __init__(self, session):
self.session = session

def __getitem__(self, name):
self.session.send_command("GET", "cookie/%s" % name, {}, key="value")

def __setitem__(self, name, value):
cookie = {"name": name,
"value": None}

if isinstance(name, (str, unicode)):
cookie["value"] = value
elif hasattr(value, "value"):
cookie["value"] = value.value
self.session.send_command("POST", "cookie/%s" % name, {}, key="value")


class Session(object):
def __init__(self, host, port, url_prefix="", desired_capabilities=None, port_timeout=60,
extension=None):
@@ -496,7 +513,7 @@ def set_cookie(self, name, value, path=None, domain=None, secure=None, expiry=No
body["secure"] = secure
if expiry is not None:
body["expiry"] = expiry
self.send_command("POST", "cookie", body)
self.send_command("POST", "cookie", {"cookie": body})

def delete_cookie(self, name=None):
if name is None:
@@ -593,14 +610,18 @@ def name(self):
return self.session.send_command("GET", self.url("name"))

@command
def css(self, property_name):
def style(self, property_name):
return self.session.send_command("GET", self.url("css/%s" % property_name))

@property
@command
def rect(self):
return self.session.send_command("GET", self.url("rect"))

@command
def attribute(self, name):
return self.session.send_command("GET", self.url("attribute/%s" % name))

class ServoExtensions(object):
def __init__(self, session):
self.session = session
@@ -165,6 +165,10 @@ def create_parser(product_choices=None):
servo_group.add_argument("--user-stylesheet",
default=[], action="append", dest="user_stylesheets",
help="Inject a user CSS stylesheet into every test.")
servo_group.add_argument("--servo-backend",
default="cpu", choices=["cpu", "webrender"],
help="Rendering backend to use with Servo.")


parser.add_argument("test_list", nargs="*",
help="List of URLs for tests to run, or paths including tests to run. "

0 comments on commit 5998742

Please sign in to comment.
You can’t perform that action at this time.