Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some support for WPT tests in an Android emulator through WebDriver #21213

Merged
merged 15 commits into from Jul 21, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

servodriver: fix setting preferences

This makes `/_mozilla/mozilla/webgl/context_creation_error.html` pass,
for example.

```
./ mach test-wpt --product servodriver \
  --binary etc/run_in_headless_android_emulator.py \
  --binary-arg servo-x86 \
  --binary-arg target/i686-linux-android/release/servo.apk \
  /_mozilla/mozilla/webgl/context_creation_error.html
```
  • Loading branch information
SimonSapin committed Jul 20, 2018
commit 230a6da5ff59cebc0dca96afa4112e55248a78c5
@@ -34,17 +34,35 @@ def __init__(self, session):
@webdriver.client.command
def get_prefs(self, *prefs):
body = {"prefs": list(prefs)}
return self.session.send_command("POST", "servo/prefs/get", body)
return self.session.send_session_command("POST", "servo/prefs/get", body)

@webdriver.client.command
def set_prefs(self, prefs):
body = {"prefs": prefs}
return self.session.send_command("POST", "servo/prefs/set", body)
return self.session.send_session_command("POST", "servo/prefs/set", body)

@webdriver.client.command
def reset_prefs(self, *prefs):
body = {"prefs": list(prefs)}
return self.session.send_command("POST", "servo/prefs/reset", body)
return self.session.send_session_command("POST", "servo/prefs/reset", body)

def change_prefs(self, old_prefs, new_prefs):
# Servo interprets reset with an empty list as reset everything
if old_prefs:
self.reset_prefs(*old_prefs.keys())
self.set_prefs({k: parse_pref_value(v) for k, v in new_prefs.items()})


# See parse_pref_from_command_line() in components/config/opts.rs
def parse_pref_value(value):
if value == "true":
return True
if value == "false":
return False
try:
return float(value)
except ValueError:
return value


class ServoBaseProtocolPart(BaseProtocolPart):

This comment has been minimized.

@jgraham

jgraham Jul 20, 2018

Contributor

So, a more correct implementation would put all the logic for connecting via WebDriver in here (the long term goal is that we are able to share the executors and just encapsulate browser differences in the Protocol objects, but we're not there yet). Having said that I don't mind if you wait to refactor in that way.

@@ -111,11 +129,6 @@ def wait(self):
self.logger.error(traceback.format_exc(e))
break

def on_environment_change(self, old_environment, new_environment):
#Unset all the old prefs
self.session.extension.reset_prefs(*old_environment.get("prefs", {}).keys())
self.session.extension.set_prefs(new_environment.get("prefs", {}))


class ServoWebDriverRun(object):
def __init__(self, func, session, url, timeout, current_timeout=None):
@@ -215,6 +228,12 @@ def do_testharness(self, session, url, timeout):
session.back()
return result

def on_environment_change(self, new_environment):
self.protocol.session.extension.change_prefs(
self.last_environment.get("prefs", {}),
new_environment.get("prefs", {})
)


class TimeoutError(Exception):
pass
@@ -281,3 +300,9 @@ def _screenshot(self, session, url, timeout):
session.url = url
session.execute_async_script(self.wait_script)
return session.screenshot()

def on_environment_change(self, new_environment):
self.protocol.session.extension.change_prefs(
self.last_environment.get("prefs", {}),
new_environment.get("prefs", {})
)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.