Bug 1553384, fix intermittent orange caused by fission changes, by waiting for page and findbar to be ready
authorNeil Deakin <neil@mozilla.com>
Wed, 18 Sep 2019 09:33:52 +0000
changeset 493766 e33c3e14ee40f88d1775952e309dc2a617eb97f7
parent 493765 656e05faba49669bba146c73e0db98d4cacb6caf
child 493767 43ea73f1db1a64cf4f2fb94a1f8accaf3a8e38cd
push id36589
push usernerli@mozilla.com
push dateWed, 18 Sep 2019 21:49:27 +0000
treeherdermozilla-central@21aff209f5a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1553384
milestone71.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 1553384, fix intermittent orange caused by fission changes, by waiting for page and findbar to be ready Differential Revision: https://phabricator.services.mozilla.com/D46239
toolkit/content/tests/chrome/bug360437_window.xul
--- a/toolkit/content/tests/chrome/bug360437_window.xul
+++ b/toolkit/content/tests/chrome/bug360437_window.xul
@@ -40,52 +40,56 @@
         SimpleTest.finish();
       });
     }
 
     async function startTestWithBrowser(browserId) {
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
       gFindBar.browser = gBrowser;
-      let promise = ContentTask.spawn(gBrowser, null, async function() {
+
+      let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser);
+      let contentLoadedPromise = ContentTask.spawn(gBrowser, null, async function() {
         return new Promise(resolve => {
           addEventListener("DOMContentLoaded", function listener() {
             removeEventListener("DOMContentLoaded", listener);
             resolve();
           });
         });
       });
       BrowserTestUtils.loadURI(gBrowser, "data:text/html,<form><input id='input' type='text' value='text inside an input element'></form>");
-      await promise;
-      await onDocumentLoaded();
-    }
+      await loadedPromise;
+      await contentLoadedPromise;
 
-    async function onDocumentLoaded() {
       gFindBar.onFindCommand();
 
       // Make sure the findfield is correctly focused on open
       var searchStr = "text inside an input element";
       await promiseEnterStringIntoFindField(searchStr);
       is(document.commandDispatcher.focusedElement,
          gFindBar._findField, "Find field isn't focused");
 
       // Make sure "find again" correctly transfers focus to the content element
       // when the find bar is closed.
-      gFindBar.close();
+      await new Promise(resolve => {
+        window.addEventListener("findbarclose", resolve, { once: true });
+        gFindBar.close();
+      });
       gFindBar.onFindAgainCommand(false);
       await ContentTask.spawn(gBrowser, null, async function() {
         Assert.equal(content.document.activeElement,
          content.document.getElementById("input"), "Input Element isn't focused");
       });
 
       // Make sure "find again" doesn't focus the content element if focus
       // isn't in the content document.
       var textbox = document.getElementById("textbox");
       textbox.focus();
-      gFindBar.close();
+
+      ok(gFindBar.hidden, "Findbar is hidden");
       gFindBar.onFindAgainCommand(false);
       ok(textbox.hasAttribute("focused"),
          "Focus was stolen from a chrome element");
     }
 
     function promiseFindResult(str = null) {
       return new Promise(resolve => {
         let listener = {