From b0ca93683fe046dcc14a4353531a5a3855b864de Mon Sep 17 00:00:00 2001 From: Christian Biesinger Date: Mon, 19 Jun 2023 19:54:25 +0000 Subject: [PATCH] Bug 1833659 [wpt PR 40058] - Don't make WebDriverExceptions force-fail the test, a=testonly Automatic update from web-platform-tests Don't make WebDriverExceptions force-fail the test (#40058) Instead, allow JavaScript to catch them, and have the `unhandledrejection` handler trigger the test failure if they are not caught. Fixes #40057 -- wpt-commits: 15522c48a8938ca569640ee5874f013e404b8f90 wpt-pr: 40058 --- .../web-platform/tests/tools/wptrunner/wptrunner/executors/base.py | 6 +++++- .../tools/wptrunner/wptrunner/executors/executormarionette.py | 7 +++++++ .../tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py index 4b715a1f3171..c537e8271c7e 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py @@ -710,6 +710,7 @@ class CallbackHandler: fully custom implementation.""" unimplemented_exc: ClassVar[Tuple[Type[Exception], ...]] = (NotImplementedError,) + expected_exc: ClassVar[Tuple[Type[Exception], ...]] = () def __init__(self, logger, protocol, test_window): self.protocol = protocol @@ -749,8 +750,11 @@ class CallbackHandler: except self.unimplemented_exc: self.logger.warning("Action %s not implemented" % action) self._send_message(cmd_id, "complete", "error", "Action %s not implemented" % action) + except self.expected_exc: + self.logger.debug("Action %s failed with an expected exception" % action) + self._send_message(cmd_id, "complete", "error") except Exception: - self.logger.warning("Action %s failed" % action) + self.logger.error("Action %s failed" % action) self.logger.warning(traceback.format_exc()) self._send_message(cmd_id, "complete", "error") raise diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py index a18063c98011..9c9c18735a64 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py @@ -72,6 +72,13 @@ def _switch_to_window(marionette, handle): marionette.window = handle +class MarionetteCallbackHandler(CallbackHandler): + + def __init__(self, logger, protocol, test_window): + MarionetteCallbackHandler.expected_exc = (errors.MarionetteException,) + super().__init__(self, logger, protocol, test_window) + + class MarionetteBaseProtocolPart(BaseProtocolPart): def __init__(self, parent): super().__init__(parent) diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 46b98d4df13c..b31c84d8e88f 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -43,6 +43,7 @@ here = os.path.dirname(__file__) class WebDriverCallbackHandler(CallbackHandler): unimplemented_exc = (NotImplementedError, error.UnknownCommandException) + expected_exc = (error.WebDriverException,) class WebDriverBaseProtocolPart(BaseProtocolPart): -- 2.11.4.GIT