Bug 1414563 - wait for context menu to open before poking its contents in test-content-tab.js. r=jorgk CLOSED TREE
authoraceman <acelists@atlas.sk>
Sat, 04 Nov 2017 16:41:00 +0100
changeset 29322 b5fb9c055e0e5a890f4515099bc3a967b76f4289
parent 29321 a7aa0ecabaddb286e6795b1d47fc33cd15622feb
child 29323 8ebc38529db6693b8b757a21471558b4eab3dd3a
push id2068
push userclokep@gmail.com
push dateMon, 13 Nov 2017 19:02:14 +0000
treeherdercomm-beta@9c7e7ce8672b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1414563
Bug 1414563 - wait for context menu to open before poking its contents in test-content-tab.js. r=jorgk CLOSED TREE
mail/test/mozmill/content-tabs/test-content-tab.js
mail/test/mozmill/shared-modules/test-folder-display-helpers.js
--- a/mail/test/mozmill/content-tabs/test-content-tab.js
+++ b/mail/test/mozmill/content-tabs/test-content-tab.js
@@ -1,59 +1,54 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var MODULE_NAME = 'test-content-tab';
 
 var RELATIVE_ROOT = '../shared-modules';
-var MODULE_REQUIRES = ['folder-display-helpers', 'content-tab-helpers'];
+var MODULE_REQUIRES = ['folder-display-helpers', 'content-tab-helpers',
+                       'dom-helpers', 'window-helpers'];
 
 var controller = {};
 Components.utils.import('resource://mozmill/modules/controller.js', controller);
 var mozmill = {};
 Components.utils.import('resource://mozmill/modules/mozmill.js', mozmill);
 var elementslib = {};
 Components.utils.import('resource://mozmill/modules/elementslib.js', elementslib);
 Components.utils.import('resource://gre/modules/Services.jsm');
 
 // RELATIVE_ROOT messes with the collector, so we have to bring the path back
 // so we get the right path for the resources.
 // Note: this one adds to '' as we need to make sure that favicon.ico is in the
 // root directory.
 var url = collector.addHttpResource('../content-tabs/html', '');
 var whatsUrl = url + "whatsnew.html";
 
-var setupModule = function (module) {
-  let fdh = collector.getModule('folder-display-helpers');
-  fdh.installInto(module);
-  let cth = collector.getModule('content-tab-helpers');
-  cth.installInto(module);
-  let dh = collector.getModule('dom-helpers');
-  dh.installInto(module);
-  let wh = collector.getModule('window-helpers');
-  wh.installInto(module);
-};
+function setupModule(module) {
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
+}
 
 function test_content_tab_open() {
   // Set the pref so that what's new opens a local url
   Services.prefs.setCharPref("mailnews.start_page.override_url", whatsUrl);
 
   let tab = open_content_tab_with_click(mc.menus.helpMenu.whatsNew, whatsUrl);
 
   assert_tab_has_title(tab, "What's New Content Test");
   // Check the location of the what's new image, this is via the link element
   // and therefore should be set and not favicon.png.
   assert_content_tab_has_favicon(tab, url + "whatsnew.png");
 
   // Check that window.content is set up correctly wrt content-primary and
   // content-targetable.
   if (mc.window.content.location != whatsUrl)
     throw new Error("window.content is not set to the url loaded, incorrect type=\"...\"?");
-
 }
 
 /**
  * Just make sure that the context menu does what we expect in content tabs wrt.
  * spell checking options.
  */
 function test_spellcheck_in_content_tabs() {
   let tabmail = mc.tabmail;
@@ -64,38 +59,42 @@ function test_spellcheck_in_content_tabs
   // Test a few random items
   mc.click(new elementslib.Elem(textarea));
   // Bug 364914 causes textareas to not be spell checked until they have been
   // focused at last once, so give the event loop a chance to spin.
   // Since bug 1370754 the inline spell checker waits 1 second, so let's
   // wait 2 seconds to be on the safe side.
   mc.sleep(2000);
   mc.rightClick(new elementslib.Elem(textarea));
+  wait_for_popup_to_open(eidMailContext.getNode());
   assert_element_visible("mailContext-spell-dictionaries");
   assert_element_visible("mailContext-spell-check-enabled");
   assert_element_not_visible("mailContext-replySender"); // we're in a content tab!
   close_popup(mc, eidMailContext);
 
   // Different test
   mc.rightClick(new elementslib.Elem(w.document.body.firstElementChild));
+  wait_for_popup_to_open(eidMailContext.getNode());
   assert_element_not_visible("mailContext-spell-dictionaries");
   assert_element_not_visible("mailContext-spell-check-enabled");
   close_popup(mc, eidMailContext);
 
   // Right-click on "zombocom" and add to dictionary
   EventUtils.synthesizeMouse(textarea, 5, 5,
                              {type: "contextmenu", button: 2}, w);
+  wait_for_popup_to_open(eidMailContext.getNode());
   let suggestions = mc.window.document.getElementsByClassName("spell-suggestion");
   assert_true(suggestions.length > 0, "What, is zombocom a registered word now?");
   mc.click(mc.eid("mailContext-spell-add-to-dictionary"));
   close_popup(mc, eidMailContext);
 
   // Now check we don't have any suggestionss
   EventUtils.synthesizeMouse(textarea, 5, 5,
                              {type: "contextmenu", button: 2}, w);
+  wait_for_popup_to_open(eidMailContext.getNode());
   suggestions = mc.window.document.getElementsByClassName("spell-suggestion");
   assert_true(suggestions.length == 0, "But I just taught you this word!");
   close_popup(mc, eidMailContext);
 }
 
 function test_content_tab_context_menu() {
   let tabmail = mc.tabmail;
   let w = tabmail.selectedTab.browser.contentWindow;
--- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
@@ -1417,17 +1417,17 @@ function delete_via_popup() {
   // for reasons unknown, the pop-up does not close itself?
   close_popup(mc, mc.eid("mailContext"));
   wait_for_folder_events();
 }
 
 function wait_for_popup_to_open(popupElem) {
   mark_action("fdh", "wait_for_popup_to_open", [popupElem]);
   utils.waitFor(() => popupElem.state == "open",
-                "Timeout waiting for popup to open", 1000, 50);
+                "Timeout waiting for popup to open, state=" + popupElem.state, 1000, 50);
 }
 
 /**
  * Close the open pop-up.
  */
 function close_popup(aController, eid) {
   if (aController == null)
     aController = mc;