From 280d04eaabed08d430d12c8af971b0b56f32310f Mon Sep 17 00:00:00 2001 From: Jonathan Lee Date: Fri, 11 Oct 2024 15:13:57 -0700 Subject: [PATCH] [wptrunner] Cycle testdriver event loop when testharness isn't loaded (#48582) Workaround for https://crbug.com/340662810 that seems to work without an increase in test runtime or regressions (https://crrev.com/c/5698330/9). --- .../wptrunner/wptrunner/executors/executorchrome.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/wptrunner/wptrunner/executors/executorchrome.py b/tools/wptrunner/wptrunner/executors/executorchrome.py index 4dd2f86f5cfd0d..53c11f133e5e01 100644 --- a/tools/wptrunner/wptrunner/executors/executorchrome.py +++ b/tools/wptrunner/wptrunner/executors/executorchrome.py @@ -2,6 +2,7 @@ import collections import os +import re import time from typing import Mapping, MutableMapping, Type @@ -244,6 +245,18 @@ def setup(self, runner, protocol=None): } self.protocol.cdp.execute_cdp_command("Browser.setPermission", params) + def _get_next_message_classic(self, protocol, url, test_window): + try: + return super()._get_next_message_classic(protocol, url, test_window) + except error.JavascriptErrorException as js_error: + # TODO(crbug.com/340662810): Cycle testdriver event loop to work + # around `testharnessreport.js` flakily not loaded. + if re.search(r'window\.__wptrunner_process_next_event is not a function', + js_error.message): + time.sleep(0.05) + return None + raise + @_evaluate_leaks class ChromeDriverPrintRefTestExecutor(WebDriverPrintRefTestExecutor,