forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request web-platform-tests#8987 from w3c/chrome-android
wpt run for chome on android
- Loading branch information
Showing
6 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
To run WPT on Chrome on an android device, some additional set up is required. | ||
First until we find a better way, we need to root the android device and update | ||
the /etc/hosts file to include | ||
|
||
``` | ||
127.0.0.1 web-platform.test | ||
127.0.0.1 www.web-platform.test | ||
127.0.0.1 www1.web-platform.test | ||
127.0.0.1 www2.web-platform.test | ||
127.0.0.1 xn--n8j6ds53lwwkrqhv28a.web-platform.test | ||
127.0.0.1 xn--lve-6lad.web-platform.test | ||
0.0.0.0 nonexistent-origin.web-platform.test | ||
``` | ||
|
||
Next, we need to start adb and reverse forward the web-platform.tests ports | ||
|
||
``` | ||
adb start-server | ||
``` | ||
|
||
Add any ports that you need based on your config. For example: | ||
``` | ||
adb reverse tcp:8000 tcp:8000 | ||
adb reverse tcp:8001 tcp:8001 | ||
adb reverse tcp:8081 tcp:8081 | ||
adb reverse tcp:8444 tcp:8444 | ||
adb reverse tcp:9001 tcp:9001 | ||
adb reverse tcp:9444 tcp:9444 | ||
``` | ||
|
||
After this, we may run wpt with the `chrome_android` product | ||
|
||
``` | ||
./wpt run chrome_android <test> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mozprocess >= 0.19 | ||
selenium >= 2.41.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
""" | ||
|
||
product_list = ["chrome", | ||
"chrome_android", | ||
"edge", | ||
"firefox", | ||
"ie", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from .base import Browser, ExecutorBrowser, require_arg | ||
from ..webdriver_server import ChromeDriverServer | ||
from ..executors import executor_kwargs as base_executor_kwargs | ||
from ..executors.executorselenium import (SeleniumTestharnessExecutor, | ||
SeleniumRefTestExecutor) | ||
from ..executors.executorchrome import ChromeDriverWdspecExecutor | ||
|
||
|
||
__wptrunner__ = {"product": "chrome_android", | ||
"check_args": "check_args", | ||
"browser": "ChromeAndroidBrowser", | ||
"executor": {"testharness": "SeleniumTestharnessExecutor", | ||
"reftest": "SeleniumRefTestExecutor", | ||
"wdspec": "ChromeDriverWdspecExecutor"}, | ||
"browser_kwargs": "browser_kwargs", | ||
"executor_kwargs": "executor_kwargs", | ||
"env_extras": "env_extras", | ||
"env_options": "env_options"} | ||
|
||
|
||
def check_args(**kwargs): | ||
require_arg(kwargs, "webdriver_binary") | ||
|
||
|
||
def browser_kwargs(test_type, run_info_data, **kwargs): | ||
return {"binary": kwargs["binary"], | ||
"webdriver_binary": kwargs["webdriver_binary"], | ||
"webdriver_args": kwargs.get("webdriver_args")} | ||
|
||
|
||
def executor_kwargs(test_type, server_config, cache_manager, run_info_data, | ||
**kwargs): | ||
from selenium.webdriver import DesiredCapabilities | ||
|
||
executor_kwargs = base_executor_kwargs(test_type, server_config, | ||
cache_manager, **kwargs) | ||
executor_kwargs["close_after_done"] = True | ||
capabilities = dict(DesiredCapabilities.CHROME.items()) | ||
capabilities["chromeOptions"] = {} | ||
# required to start on mobile | ||
capabilities["chromeOptions"]["androidPackage"] = "com.android.chrome" | ||
|
||
for (kwarg, capability) in [("binary", "binary"), ("binary_args", "args")]: | ||
if kwargs[kwarg] is not None: | ||
capabilities["chromeOptions"][capability] = kwargs[kwarg] | ||
if test_type == "testharness": | ||
capabilities["useAutomationExtension"] = False | ||
capabilities["excludeSwitches"] = ["enable-automation"] | ||
if test_type == "wdspec": | ||
capabilities["chromeOptions"]["w3c"] = True | ||
executor_kwargs["capabilities"] = capabilities | ||
return executor_kwargs | ||
|
||
|
||
def env_extras(**kwargs): | ||
return [] | ||
|
||
|
||
def env_options(): | ||
return {"host": "web-platform.test", | ||
"bind_hostname": "true"} | ||
|
||
|
||
class ChromeAndroidBrowser(Browser): | ||
"""Chrome is backed by chromedriver, which is supplied through | ||
``wptrunner.webdriver.ChromeDriverServer``. | ||
""" | ||
|
||
def __init__(self, logger, binary, webdriver_binary="chromedriver", | ||
webdriver_args=None): | ||
"""Creates a new representation of Chrome. The `binary` argument gives | ||
the browser binary to use for testing.""" | ||
Browser.__init__(self, logger) | ||
self.binary = binary | ||
self.server = ChromeDriverServer(self.logger, | ||
binary=webdriver_binary, | ||
args=webdriver_args) | ||
|
||
def start(self, **kwargs): | ||
self.server.start(block=False) | ||
|
||
def stop(self, force=False): | ||
self.server.stop(force=force) | ||
|
||
def pid(self): | ||
return self.server.pid | ||
|
||
def is_alive(self): | ||
# TODO(ato): This only indicates the driver is alive, | ||
# and doesn't say anything about whether a browser session | ||
# is active. | ||
return self.server.is_alive() | ||
|
||
def cleanup(self): | ||
self.stop() | ||
|
||
def executor_browser(self): | ||
return ExecutorBrowser, {"webdriver_url": self.server.url} |