w3c / webdriver-bidi

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

Support setting page content #759

Open OrKoN opened 1 month ago

OrKoN commented 1 month ago

Puppeteer allows setting document content via https://pptr.dev/api/puppeteer.page.setcontent The implementation is based on document.open + document.write. With document.write being deprecated, it would good to offer a way to do this over WebDriver BiDi. CDP provides a method to do this https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-setDocumentContent

I am not quite convinced that would be a useful addition to the standard but I wonder if others have some feedback.

jgraham commented 1 month ago

I guess the question is whether the semantics are different from document.open / document.write and if so what they actually are. It seems somewhat unlikely that document.write will be removed from the platform, so it seems OK to require that people who want to overwrite the current document in-place keep using that.

OrKoN commented 1 month ago

There are some observable side-effects in Chrome https://html.spec.whatwg.org/#document-written-scripts-intervention / https://chromestatus.com/feature/5718547946799104 E.g., users might get warning console message when using scripts in document.write.