Unreviewed. Update W3C WebDriver imported tests.
[WebKit-https.git] / WebDriverTests / imported / w3c / tools / wptrunner / wptrunner / browsers / edge.py
1 from .base import Browser, ExecutorBrowser, require_arg
2 from ..webdriver_server import EdgeDriverServer
3 from ..executors import executor_kwargs as base_executor_kwargs
4 from ..executors.executorselenium import (SeleniumTestharnessExecutor,
5                                           SeleniumRefTestExecutor)
6 from ..executors.executoredge import EdgeDriverWdspecExecutor
7
8 __wptrunner__ = {"product": "edge",
9                  "check_args": "check_args",
10                  "browser": "EdgeBrowser",
11                  "executor": {"testharness": "SeleniumTestharnessExecutor",
12                               "reftest": "SeleniumRefTestExecutor",
13                               "wdspec": "EdgeDriverWdspecExecutor"},
14                  "browser_kwargs": "browser_kwargs",
15                  "executor_kwargs": "executor_kwargs",
16                  "env_extras": "env_extras",
17                  "env_options": "env_options"}
18
19
20 def check_args(**kwargs):
21     require_arg(kwargs, "webdriver_binary")
22
23 def browser_kwargs(test_type, run_info_data, **kwargs):
24     return {"webdriver_binary": kwargs["webdriver_binary"],
25             "webdriver_args": kwargs.get("webdriver_args")}
26
27 def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
28                     **kwargs):
29     from selenium.webdriver import DesiredCapabilities
30
31     executor_kwargs = base_executor_kwargs(test_type, server_config,
32                                            cache_manager, **kwargs)
33     executor_kwargs["close_after_done"] = True
34     executor_kwargs["capabilities"] = dict(DesiredCapabilities.EDGE.items())
35     return executor_kwargs
36
37 def env_extras(**kwargs):
38     return []
39
40 def env_options():
41     return {"host": "web-platform.test",
42             "bind_hostname": "true",
43             "supports_debugger": False}
44
45 class EdgeBrowser(Browser):
46     used_ports = set()
47
48     def __init__(self, logger, webdriver_binary, webdriver_args=None):
49         Browser.__init__(self, logger)
50         self.server = EdgeDriverServer(self.logger,
51                                        binary=webdriver_binary,
52                                        args=webdriver_args)
53         self.webdriver_host = "localhost"
54         self.webdriver_port = self.server.port
55
56     def start(self, **kwargs):
57         print self.server.url
58         self.server.start()
59
60     def stop(self, force=False):
61         self.server.stop(force=force)
62
63     def pid(self):
64         return self.server.pid
65
66     def is_alive(self):
67         # TODO(ato): This only indicates the server is alive,
68         # and doesn't say anything about whether a browser session
69         # is active.
70         return self.server.is_alive()
71
72     def cleanup(self):
73         self.stop()
74
75     def executor_browser(self):
76         return ExecutorBrowser, {"webdriver_url": self.server.url}