(In reply to James Teh [:Jamie] from comment #31)
Gijs, might you have some thoughts on comment 30 or be able to redirect me to someone that might? This bug seems pretty nasty to me, so I'd like to have a path forward sooner rather than later. Thanks.
I'm not sure I really follow, unfortunately. Some questions inline to help clarify:
(In reply to James Teh [:Jamie] from comment #30)
Urgh. This is nasty.
Bug 493683 introduced a change that causes a11y to request the LABEL_FOR relation when building the a11y tree. For XUL tabs (the basis for browser tabs), this ends up calling nsIDOMXULRelatedElement::getRelatedElement.
OK, but why? The tabs have their own labels. What's the "point" of calling GetRelatedElement? I found https://searchfox.org/mozilla-central/rev/e08a9aa5c5dfb77e8847ab7af3f753a9c3e551f8/accessible/xul/XULTabAccessible.cpp#100 but that doesn't really tell me what this
LABEL_FOR relation is, or why we need it.
Unfortunately, it turns out that browser tabs override getRelatedElement to insert the browser. (This was done in bug 1287330.) The practical upshot is that when the a11y tree gets built, all the tabs get loaded. 😟 This also explains why tab documents get inserted as a result of that call, which was triggering bug 1689936 (since fixed).
I'm not entirely sure how to fix this. A11y does need to be able to figure out what tab labels a given tab panel, but we certainly don't want the tab panel to be created when we query that. AsyncTabSwitcher uses getRelatedElement, so we can't change that.
It's a bit of a hack, but maybe we can set some attribute on browser tabs that are disconnected? A11y could query that attribute and avoid calling getRelatedElement if the attribute is set. I don't think we can use the "pending" attribute because I think that is set by SessionStore, so I'm guessing it might not be set on tabs discarded after restore?
Note that whatever solution we come up with needs to work for all XUL tabs, since a11y doesn't know whether it's a browser tab or another kind of XUL tab. For example, I considered querying the linkedpanel attribute, but it seems XUL tabs might not have that attribute and might fall back to matching indexes.
Dao, do you have any recommendations here (or can you point me to someone who might)?
I mean, from a very quick look, it looks like besides the a11y callers, there are only 2 callers of
getRelatedElement, and both are for tabs that are supposed to be selected. So we can either update
getRelatedElement to return null if the tab is not selected, or, if there's some reason I'm missing that that doesn't work, introduce a different method either for the a11y code or for those 2 consumers to split the expectations (of inserting the panel, or not doing so).