Skip to content

Commit

Permalink
Choose ChromeDriverProtocol based on the browser setting `require_web…
Browse files Browse the repository at this point in the history
…driver_bidi`
  • Loading branch information
sadym-chromium committed Nov 7, 2024
1 parent 9b130f3 commit 6173225
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
disabled: https://github.com/web-platform-tests/wpt/issues/47544
disabled:
if product != "chrome": @True
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
disabled: https://github.com/web-platform-tests/wpt/issues/47544
disabled:
if product != "chrome": @True
18 changes: 17 additions & 1 deletion tools/wptrunner/wptrunner/browsers/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mozlog.structuredlog import StructuredLogger

from . import chrome_spki_certs
from .base import BrowserError
from .base import BrowserError, BrowserSettings
from .base import WebDriverBrowser, require_arg
from .base import NullBrowser # noqa: F401
from .base import OutputHandler
Expand Down Expand Up @@ -41,6 +41,8 @@
"update_properties": "update_properties",
"timeout_multiplier": "get_timeout_multiplier",}

from ..wpttest import Test


def debug_args(debug_info):
if debug_info.interactive:
Expand Down Expand Up @@ -214,6 +216,7 @@ def __init__(self,
super().__init__(logger, **kwargs)
self._leak_check = leak_check
self._actual_port = None
self._require_webdriver_bidi = None

def restart_on_test_type_change(self, new_test_type: str, old_test_type: str) -> bool:
# Restart the test runner when switch from/to wdspec tests. Wdspec test
Expand Down Expand Up @@ -262,6 +265,19 @@ def executor_browser(self):
browser_cls, browser_kwargs = super().executor_browser()
return browser_cls, {**browser_kwargs, "leak_check": self._leak_check}

@property
def require_webdriver_bidi(self) -> Optional[bool]:
return self._require_webdriver_bidi

def settings(self, test: Test) -> BrowserSettings:
""" Required to store `require_webdriver_bidi` in browser settings."""
settings = super().settings(test)
self._require_webdriver_bidi = test.require_webdriver_bidi
return {
**settings,
"require_webdriver_bidi": self._require_webdriver_bidi
}


class ChromeDriverOutputHandler(OutputHandler):
PORT_RE = re.compile(rb'.*was started successfully on port (\d+)\.')
Expand Down
32 changes: 30 additions & 2 deletions tools/wptrunner/wptrunner/executors/executorchrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
WebDriverFedCMProtocolPart,
WebDriverPrintRefTestExecutor,
WebDriverProtocol,
WebDriverBidiProtocol,
WebDriverRefTestExecutor,
WebDriverTestharnessExecutor,
WebDriverTestharnessProtocolPart,
Expand Down Expand Up @@ -211,6 +212,28 @@ def __init__(self, executor, browser, capabilities, **kwargs):
super().__init__(executor, browser, capabilities, **kwargs)


# TODO: simplify
class ChromeDriverBidiProtocol(WebDriverBidiProtocol):
implements = [
ChromeDriverBaseProtocolPart,
ChromeDriverDevToolsProtocolPart,
ChromeDriverFedCMProtocolPart,
ChromeDriverTestharnessProtocolPart,
]
for base_part in WebDriverBidiProtocol.implements:
if base_part.name not in {part.name for part in implements}:
implements.append(base_part)

# Prefix to apply to vendor-specific WebDriver extension commands.
vendor_prefix = "goog"

def __init__(self, executor, browser, capabilities, **kwargs):
self.implements = list(ChromeDriverBidiProtocol.implements)
if getattr(browser, "leak_check", False):
self.implements.append(ChromeDriverLeakProtocolPart)
super().__init__(executor, browser, capabilities, **kwargs)


def _evaluate_leaks(executor_cls):
if hasattr(executor_cls, "base_convert_result"):
# Don't wrap more than once, which can cause unbounded recursion.
Expand Down Expand Up @@ -244,9 +267,14 @@ class ChromeDriverRefTestExecutor(WebDriverRefTestExecutor, _SanitizerMixin): #

@_evaluate_leaks
class ChromeDriverTestharnessExecutor(WebDriverTestharnessExecutor, _SanitizerMixin): # type: ignore
protocol_cls = ChromeDriverProtocol

def __init__(self, *args, reuse_window=False, **kwargs):
require_webdriver_bidi = kwargs.get("browser_settings", {}).get("require_webdriver_bidi",
None)
if require_webdriver_bidi == 'true':
self.protocol_cls = ChromeDriverBidiProtocol
else:
self.protocol_cls = ChromeDriverProtocol

super().__init__(*args, **kwargs)
self.reuse_window = reuse_window

Expand Down

0 comments on commit 6173225

Please sign in to comment.