diff --git a/accessible/tests/browser/states/browser_offscreen_element_in_out_of_process_iframe.js b/accessible/tests/browser/states/browser_offscreen_element_in_out_of_process_iframe.js index 2d1f3aabb576..289d3fec9a81 100644 --- a/accessible/tests/browser/states/browser_offscreen_element_in_out_of_process_iframe.js +++ b/accessible/tests/browser/states/browser_offscreen_element_in_out_of_process_iframe.js @@ -57,7 +57,7 @@ add_task(async function() { // Setup an out-of-process iframe which is initially scrolled out. const iframe = await SpecialPowers.spawn(browser, [iframeURL], setup); - await waitForIFrameUpdates(); + await waitForIFrameA11yReady(iframe); await spawnTestStates( iframe, "target", diff --git a/accessible/tests/browser/states/head.js b/accessible/tests/browser/states/head.js index 0a51d1502eef..9f428dce4f11 100644 --- a/accessible/tests/browser/states/head.js +++ b/accessible/tests/browser/states/head.js @@ -4,7 +4,7 @@ "use strict"; -/* exported waitForIFrameUpdates, spawnTestStates */ +/* exported waitForIFrameA11yReady, waitForIFrameUpdates, spawnTestStates */ // Load the shared-head file first. /* import-globals-from ../shared-head.js */ @@ -20,6 +20,35 @@ loadScripts( { name: "promisified-events.js", dir: MOCHITESTS_DIR } ); +// This is another version of addA11yLoadEvent for fission. +async function waitForIFrameA11yReady(iFrameBrowsingContext) { + async function waitForReady() { + new Promise(resolve => { + function waitForDocLoad() { + SpecialPowers.executeSoon(() => { + const acc = SpecialPowers.Cc[ + "@mozilla.org/accessibilityService;1" + ].getService(SpecialPowers.Ci.nsIAccessibilityService); + + const accDoc = acc.getAccessibleFor(content.document); + let state = {}; + accDoc.getState(state, {}); + if (state.value & SpecialPowers.Ci.nsIAccessibleStates.STATE_BUSY) { + SpecialPowers.executeSoon(waitForDocLoad); + return; + } + resolve(); + }, 0); + } + waitForDocLoad(); + }); + } + + await SimpleTest.promiseFocus(window); + + await SpecialPowers.spawn(iFrameBrowsingContext, [], waitForReady); +} + // A utility function to make sure the information of scroll position or visible // area changes reach to out-of-process iframes. async function waitForIFrameUpdates() {