Bug 1321376 - Make browser_selectpopup.js wait for SelectContentHelper to think that the popup in the parent has closed when hiding popups. r=enndeakin+6102
authorMike Conley <mconley@mozilla.com>
Mon, 28 Nov 2016 16:07:41 -0800
changeset 326458 cf1a77997e44ff7aa0fcdc18f4a0e687a926f02c
parent 326457 4f21a85561900253d4b91696f331c294e1732926
child 326459 4bd7d95379f640887531f12ecacec9c137c39ac0
push id31105
push userkwierso@gmail.com
push dateTue, 20 Dec 2016 19:35:18 +0000
treeherdermozilla-central@0f3603e365f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs1321376
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1321376 - Make browser_selectpopup.js wait for SelectContentHelper to think that the popup in the parent has closed when hiding popups. r=enndeakin+6102 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);
 });
+