From 2f92671a5a8485c0deb9847cdf407c4ef556a02a Mon Sep 17 00:00:00 2001 From: Mike de Boer Date: Fri, 1 Apr 2016 10:57:46 +0200 Subject: [PATCH] Bug 1244991: re-enable browser_backgroundTab.js UITour test and to make sure it doesn't fail on slower hardware, wait for the visibilitychange event explicitly since it may occur later than the tab open and switch. r=MattN --- browser/components/uitour/test/browser.ini | 1 - .../uitour/test/browser_backgroundTab.js | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/browser/components/uitour/test/browser.ini b/browser/components/uitour/test/browser.ini index 0d2308f2d65c..a755ca07d0c6 100644 --- a/browser/components/uitour/test/browser.ini +++ b/browser/components/uitour/test/browser.ini @@ -6,7 +6,6 @@ support-files = ../UITour-lib.js [browser_backgroundTab.js] -skip-if = e10s # Intermittent failures, bug 1244991 [browser_closeTab.js] [browser_fxa.js] skip-if = debug || asan # updateAppMenuItem leaks diff --git a/browser/components/uitour/test/browser_backgroundTab.js b/browser/components/uitour/test/browser_backgroundTab.js index ec2d0c2fa547..c4117c698a3c 100644 --- a/browser/components/uitour/test/browser_backgroundTab.js +++ b/browser/components/uitour/test/browser_backgroundTab.js @@ -7,7 +7,6 @@ var gContentWindow; requestLongerTimeout(2); add_task(setup_UITourTest); - add_UITour_task(function* test_bg_getConfiguration() { info("getConfiguration is on the allowed list so should work"); yield* loadForegroundTab(); @@ -20,7 +19,7 @@ add_UITour_task(function* test_bg_showInfo() { info("showInfo isn't on the allowed action list so should be denied"); yield* loadForegroundTab(); - yield showInfoPromise("appMenu", "Hello from the backgrund", "Surprise!").then( + yield showInfoPromise("appMenu", "Hello from the background", "Surprise!").then( () => ok(false, "panel shouldn't have shown from a background tab"), () => ok(true, "panel wasn't shown from a background tab")); @@ -29,6 +28,19 @@ add_UITour_task(function* test_bg_showInfo() { function* loadForegroundTab() { + // Spawn a content task that resolves once we're sure the visibilityState was + // changed. This state is what the tests in this file rely on. + let promise = ContentTask.spawn(gBrowser.selectedTab.linkedBrowser, null, function* () { + return new Promise(resolve => { + let document = content.document; + document.addEventListener("visibilitychange", function onStateChange() { + Assert.equal(document.visibilityState, "hidden", "UITour page should be hidden now."); + document.removeEventListener("visibilitychange", onStateChange); + resolve(); + }); + }); + }); yield BrowserTestUtils.openNewForegroundTab(gBrowser); + yield promise; isnot(gBrowser.selectedTab, gTestTab, "Make sure tour tab isn't selected"); }