Bug 802575 - Follow-up - make menubar tests wait for mail startup to complete. r=Standard8 for CLOSED TREE.
authorMike Conley <mconley@mozilla.com>
Wed, 24 Oct 2012 13:38:43 -0400
changeset 12660 ce1bbebaef2002a6413c3ebc5bd63d6ba889467a
parent 12659 5ba465f0c7f0387ac7613f1c0152674ac5faf3d6
child 12661 58766ab57d3df7d3bfc8a2ad24446bea66eb3cac
push id796
push userbugzilla@standard8.plus.com
push dateMon, 19 Nov 2012 22:27:00 +0000
treeherdercomm-aurora@c16a2db13b6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs802575
Bug 802575 - Follow-up - make menubar tests wait for mail startup to complete. r=Standard8 for CLOSED TREE.
mail/test/mozmill/override-main-menu-collapse/test-override-mainmenu-collapse.js
mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js
--- a/mail/test/mozmill/override-main-menu-collapse/test-override-mainmenu-collapse.js
+++ b/mail/test/mozmill/override-main-menu-collapse/test-override-mainmenu-collapse.js
@@ -5,20 +5,47 @@
 /**
  * Tests that the main menu will NOT be collapsed by default if Thunderbird
  * starts with no accounts created, and mail.main_menu.collapse_by_default set
  * to false.
  */
 
 let MODULE_NAME = "test-override-main-menu-collapse";
 let RELATIVE_ROOT = "../shared-modules";
-let MODULE_REQUIRES = ["folder-display-helpers"];
+let MODULE_REQUIRES = ["folder-display-helpers",
+                       "window-helpers"];
+
+Cu.import("resource://gre/modules/Services.jsm");
 
 function setupModule(module) {
   collector.getModule("folder-display-helpers").installInto(module);
+  collector.getModule("window-helpers").installInto(module);
 }
 
 function test_main_menu_not_collapsed() {
+  // Due to random oranges on slower machines, we need to ensure that startup
+  // is complete before running this test.
+  let done = false;
+  let observer = {
+    observe: function(aSubject, aTopic, aData) {
+      if (aTopic == "mail-startup-done") {
+        done = true;
+      }
+    }
+  };
+  Services.obs.addObserver(observer, "mail-startup-done", false);
+
+  // Since no accounts were set up, and the account provisoner was disabled
+  // in prefs.js, the wizard will show up. Find it, and close it. This will
+  // cause mail-startup-done to eventually be fired.
+  let wizard = wait_for_existing_window("mail:autoconfig");
+  close_window(wizard);
+
+  // Spin the event loop until mail-startup-done is fired.
+  mc.waitFor(function () done);
+
   let mainMenu = mc.e("mail-toolbar-menubar2");
   assert_false(mainMenu.hasAttribute("autohide"),
                "The main menu should not have the autohide attribute.");
+
+  Services.obs.removeObserver(observer, "mail-startup-done");
 }
 test_main_menu_not_collapsed.EXCLUDED_PLATFORMS = ["Darwin"];
--- a/mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js
+++ b/mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js
@@ -4,20 +4,45 @@
 
 /**
  * Tests that the main menu will be collapsed by default if Thunderbird starts
  * with no accounts created.
  */
 
 let MODULE_NAME = "test-main-menu-collapsed";
 let RELATIVE_ROOT = "../shared-modules";
-let MODULE_REQUIRES = ["folder-display-helpers"];
+let MODULE_REQUIRES = ["folder-display-helpers",
+                       "window-helpers"];
 
 function setupModule(module) {
   collector.getModule("folder-display-helpers").installInto(module);
+  collector.getModule("window-helpers").installInto(module);
 }
 
 function test_main_menu_collapsed() {
+  // Due to random oranges on slower machines, we need to ensure that startup
+  // is complete before running this test.
+  let done = false;
+  let observer = {
+    observe: function(aSubject, aTopic, aData) {
+      if (aTopic == "mail-startup-done") {
+        done = true;
+      }
+    }
+  };
+  Services.obs.addObserver(observer, "mail-startup-done", false);
+
+  // Since no accounts were set up, and the account provisoner was disabled
+  // in prefs.js, the wizard will show up. Find it, and close it. This will
+  // cause mail-startup-done to eventually be fired.
+  let wizard = wait_for_existing_window("mail:autoconfig");
+  close_window(wizard);
+
+  // Spin the event loop until mail-startup-done is fired.
+  mc.waitFor(function () done);
+
   let mainMenu = mc.e("mail-toolbar-menubar2");
   assert_equals(mainMenu.getAttribute("autohide"), "true",
                 "The main menu should have the autohide attribute set to true.");
+
+  Services.obs.removeObserver(observer, "mail-startup-done");
 }
 test_main_menu_collapsed.EXCLUDED_PLATFORMS = ["Darwin"];