From f9569531b33187a53dbd7afe5a1287ced47f5c68 Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 26 May 2015 12:03:11 +0100 Subject: [PATCH 1/4] Only set the webdriver timeout when it changes. --- wptrunner/executors/executorservodriver.py | 39 ++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/wptrunner/executors/executorservodriver.py b/wptrunner/executors/executorservodriver.py index d03e0889cb16c9..99d3958778913f 100644 --- a/wptrunner/executors/executorservodriver.py +++ b/wptrunner/executors/executorservodriver.py @@ -84,7 +84,7 @@ def wait(self): class ServoWebDriverRun(object): - def __init__(self, func, session, url, timeout): + def __init__(self, func, session, url, timeout, current_timeout=None): self.func = func self.result = None self.session = session @@ -93,18 +93,10 @@ def __init__(self, func, session, url, timeout): self.result_flag = threading.Event() def run(self): - timeout = self.timeout - - try: - self.session.timeouts.script = timeout + extra_timeout - except IOError: - self.logger.error("Lost webdriver connection") - return Stop - executor = threading.Thread(target=self._run) executor.start() - flag = self.result_flag.wait(timeout + 2 * extra_timeout) + flag = self.result_flag.wait(self.timeout + extra_timeout) if self.result is None: assert not flag self.result = False, ("EXTERNAL-TIMEOUT", None) @@ -144,6 +136,7 @@ def __init__(self, browser, server_config, timeout_multiplier=1, self.protocol = ServoWebDriverProtocol(self, browser, capabilities=capabilities) with open(os.path.join(here, "testharness_servodriver.js")) as f: self.script = f.read() + self.timeout = None def on_protocol_change(self, new_protocol): pass @@ -154,10 +147,20 @@ def is_alive(self): def do_test(self, test): url = self.test_url(test) + timeout = test.timeout * self.timeout_multiplier + extra_timeout + + if timeout != self.timeout: + try: + self.protocol.session.timeouts.script = timeout + self.timeout = timeout + except IOError: + self.logger.error("Lost webdriver connection") + return Stop + success, data = ServoWebDriverRun(self.do_testharness, self.protocol.session, url, - test.timeout * self.timeout_multiplier).run() + timeout).run() if success: return self.convert_result(test, data) @@ -194,7 +197,7 @@ def __init__(self, browser, server_config, timeout_multiplier=1, self.protocol = ServoWebDriverProtocol(self, browser, capabilities=capabilities) self.implementation = RefTestImplementation(self) - + self.timeout = None with open(os.path.join(here, "reftest-wait_servodriver.js")) as f: self.wait_script = f.read() @@ -217,7 +220,17 @@ def do_test(self, test): return test.result_cls("ERROR", message), [] def screenshot(self, test): - timeout = test.timeout * self.timeout_multiplier if self.debug_info is None else None + timeout = (test.timeout * self.timeout_multiplier + extra_timeout + if self.debug_info is None else None) + + if self.timeout != timeout: + try: + self.protocol.session.timeouts.script = timeout + self.timeout = timeout + except IOError: + self.logger.error("Lost webdriver connection") + return Stop + return ServoWebDriverRun(self._screenshot, self.protocol.session, self.test_url(test), From a4fa32b16e8e001cc1f61c1c49e0694f3af7c464 Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 26 May 2015 12:03:42 +0100 Subject: [PATCH 2/4] Provide the test id in the results data for consistency checks. --- wptrunner/testharnessreport-servodriver.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wptrunner/testharnessreport-servodriver.js b/wptrunner/testharnessreport-servodriver.js index 2209af8b061c26..874a097ca2ca9a 100644 --- a/wptrunner/testharnessreport-servodriver.js +++ b/wptrunner/testharnessreport-servodriver.js @@ -9,7 +9,9 @@ add_completion_callback(function() { var test_results = tests.map(function(x) { return {name:x.name, status:x.status, message:x.message, stack:x.stack} }); - var results = JSON.stringify({tests:test_results, + var id = location.pathname + location.search + location.hash; + var results = JSON.stringify({test: id, + tests:test_results, status: status.status, message: status.message, stack: status.stack}); From 68156487033ce7757a45b25021b528dcba6eae5e Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 26 May 2015 12:04:17 +0100 Subject: [PATCH 3/4] Go back in history after each test to prevent leaking every page. --- wptrunner/executors/executorservodriver.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wptrunner/executors/executorservodriver.py b/wptrunner/executors/executorservodriver.py index 99d3958778913f..6b94c033bd1cd1 100644 --- a/wptrunner/executors/executorservodriver.py +++ b/wptrunner/executors/executorservodriver.py @@ -175,8 +175,9 @@ def do_testharness(self, session, url, timeout): "url": strip_server(url), "timeout_multiplier": self.timeout_multiplier, "timeout": timeout * 1000})) - if "test" not in result: - result["test"] = strip_server(url) + # Prevent leaking every page in history until Servo develops a more sane + # page cache + session.back() return result From e70257f5cd1b99dbf5fcb3a5c4bf8ab8d5c0de18 Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 26 May 2015 12:05:34 +0100 Subject: [PATCH 4/4] Remove debugging print statement --- wptrunner/executors/webdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wptrunner/executors/webdriver.py b/wptrunner/executors/webdriver.py index cabb0d6663712f..b3c9ab3a7f5a72 100644 --- a/wptrunner/executors/webdriver.py +++ b/wptrunner/executors/webdriver.py @@ -444,7 +444,7 @@ def switch_frame(self, frame): body = {"id": frame.json()} else: body = {"id": frame} - print body + return self.send_command("POST", url, body) @command