w3c / webdriver-bidi

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

Extend `browsingContext.Info` with `opener` #516

Open Lightning00Blade opened 10 months ago

Lightning00Blade commented 10 months ago

In CDP there is a concept opener exits related to new Windows/Tab being open from another Window/Tab. Puppeteer also supports this for CDP via the page.on('popup'). Ref CDP TargeInfo

The proposed solution would be add a property on the browsingContext.Info Type called opener, that will be browsingContext.BrowsingContext / null of either the browsing context or the top level browsing context.

Example of such scenarios:

OrKoN commented 10 months ago

Sounds reasonable to me.

OrKoN commented 10 months ago

cc @jgraham @whimboo @juliandescottes do you have any concerns about this?

Lightning00Blade commented 10 months ago

For reference the HTML spec already says that each browsing context should have a property opener -> https://html.spec.whatwg.org/multipage/document-sequences.html#windows The only real discussion is around the noopener=true as CDP allows you to get the info even then I believe.

jgraham commented 8 months ago

This seems fine.

OrKoN commented 4 months ago

I think the difficultly here is that when the HTML spec calls the algorithm to emit the browsing context create event, there is no original opener ID available in that algorithm and I am not sure what is the best way to make it available. Note that Puppeteer requires an opener ID even if the browsing context is loaded with noopener=true. There is a place for saving the original opener after the context is created but it is too late for including it in the created event: https://github.com/w3c/webdriver-bidi/pull/664

jgraham commented 2 months ago

In gecko this is easy to implement in the case that we have window.opener but hard in cases where window.opener is null (in that case we discard knowledge of the original opener early, like the spec). So a question is how much of the use case here depends on always having opener, vs only having it in cases where window.opener exists.