Bug 710912 - Fix Mozmill test bustage on Linux caused by Bug 700536. r=bwinton.
authorMike Conley <mconley@mozilla.com>
Thu, 15 Dec 2011 10:19:35 -0500
changeset 8987 a3bfe58a7e428f60ad6907d4a765d7717d88b3fc
parent 8986 2368d15d14bee2532a1db202c5fc85fc4bc15e91
child 8988 20b6eae32a23695533f2ba4314621576f35ee198
push id6891
push usermconley@mozilla.com
push dateThu, 15 Dec 2011 15:19:47 +0000
treeherdercomm-central@a3bfe58a7e42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwinton
bugs710912, 700536
Bug 710912 - Fix Mozmill test bustage on Linux caused by Bug 700536. r=bwinton.
mail/test/mozmill/newmailaccount/test-newmailaccount.js
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ b/mail/test/mozmill/newmailaccount/test-newmailaccount.js
@@ -798,62 +798,76 @@ function subtest_search_button_disabled_
  * The tests in this file will fail if the Account Provisioner does not spawn
  * with no accounts, and when preffed off, if the Account Provisioner does
  * spawn (which it shouldn't), the instrumentation Mozmill test should fail.
  */
 function test_can_pref_off_account_provisioner() {
   // First, we'll disable the account provisioner.
   Services.prefs.setBoolPref("mail.provider.enabled", false);
 
-  let fileMenuitem = mc.eid("menu_File");
-  let newMenuitem = mc.eid("menu_New");
-  let fileMenuPopup = mc.eid("menu_FilePopup");
+  // We'll use the Mozmill Menu API to grab the main menu...
+  let mailMenuBar = mc.getMenu("#mail-menubar");
+  let newMenuPopup = mc.eid("menu_NewPopup");
   let newMailAccountMenuitem = mc.eid("newMailAccountMenuItem");
 
+  // First, we do some hackery to allow the "New" menupopup to respond to
+  // events...
+  let oldAllowEvents = newMenuPopup.getNode().allowevents;
+  newMenuPopup.getNode().allowevents = true;
+
+  // And then call open on the menu.  This doesn't actually open the menu
+  // on screen, but it simulates the act, and dynamically generated or
+  // modified menuitems react accordingly.  Simulating this helps us sidestep
+  // weird platform issues.
+  mailMenuBar.open();
+
   // Next, we'll ensure that the "Get a new mail account"
   // menuitem is no longer available
-  mc.click(fileMenuitem);
-  mc.click(newMenuitem);
-
   mc.waitFor(function() {
     return mc.eid("newCreateEmailAccountMenuItem").getNode().hidden;
   }, "Timed out waiting for the Account Provisioner menuitem to be hidden");
 
   // Open up the Existing Account wizard
   plan_for_new_window("mail:autoconfig");
   mc.click(newMailAccountMenuitem);
 
   // Ensure that the existing email account wizard opened.
   let wizard = wait_for_new_window("mail:autoconfig");
+
+  // And make sure the Get a New Account button is hidden.
   assert_true(wizard.eid("provisioner_button").getNode().hidden);
 
+  // Alright, close the Wizard.
   plan_for_window_close(wizard);
   close_window(wizard);
   wait_for_window_close();
 
-  // We have to make sure the File menu popup is closed, or else we get weird
-  // behaviour on Linux
-  close_popup(mc, fileMenuPopup);
-
-  // Ok, now pref it back on
+  // Ok, now pref the Account Provisioner back on
   Services.prefs.setBoolPref("mail.provider.enabled", true);
 
-  // Next, we'll ensure that the "Get a new mail account"
-  // menuitem is available
-  mc.click(fileMenuitem);
-  mc.click(newMenuitem);
+  // Re-open the menu to repopulate it.
+  mailMenuBar.open();
 
+  // Make sure that the "Get a new mail account" menuitem is NOT hidden.
   mc.waitFor(function() {
     return !mc.eid("newCreateEmailAccountMenuItem").getNode().hidden;
   }, "Timed out waiting for the Account Provisioner menuitem to appear");
 
   // Open up the Existing Account wizard
   plan_for_new_window("mail:autoconfig");
   mc.click(newMailAccountMenuitem);
 
   // Ensure that the existing email account wizard opened.
   let wizard = wait_for_new_window("mail:autoconfig");
+
+  // Make sure that the button to open the Account Provisioner dialog is
+  // NOT hidden.
   assert_false(wizard.eid("provisioner_button").getNode().hidden);
+
+  // Alright, close up.
   close_window(wizard);
+
+  // And finally restore the menu to the way it was.
+  newMenuPopup.getNode().allowevents = oldAllowEvents;
 }
 
 // We cannot control menus via Mozmill in OSX, so we'll skip this test.
 test_can_pref_off_account_provisioner.EXCLUDED_PLATFORMS = ['darwin'];