Open Lightning00Blade opened 10 months ago
Sounds reasonable to me.
cc @jgraham @whimboo @juliandescottes do you have any concerns about this?
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.
This seems fine.
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
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.
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 thepage.on('popup')
. Ref CDP TargeInfoThe proposed solution would be add a property on the
browsingContext.Info Type
calledopener
, that will bebrowsingContext.BrowsingContext / null
of either the browsing context or the top level browsing context.Example of such scenarios:
window.open('about:blank')
.<a target=_blank href="/">open</a>
.