w3c / webdriver-bidi

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

Explicit support for unloaded tabs #656

Open juliandescottes opened 4 months ago

juliandescottes commented 4 months ago

As seen on https://bugzilla.mozilla.org/show_bug.cgi?id=1876240, some BiDi commands are not behaving correctly on Firefox when the browser has unloaded tabs.

On Firefox, we have unloaded tabs for instance when doing a session restore. Some tabs will be added in the background but they won't have any browsing context attached yet. It will typically only be created when the tab becomes selected. I think Chrome has a similar concept, but I don't know the implementation details.

At least on Firefox, such tabs don't have a document or browsing context attached yet, so a lot of our commands and events don't work properly. For instance, no browsingContext.contextCreated event will be emitted, browsingContext.navigate will fail etc...

How should we handle such tabs in BiDi, provided the concept is similar enough in all browsers?

An option would be to ignore those tabs until they are loaded: never return them from browsingContext.getTree, do not emit event for them etc...

whimboo commented 4 months ago

CC @OrKoN and @sadym-chromium

css-meeting-bot commented 3 months ago

The Browser Testing and Tools Working Group just discussed Support for unloaded tabs.

The full IRC log of that discussion <AutomatedTester> topic: Support for unloaded tabs
<AutomatedTester> github: https://github.com/w3c/webdriver-bidi/issues/656
<AutomatedTester> whimboo: This isnt a blocking topic at the moment but we will need to think about it in the future
<AutomatedTester> ... there could be cases where a tab doesnt have content window attached to it
<AutomatedTester> ... a lot of events will not be sent out if nthere isn't a content window attached
<AutomatedTester> ... so I wanted to see if there is a similar issue with chromium folks
<AutomatedTester> q?
<MaksimSadym> q+
<AutomatedTester> whimboo: this will be an issue with bidi as we can access tabs that are not currently focused. It's not an issue with webdriver classic
<AutomatedTester> ack next
<jgraham> q+
<jrandolf> q+
<AutomatedTester> Maksim Sadym: we have a more or less similar issue when we do print or screenshot when the tab is not in focus
<AutomatedTester> ... I will try look at this in the next week
<AutomatedTester> ack next
<AutomatedTester> jgraham: spec wise HTML doesn't have anything for this situation. We shoiuld probably raise an issue on that spec
<AutomatedTester> ... as it's not really discribed
<AutomatedTester> ack next
<AutomatedTester> jrandolf: could you precisely define unloaded
<jrandolf> q+
<AutomatedTester> whimboo: in our case with a tab when a content process in a tab. When the tab is unloaded there will not be a content process attached
<AutomatedTester> ack next
<jgraham> q+
<AutomatedTester> jrandolf: could you hellp me understand when this occurs
<AutomatedTester> ack next
<AutomatedTester> jgraham (IRC): in Firefox if you reload a session you will have tabs but they won't load any content until somene clicks on it
<jrandolf> q+
<AutomatedTester> ... but there are times where you want to tell a tab in automation to start loading by clicking on it
<AutomatedTester> ... there are some properties that are associated with the traversable from cache and other properties
<jrandolf> q+
<AutomatedTester> ... I think we need to file an issue on HTML and go speak to that group
<AutomatedTester> ack next
<jgraham> A related situation is mobile when background tabs might be automatically unloaded
<AutomatedTester> jrandolf: for context in chromium there are specific commands that don't work if the tab doesn't have focus
<AutomatedTester> ... but the tree is fully loaded
<jdescottes> q+
<AutomatedTester> q?
<AutomatedTester> ack next
<AutomatedTester> jdescottes: in CHromium there is memory saver which is very similar to what Firefox does in this case
<jrandolf> q+
<AutomatedTester> ack next
<AutomatedTester> jrandolf: that's good to know. I can see what you are after and we will look into this and get back to you. I agree with jgraham (IRC) we should raise an HTML Spec issue
<AutomatedTester> action: Raise issue against HTML for Support for unloaded tabs
whimboo commented 3 months ago

@jgraham would you mind to raise the issue against the HTML spec to support unloaded tabs? Thanks.