Skip to content

Support for disabling scripts from WebDriver BiDi #11874

@juliandescottes

Description

@juliandescottes

What is the issue with the HTML Standard?

Attempt to summarize requirements for disabling scripts from WebDriver BiDi (see #11441)

BiDi exposes the command emulation.setScriptingEnabled which allows to disable script execution either for a set of navigables or a set of user contexts. The goal is to allow to test the behavior of a page when visited by a user with JavaScript disabled, so it should replicate as faithfully as possible how the browser behaves in this case.

However WebDriver BiDi also exposes several commands to execute javascript in the context of a given page:

  • script.evaluate and script.callFunction will execute a specific expression (or function) when the command is called
  • script.addPreloadScript will register a script for a given set of navigables or user contexts, which will run before any other script when a page loads

Those commands should still be allowed to successfully execute JavaScript even against a page where JavaScript was disabled via emulation.setScriptingEnabled. It is important to allow test and tool authors to run JavaScript, because it is a very useful escape hatch to either fetch information from the page or interact with the page, in case there is no specific webdriver bidi command to cover what the author wants to do.

Since those additional scripts still run in the context of the page, they normally would rely on the event loop / finalization registry of the page. In order for those scripts to behave correctly, users would expect thenables to work and weakmaps to be properly cleanedup, but that is problematic since those would effectively not work for scripts from the content page. See questions in the corresponding PR eg #11441 (comment)

cc @zcorpan @sadym-chromium

Let me know if I need to expand and add more details on a specific topic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions