Bug 1321376 - Make browser_selectpopup.js wait for SelectContentHelper to think that the popup in the parent has closed when hiding popups. r?Enn draft
authorMike Conley <mconley@mozilla.com>
Mon, 28 Nov 2016 16:07:41 -0800
changeset 451176 9e2fe5751f1148748d1bc5e9b0ed0a9b6ab3e311
parent 451175 d4b9ac0b6c1987ba3a8bff1efe48adeb61615805
child 539949 7d0d4911bdadc4ca10fbe38827a3d078211cf155
push id39077
push usermconley@mozilla.com
push dateMon, 19 Dec 2016 21:16:52 +0000
reviewersEnn
bugs1321376
milestone53.0a1
Bug 1321376 - Make browser_selectpopup.js wait for SelectContentHelper to think that the popup in the parent has closed when hiding popups. r?Enn This is because in single-process mode, key events might be handled before messages. MozReview-Commit-ID: 7Kpq1N0TjCu
browser/base/content/test/general/browser_selectpopup.js
--- a/browser/base/content/test/general/browser_selectpopup.js
+++ b/browser/base/content/test/general/browser_selectpopup.js
@@ -74,29 +74,33 @@ function openSelectPopup(selectPopup, wi
   }
 
   EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true, code: "ArrowDown" }, win);
   return popupShownPromise;
 }
 
 function hideSelectPopup(selectPopup, mode = "enter", win = window)
 {
-  let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden");
+  let browser = win.gBrowser.selectedBrowser;
+  let selectClosedPromise = ContentTask.spawn(browser, null, function*() {
+    Cu.import("resource://gre/modules/SelectContentHelper.jsm");
+    return ContentTaskUtils.waitForCondition(() => !SelectContentHelper.open);
+  });
 
   if (mode == "escape") {
     EventUtils.synthesizeKey("KEY_Escape", { code: "Escape" }, win);
   }
   else if (mode == "enter") {
     EventUtils.synthesizeKey("KEY_Enter", { code: "Enter" }, win);
   }
   else if (mode == "click") {
     EventUtils.synthesizeMouseAtCenter(selectPopup.lastChild, { }, win);
   }
 
-  return popupHiddenPromise;
+  return selectClosedPromise;
 }
 
 function getInputEvents()
 {
   return ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     return content.wrappedJSObject.gInputEvents;
   });
 }
@@ -554,8 +558,9 @@ add_task(function* test_somehidden() {
     is(getComputedStyle(child).display, child.label.indexOf("Visible") > 0 ? "-moz-box" : "none",
        "Item " + (idx++) + " is visible");
     child = child.nextSibling;
   }
 
   yield hideSelectPopup(selectPopup, "escape");
   yield BrowserTestUtils.removeTab(tab);
 });
+