servo.py (4640B)
1 # mypy: allow-untyped-defs 2 3 import os 4 5 from .base import ExecutorBrowser, NullBrowser, WebDriverBrowser, require_arg 6 from .base import get_timeout_multiplier # noqa: F401 7 from ..executors import executor_kwargs as base_executor_kwargs 8 from ..executors.base import WdspecExecutor # noqa: F401 9 from ..executors.executorservo import (ServoCrashtestExecutor, # noqa: F401 10 ServoTestharnessExecutor, # noqa: F401 11 ServoRefTestExecutor) # noqa: F401 12 13 14 here = os.path.dirname(__file__) 15 16 __wptrunner__ = { 17 "product": "servo", 18 "check_args": "check_args", 19 "browser": {None: "ServoBrowser", 20 "wdspec": "ServoWdspecBrowser"}, 21 "executor": { 22 "crashtest": "ServoCrashtestExecutor", 23 "testharness": "ServoTestharnessExecutor", 24 "reftest": "ServoRefTestExecutor", 25 "wdspec": "WdspecExecutor", 26 }, 27 "browser_kwargs": "browser_kwargs", 28 "executor_kwargs": "executor_kwargs", 29 "env_extras": "env_extras", 30 "env_options": "env_options", 31 "timeout_multiplier": "get_timeout_multiplier", 32 "update_properties": "update_properties", 33 } 34 35 36 def check_args(**kwargs): 37 require_arg(kwargs, "binary") 38 39 40 def browser_kwargs(logger, test_type, run_info_data, config, subsuite, **kwargs): 41 return { 42 "binary": kwargs["binary"], 43 "debug_info": kwargs["debug_info"], 44 "binary_args": kwargs["binary_args"] + subsuite.config.get("binary_args", []), 45 "headless": kwargs["headless"], 46 "user_stylesheets": kwargs.get("user_stylesheets"), 47 "ca_certificate_path": config.ssl_config["ca_cert_path"], 48 } 49 50 51 def executor_kwargs(logger, test_type, test_environment, run_info_data, 52 **kwargs): 53 rv = base_executor_kwargs(test_type, test_environment, run_info_data, **kwargs) 54 rv["pause_after_test"] = kwargs["pause_after_test"] 55 rv["headless"] = kwargs.get("headless", False) 56 if test_type == "wdspec": 57 rv["capabilities"] = {} 58 return rv 59 60 61 def env_extras(**kwargs): 62 return [] 63 64 65 def env_options(): 66 return {"server_host": "127.0.0.1", 67 "bind_address": False, 68 "testharnessreport": "testharnessreport-servo.js", 69 "supports_debugger": True} 70 71 72 def update_properties(): 73 return ["debug", "os", "processor", "subsuite"], {"os": ["version"], "processor": ["bits"]} 74 75 76 class ServoBrowser(NullBrowser): 77 def __init__(self, logger, binary, debug_info=None, binary_args=None, 78 user_stylesheets=None, ca_certificate_path=None, **kwargs): 79 NullBrowser.__init__(self, logger, **kwargs) 80 self.binary = binary 81 self.debug_info = debug_info 82 self.binary_args = binary_args or [] 83 self.user_stylesheets = user_stylesheets or [] 84 self.ca_certificate_path = ca_certificate_path 85 86 def executor_browser(self): 87 return ExecutorBrowser, { 88 "binary": self.binary, 89 "debug_info": self.debug_info, 90 "binary_args": self.binary_args, 91 "user_stylesheets": self.user_stylesheets, 92 "ca_certificate_path": self.ca_certificate_path, 93 } 94 95 96 class ServoWdspecBrowser(WebDriverBrowser): 97 # TODO: could share an implemenation with servodriver.py, perhaps 98 def __init__(self, logger, binary="servo", webdriver_binary="servo", 99 binary_args=None, webdriver_args=None, env=None, port=None, 100 headless=None, 101 **kwargs): 102 103 env = os.environ.copy() if env is None else env 104 env["RUST_BACKTRACE"] = "1" 105 106 super().__init__(logger, 107 binary=binary, 108 webdriver_binary=webdriver_binary, 109 webdriver_args=webdriver_args, 110 port=port, 111 env=env, 112 **kwargs) 113 self.binary_args = binary_args 114 self.headless = ["--headless"] if headless else None 115 116 117 def make_command(self): 118 command = [self.binary, 119 f"--webdriver={self.port}", 120 "--hard-fail", 121 # See https://github.com/servo/servo/issues/30080. 122 # For some reason rustls does not like the certificate generated by the WPT tooling. 123 "--ignore-certificate-errors", 124 "--window-size", 125 "800x600", 126 "about:blank"] + self.webdriver_args 127 if self.binary_args: 128 command += self.binary_args 129 if self.headless: 130 command += self.headless 131 return command