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
authorMike de Boer <mdeboer@mozilla.com>
Fri, 01 Apr 2016 10:57:46 +0200
changeset 291369 43ee605bf4666503c19e2b5a27972e8cd4a307aa
parent 291368 5fbd6d5079f498694e20506054759c867b30a622
child 291370 7dd46c214c299c5ccca96f3ee6402af1a6429c35
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1244991
milestone48.0a1
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
browser/components/uitour/test/browser_backgroundTab.js
--- a/browser/components/uitour/test/browser.ini
+++ b/browser/components/uitour/test/browser.ini
@@ -1,17 +1,16 @@
 [DEFAULT]
 support-files =
   head.js
   image.png
   uitour.html
   ../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
 [browser_no_tabs.js]
 [browser_openPreferences.js]
 [browser_openSearchPanel.js]
 skip-if = true # Bug 1113038 - Intermittent "Popup was opened"
 [browser_trackingProtection.js]
--- a/browser/components/uitour/test/browser_backgroundTab.js
+++ b/browser/components/uitour/test/browser_backgroundTab.js
@@ -2,33 +2,45 @@
 
 var gTestTab;
 var gContentAPI;
 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();
   let data = yield getConfigurationPromise("availableTargets");
   ok(data, "Got data from getConfiguration");
   yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 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"));
 
   yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 
 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");
 }