From 833026149c0b6bb88f2795bf6056d750d7838f74 Mon Sep 17 00:00:00 2001 From: Maksim Sadym Date: Mon, 22 Apr 2024 13:03:06 +0200 Subject: [PATCH] Rename `async_call_function`->`call_function` and params --- .../wptrunner/executors/executorwebdriver.py | 17 +++++++++-------- tools/wptrunner/wptrunner/executors/protocol.py | 12 ++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index c55bbf8a9fd56a..4bb49f9e723c64 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -144,12 +144,11 @@ def __init__(self, parent): def setup(self): self.webdriver = self.parent.webdriver - async def async_call_function(self, script, context, args=None): + async def call_function(self, function_declaration, target, arguments=None): return await self.webdriver.bidi_session.script.call_function( - function_declaration=script, - arguments=args, - target={ - "context": context if context else self.current_window}, + function_declaration=function_declaration, + arguments=arguments, + target=target, await_promise=True) @@ -819,9 +818,11 @@ def _get_next_message(self, protocol, url, test_window): } # `run_until_complete` allows processing BiDi events in the same loop while waiting for the next message. - message = protocol.loop.run_until_complete(protocol.bidi_script.async_call_function( - wrapped_script, context=test_window, - args=[bidi_url_argument])) + message = protocol.loop.run_until_complete(protocol.bidi_script.call_function( + wrapped_script, target={ + "context": test_window + }, + arguments=[bidi_url_argument])) # The message is in WebDriver BiDi format. Deserialize it. deserialized_message = self.bidi_deserialize(message) return deserialized_message diff --git a/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index bc86a024ef60b2..d0df0f7c00cdc4 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -332,7 +332,7 @@ async def subscribe(self, events, contexts): """Subscribe to events. :param list events: The list of events names to subscribe to. - :param list contexts: The list of contexts to subscribe to. None for global subscription.""" + :param list|None contexts: The list of contexts ids to subscribe to. None for global subscription.""" pass @abstractmethod @@ -361,13 +361,13 @@ class BidiScriptProtocolPart(ProtocolPart): name = "bidi_script" @abstractmethod - async def async_call_function(self, script, context, args=None): + async def call_function(self, function_declaration, target, arguments=None): """ - Executes the provided script in the given context in asynchronous mode. + Executes the provided script in the given target in asynchronous mode. - :param str script: The js source to execute. - :param str context: The context in which to execute the script. - :param list args: The arguments to pass to the script. + :param str function_declaration: The js source of the function to execute. + :param script.Target target: The target in which to execute the script. + :param list[script.LocalValue] arguments: The arguments to pass to the script. """ pass