Bug 1596918: Part 4f - Fix callers which have timing issues. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D53747

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kris Maglione 2019-12-06 22:15:31 +00:00
parent 41c61c2bb9
commit 7f21292ff1
4 changed files with 16 additions and 12 deletions

View File

@ -161,9 +161,10 @@ function promiseTabLoadEvent(tab, url) {
* Wait for the search engine to change. * Wait for the search engine to change.
*/ */
function promiseContentSearchChange(browser, newEngineName) { function promiseContentSearchChange(browser, newEngineName) {
return SpecialPowers.spawn(browser, [{ newEngineName }], async function( // Callers of this depend on very specific, very racy timing, and fail
args // if we introduce the trip through SpecialPowersParent that
) { // SpecialPowers.spawn requires.
return ContentTask.spawn(browser, { newEngineName }, async function(args) {
return new Promise(resolve => { return new Promise(resolve => {
content.addEventListener("ContentSearchService", function listener( content.addEventListener("ContentSearchService", function listener(
aEvent aEvent

View File

@ -175,12 +175,13 @@ add_task(async function check_permission_state_change() {
gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen); gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen);
// Check if a popup opens. // Check if a popup opens.
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async () => { await Promise.all([
let open = content.document.getElementById("pop"); SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
open.click(); let open = content.document.getElementById("pop");
}); open.click();
}),
await BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen"); BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen"),
]);
await BrowserTestUtils.waitForCondition( await BrowserTestUtils.waitForCondition(
() => popup.linkedBrowser.currentURI.spec != "about:blank" () => popup.linkedBrowser.currentURI.spec != "about:blank"
); );

View File

@ -385,7 +385,7 @@ add_task(async function() {
await openSiteDataSettingsDialog(); await openSiteDataSettingsDialog();
SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() { await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
let frameDoc = content.gSubDialog._topDialog._frame.contentDocument; let frameDoc = content.gSubDialog._topDialog._frame.contentDocument;
let siteItems = frameDoc.getElementsByTagName("richlistitem"); let siteItems = frameDoc.getElementsByTagName("richlistitem");

View File

@ -37,8 +37,10 @@ add_task(async function() {
// Click the link in file_bug1554070_2.html. It should open example.org in // Click the link in file_bug1554070_2.html. It should open example.org in
// a new tab. // a new tab.
await click(); await Promise.all([
await BrowserTestUtils.waitForNewTab(gBrowser, URL2, true); click(),
BrowserTestUtils.waitForNewTab(gBrowser, URL2, true),
]);
is(gBrowser.tabs.length, 3, "got new tab"); is(gBrowser.tabs.length, 3, "got new tab");
is(gBrowser.currentURI.spec, URL2, "loaded example.org"); is(gBrowser.currentURI.spec, URL2, "loaded example.org");