w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
350 stars 38 forks source link

Ability to disable JavaScript for a browsing context #746

Open OrKoN opened 1 month ago

OrKoN commented 1 month ago

Chrome allows disabling JavaScript for a specific page: https://pptr.dev/api/puppeteer.page.setjavascriptenabled/

Does it make sense to have this functionality in WebDriver BiDi?

jgraham commented 1 month ago

Yes, I think this makes sense. I'm not 100% sure if Gecko can disable it per (top level) navigable, but in any case it would make sense to have a command that either allowed disabling globally or for certain top-level navigables.

whimboo commented 1 month ago

I'm not 100% sure if Gecko can disable it per (top level) navigable

The BrowsingContext webidl has a allowJavascript flag which would exactly allow us to do that on a per top-level browsing context level.

shs96c commented 1 month ago

What should happen when JS is disabled yet a session wants to evaluate some JS? I believe that should still work, but it's best to confirm

OrKoN commented 1 month ago

@shs96c yeah, that should still work: only the scripts coming from the page should not be executed as if JS is not supported.

juliandescottes commented 1 month ago

The BrowsingContext webidl has a allowJavascript flag which would exactly allow us to do that on a per top-level browsing context level.

For info that's what we use for FF DevTools' "Disable JavaScript" feature

image