Skip to content

Commit

Permalink
Rename async_call_function->call_function and params
Browse files Browse the repository at this point in the history
  • Loading branch information
sadym-chromium committed Apr 22, 2024
1 parent 5e18b51 commit 8330261
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
17 changes: 9 additions & 8 deletions tools/wptrunner/wptrunner/executors/executorwebdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tools/wptrunner/wptrunner/executors/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 8330261

Please sign in to comment.