Unreviewed. Update W3C WebDriver imported tests.
[WebKit-https.git] / WebDriverTests / imported / w3c / tools / wptrunner / wptrunner / browsers / ie.py
1 from .base import Browser, ExecutorBrowser, require_arg
2 from ..webdriver_server import InternetExplorerDriverServer
3 from ..executors import executor_kwargs as base_executor_kwargs
4 from ..executors.executorselenium import (SeleniumTestharnessExecutor,
5                                           SeleniumRefTestExecutor)
6 from ..executors.executorinternetexplorer import InternetExplorerDriverWdspecExecutor
7
8 __wptrunner__ = {"product": "ie",
9                  "check_args": "check_args",
10                  "browser": "InternetExplorerBrowser",
11                  "executor": {"testharness": "SeleniumTestharnessExecutor",
12                               "reftest": "SeleniumRefTestExecutor",
13                               "wdspec": "InternetExplorerDriverWdspecExecutor"},
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     ieOptions = {}
32     ieOptions["requireWindowFocus"] = True
33     capabilities = {}
34     capabilities["se:ieOptions"] = ieOptions
35     executor_kwargs = base_executor_kwargs(test_type, server_config,
36                                            cache_manager, **kwargs)
37     executor_kwargs["close_after_done"] = True
38     executor_kwargs["capabilities"] = capabilities
39     return executor_kwargs
40
41 def env_extras(**kwargs):
42     return []
43
44 def env_options():
45     return {"host": "web-platform.test",
46             "bind_hostname": "true",
47             "supports_debugger": False}
48
49 class InternetExplorerBrowser(Browser):
50     used_ports = set()
51
52     def __init__(self, logger, webdriver_binary, webdriver_args=None):
53         Browser.__init__(self, logger)
54         self.server = InterentExplorerDriverServer(self.logger,
55                                                    binary=webdriver_binary,
56                                                    args=webdriver_args)
57         self.webdriver_host = "localhost"
58         self.webdriver_port = self.server.port
59
60     def start(self, **kwargs):
61         self.server.start()
62
63     def stop(self, force=False):
64         self.server.stop(force=force)
65
66     def pid(self):
67         return self.server.pid
68
69     def is_alive(self):
70         # TODO(ato): This only indicates the server is alive,
71         # and doesn't say anything about whether a browser session
72         # is active.
73         return self.server.is_alive()
74
75     def cleanup(self):
76         self.stop()
77
78     def executor_browser(self):
79         return ExecutorBrowser, {"webdriver_url": self.server.url}