Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Last active April 26, 2024 22:50
Show Gist options
  • Save juliandescottes/fca6e9f0c0a8da3a5809590b8c90816c to your computer and use it in GitHub Desktop.
Save juliandescottes/fca6e9f0c0a8da3a5809590b8c90816c to your computer and use it in GitHub Desktop.

WebDriver BiDi

Support custom browser to client messages

  • to install and to remove pre-load (bootstrap) -> "to add and to remove" (to be in sync with the command names?)

Two suggestions below to slightly rephrase some paragraphs in the code example:

  • While this was already helpful to just call those pre-defined functions from within any script.evaluate or script.callFunction command their return value needed to be returned via the command’s response.

    -> "This was already helpful to perform some setup logic, or to expose functions that could be called from script.evaluate or script.callFunction commands later on. However there was no way to properly handle dynamic situations, like monitoring DOM mutations and notify the client about the details."

  • This channel can then be used by the pre-load script to send data as a JSON object to the client whenever it’s code gets executed. Therefore a script.message event is emitted over the WebSocket channel with the id of the channel included.

    -> "In this case, the pre-load script will receive a channel argument. This channel argument is a function which can be called at any point to send data to the client, via a script.message event which will also include the id of the channel.

  • the channel id is supposed to be string, maybe we can use something with some letters, and not "42" (eg "my mutation channel")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment