Bug 1052750 - Try to fix intermittent timeouts in browser urlbar search test by waiting for focus on the newly opened window. a=test-only
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 12 Aug 2014 15:13:00 +0100
changeset 217644 ef319e5ce14893e0028494da9fc9fcba40b2824e
parent 217643 439ceee39acb0805e0248f16a89a866800e7327c
child 217645 816ee2cae6a6d9c05e291fc29c5f43bbf084eb75
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstest-only
bugs1052750
milestone33.0a2
Bug 1052750 - Try to fix intermittent timeouts in browser urlbar search test by waiting for focus on the newly opened window. a=test-only
browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
--- a/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
+++ b/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
@@ -66,17 +66,25 @@ add_task(function* test_navigate_numbers
   let tab = gBrowser.selectedTab = gBrowser.addTab();
   yield* runURLBarSearchTest("1234", true, false);
   gBrowser.removeTab(tab);
 });
 
 function get_test_function_for_localhost_with_hostname(hostName, isPrivate) {
   return function* test_navigate_single_host() {
     const pref = "browser.fixup.domainwhitelist.localhost";
-    let win = isPrivate ? yield promiseOpenAndLoadWindow({private: true}, true) : window;
+    let win;
+    if (isPrivate) {
+      win = yield promiseOpenAndLoadWindow({private: true}, true);
+      let deferredOpenFocus = Promise.defer();
+      waitForFocus(deferredOpenFocus.resolve, win);
+      yield deferredOpenFocus.promise;
+    } else {
+      win = window;
+    }
     let browser = win.gBrowser;
     let tab = browser.selectedTab = browser.addTab();
 
     Services.prefs.setBoolPref(pref, false);
     yield* runURLBarSearchTest(hostName, true, true, win);
 
     let notificationBox = browser.getNotificationBox(tab.linkedBrowser);
     let notification = notificationBox.getNotificationWithValue("keyword-uri-fixup");
@@ -91,18 +99,20 @@ function get_test_function_for_localhost
     browser.removeTab(tab);
 
     // Now try again with the pref set.
     let tab = browser.selectedTab = browser.addTab();
     // In a private window, the notification should appear again.
     yield* runURLBarSearchTest(hostName, isPrivate, isPrivate, win);
     browser.removeTab(tab);
     if (isPrivate) {
+      info("Waiting for private window to close");
       yield promiseWindowClosed(win);
       let deferredFocus = Promise.defer();
+      info("Waiting for focus");
       waitForFocus(deferredFocus.resolve, window);
       yield deferredFocus.promise;
     }
   }
 }
 
 add_task(get_test_function_for_localhost_with_hostname("localhost"));
 add_task(get_test_function_for_localhost_with_hostname("localhost."));