Bug 1700546: Fire a reorder event when a top level remote document is added. r=morgan

When a local document is added, we fire a reorder event in DocAccessible::DoInitialUpdate.
This doesn't work for top level documents in remote content processes because the embedder (OuterDocAccessible) is in a different process.
We already handled this for out-of-process iframe documents in DocAccessibleChild::AddChildDoc.
However, there was no code to do this for a top level remote document.
This wasn't a problem for users for normal browser tabs, since clients only interact with the document when it gets focus.
It was problematic for <browser> elements embedded in a parent process content document, since some clients need the event in order to pick up the embedded content.
Therefore, we now fire this event in DocManager::RemoteDocAdded.

This patch re-enables browser_test_docload.js, which is intended to test this.
This test was ported in bug 1376857 before we shipped e10s.
It didn't work with e10s at the time, so it was disabled there, but this was never fixed.
That meant that once e10s shipped, this test was disabled completely.

I had to change the test's expectations slightly, since we do fire document load complete and state change events for remote iframe documents, but the test asserted that we don't.
Although we originally didn't fire these events many years ago, this has been broken for a long time now and it doesn't really make sense to reinstate that behaviour; see bug 1700362.

Differential Revision: https://phabricator.services.mozilla.com/D244687
This commit is contained in:
James Teh
2025-04-10 00:53:14 +00:00
parent bd6cf1706c
commit a40b16b3b2
3 changed files with 15 additions and 13 deletions

View File

@@ -554,6 +554,7 @@ void DocManager::ClearDocCache() {
} }
void DocManager::RemoteDocAdded(DocAccessibleParent* aDoc) { void DocManager::RemoteDocAdded(DocAccessibleParent* aDoc) {
MOZ_ASSERT(aDoc->IsTopLevel());
if (!sRemoteDocuments) { if (!sRemoteDocuments) {
sRemoteDocuments = new nsTArray<DocAccessibleParent*>; sRemoteDocuments = new nsTArray<DocAccessibleParent*>;
ClearOnShutdown(&sRemoteDocuments); ClearOnShutdown(&sRemoteDocuments);
@@ -563,6 +564,12 @@ void DocManager::RemoteDocAdded(DocAccessibleParent* aDoc) {
"How did we already have the doc!"); "How did we already have the doc!");
sRemoteDocuments->AppendElement(aDoc); sRemoteDocuments->AppendElement(aDoc);
ProxyCreated(aDoc); ProxyCreated(aDoc);
// Fire a reorder event on the OuterDocAccessible.
if (LocalAccessible* outerDoc = aDoc->OuterDocOfRemoteBrowser()) {
MOZ_ASSERT(outerDoc->Document());
RefPtr<AccReorderEvent> reorder = new AccReorderEvent(outerDoc);
outerDoc->Document()->FireDelayedEvent(reorder);
}
} }
DocAccessible* mozilla::a11y::GetExistingDocAccessible( DocAccessible* mozilla::a11y::GetExistingDocAccessible(

View File

@@ -19,7 +19,6 @@ support-files = [
["browser_test_caret_move_granularity.js"] ["browser_test_caret_move_granularity.js"]
["browser_test_docload.js"] ["browser_test_docload.js"]
skip-if = ["true"]
["browser_test_focus_browserui.js"] ["browser_test_focus_browserui.js"]

View File

@@ -31,17 +31,13 @@ function urlChecker(url) {
} }
async function runTests(browser) { async function runTests(browser) {
let onLoadEvents = waitForEvents({ let onLoadEvents = waitForEvents([
expected: [ [EVENT_REORDER, getAccessible(browser)],
[EVENT_REORDER, getAccessible(browser)], [EVENT_DOCUMENT_LOAD_COMPLETE, "body2"],
[EVENT_DOCUMENT_LOAD_COMPLETE, "body2"], [EVENT_STATE_CHANGE, busyChecker(false)],
[EVENT_STATE_CHANGE, busyChecker(false)], [EVENT_DOCUMENT_LOAD_COMPLETE, inIframeChecker("iframe1")],
], [EVENT_STATE_CHANGE, inIframeChecker("iframe1")],
unexpected: [ ]);
[EVENT_DOCUMENT_LOAD_COMPLETE, inIframeChecker("iframe1")],
[EVENT_STATE_CHANGE, inIframeChecker("iframe1")],
],
});
BrowserTestUtils.startLoadingURIString( BrowserTestUtils.startLoadingURIString(
browser, browser,
@@ -123,6 +119,6 @@ async function runTests(browser) {
} }
/** /**
* Test caching of accessible object states * Test events when a document loads.
*/ */
addAccessibleTask("", runTests); addAccessibleTask("", runTests);