From 15dc2228b60a69826cf52d19c68fe911742d2fc4 Mon Sep 17 00:00:00 2001 From: Ed Lee Date: Thu, 10 Aug 2017 10:41:19 -0700 Subject: [PATCH] Bug 1335057 - Fix intermittent bug1058164.js test timed out by conditionally waiting. r=mconley MozReview-Commit-ID: LRhV0IbHt5b --HG-- extra : rebase_source : f5d92a9d179aeca6f206a8a5bca98b0fe767b1c7 --- dom/base/test/browser_bug1058164.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/dom/base/test/browser_bug1058164.js b/dom/base/test/browser_bug1058164.js index 9da9dbebd0cb..54f2740b42b3 100644 --- a/dom/base/test/browser_bug1058164.js +++ b/dom/base/test/browser_bug1058164.js @@ -82,17 +82,13 @@ add_task(async function test_swap_frameloader_pagevisibility_events() { gBrowser.selectedTab = newTab; let emptyBrowser = newTab.linkedBrowser; - // Wait for that initial browser to show its pageshow event so that we - // don't confuse it with the other expected events. Note that we can't - // use BrowserTestUtils.waitForEvent here because we're using the - // e10s add-on shims in the e10s-case. I'm doing this because I couldn't - // find a way of sending down a frame script to the newly opened windows - // and tabs fast enough to attach the event handlers before they were - // fired. - await new Promise((resolve) => { - emptyBrowser.addEventListener("pageshow", function() { - resolve(); - }, {once: true}); + // Wait for that initial browser to show its pageshow event if it hasn't + // happened so that we don't confuse it with the other expected events. + await ContentTask.spawn(emptyBrowser, {}, async() => { + if (content.document.visibilityState === "hidden") { + info("waiting for hidden emptyBrowser to pageshow"); + await ContentTaskUtils.waitForEvent(content, "pageshow"); + } }); // The empty tab we just added show now fire a pagehide as its replaced,