Open Bug 1837031 Opened 1 year ago Updated 1 year ago

Request for a unique id that references a browsing context (navigable) even after a replacement

Categories

(Core :: DOM: Navigation, enhancement)

enhancement

Tracking

()

People

(Reporter: whimboo, Unassigned)

References

(Blocks 3 open bugs)

Details

For our WebDriver implementation we need a unique id that references a Navigable and survives browsing context replacements. Given that we do not have Navigables implemented in Gecko yet (and as we have heard that there are no such plans), we would like to request a property on the BrowsingContext interface which could be used to reference a given top-level browsing context (tab) even if it has been replaced by a cross-origin navigation. This id would have to be available on the parent and the child process and if possible synced automatically. Would a name like navigableId make sense? Most likely we would also need a getFromNavigableId() method to retrieve the related browsing context.

Per WebDriver specification it needs to be a string but for easier handling inside Gecko it could be a counter internally. The only requirement would be that the values are unique.

As Olli pointed out CanonicalBrowsingContext::ReplacedBy gets called whenever a browsing context gets replaced. As such the known unique id could easily be set on the new browsing context, and should then automatically be synced with the content process.

Olli, is there something else that we haven't discussed yet? And how difficult would such an implementation be?

Thanks!

browserId wouldn't help us here because it would only allow us to reference a top-level browsing context and wont work with BrowsingContext.get(). Means we would have to differentiate between top-level and child browsing contexts. But with the information that we get with the command payload from clients - it's only an uuid - we do not know if that is a top-level or child browsing context. So we might have to check get() first and if no browsing context can be found using getCurrentTopByBrowserId() afterward. But this would only work if the browserId and id would never have the same value. Is that guaranteed?

But the initial comment was talking about top level browsing contexts:
"we would like to request a property on the BrowsingContext interface which could be used to reference a given top-level browsing context (tab) even if it has been replaced by a cross-origin navigation."

Yes, because only top-level browsing contexts are getting replaced. Also the summary of the bug still doesn't include that the requested unique id is for top-level browsing contexts only. So to be clear we need an id that is stable and can reference any kind of browsing context while the tab or a frame is alive.

(In reply to Henrik Skupin [:whimboo][⌚️UTC+2] (away 07/08 - 07/30) from comment #4)

Yes, because only top-level browsing contexts are getting replaced. Also the summary of the bug still doesn't include that the requested unique id is for top-level browsing contexts only. So to be clear we need an id that is stable and can reference any kind of browsing context while the tab or a frame is alive.

Olli, would something like that be possible? One thing I'm not sure about is how it would actually work for unloaded tabs.

Flags: needinfo?(smaug)

I'm still a bit confused why the current IDs we have aren't enough. There is browsing context ID, and there is browser ID.
Can't you store the information like
browserid + "-" + browsingcontextid ?

Flags: needinfo?(smaug)
You need to log in before you can comment on or make changes to this bug.