Skip to content

Commit 965dd6e

Browse files
[wptrunner] Mark WebDriver protocol as not alive in other cases (#46621)
* [wptrunner] Mark WebDriver protocol as not alive if `OSError` raised This is a follow-up improvement to #45833. `Protocol.is_alive()` should handle a browser that's unable to even establish the low-level transport. `OSError` is a sufficiently broad base exception, which encompasses `socket.timeout`, `IOError`, and the `Connection*Error` family. * Coerce all `WebDriverException`s to not alive * Update safari infrastructure expectation
1 parent 706749d commit 965dd6e

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

infrastructure/metadata/infrastructure/testdriver/virtual_authenticator.html.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[virtual_authenticator.html]
22
expected:
3-
if product == "safari": ERROR
3+
if product == "safari": CRASH
44

55
[Can create an authenticator]
66
expected:

tools/wptrunner/wptrunner/executors/executorwebdriver.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def is_alive(self):
517517
# 5 seconds of extra_timeout we have as maximum to end the test before
518518
# the external timeout from testrunner triggers.
519519
self.webdriver.send_session_command("GET", "window", timeout=2)
520-
except (socket.timeout, error.UnknownErrorException, error.InvalidSessionIdException):
520+
except (OSError, error.WebDriverException):
521521
return False
522522
return True
523523

@@ -630,11 +630,7 @@ def do_testharness(self, protocol, url, timeout):
630630
#
631631
# https://github.com/w3c/webdriver/issues/1308
632632
if not isinstance(result, list) or len(result) != 3:
633-
try:
634-
is_alive = self.is_alive()
635-
except error.WebDriverException:
636-
is_alive = False
637-
633+
is_alive = self.is_alive()
638634
if not is_alive:
639635
raise Exception("Browser crashed during script execution.")
640636

tools/wptrunner/wptrunner/executors/protocol.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,12 @@ def is_alive(self):
776776
proof enough to us that the server is alive and kicking.
777777
"""
778778
conn = HTTPConnection(self.browser.host, self.browser.port)
779-
conn.request("HEAD", "/invalid")
780-
res = conn.getresponse()
781-
return res.status == 404
779+
try:
780+
conn.request("HEAD", "/invalid")
781+
res = conn.getresponse()
782+
return res.status == 404
783+
except OSError:
784+
return False
782785

783786

784787
class VirtualSensorProtocolPart(ProtocolPart):

0 commit comments

Comments
 (0)