Bug 1607624 draft fission-unselectedtabhover-1607624
authorBernard Igiri <bigiri@mozilla.com>
Fri, 07 Feb 2020 14:43:56 -0500
branchfission-unselectedtabhover-1607624
changeset 2630427 50614c19f04b141b451754da57f43d1274242427
parent 2630426 05534472f34ccd4ab10884dee6e6be6aaeacd6f5
child 2630428 5f9468fc706f2a0b198755a63ddfb503ba94b3c2
child 2635908 3fd8fd4ec37f5d8a8ac3e79cfc71c28b7b1bf451
child 3743843 e3ed26447ea22f8c9d9855862f85d9fbc97e7d56
push id485721
push userbigiri@mozilla.com
push dateTue, 11 Feb 2020 16:38:02 +0000
treeherdertry@5f9468fc706f [default view] [failures only]
bugs1607624
milestone74.0a1
Bug 1607624 Fixed test. Differential Revision: https://phabricator.services.mozilla.com/D62098
toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js
--- a/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js
+++ b/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js
@@ -27,62 +27,40 @@ async function check_video_decoding_stat
         ok(true, `Video decoding is ${state}.`);
         resolve();
       },
       { once: true }
     );
   });
 }
 
-function check_should_send_unselected_tab_hover_msg(browser) {
-  if (browser.shouldHandleUnselectedTabHover) {
-    ok(
-      true,
-      "Should send unselected tab hover msg, someone is listening for it."
-    );
-    return true;
-  }
-
+async function check_should_send_unselected_tab_hover_msg(browser) {
   info("did not update the value now, wait until it changes.");
-  return new Promise(resolve => {
-    browser.messageManager.addMessageListener(
-      "UnselectedTabHoverMsg:Enabled",
-      function() {
-        ok(
-          true,
-          "Should send unselected tab hover msg, someone is listening for it."
-        );
-        resolve();
-      }
-    );
-  });
+  return BrowserTestUtils.waitForCondition(
+    () => browser.shouldHandleUnselectedTabHover,
+    "Should send unselected tab hover msg, someone is listening for it."
+  );
 }
 
-function check_should_not_send_unselected_tab_hover_msg(browser) {
-  if (!browser.shouldHandleUnselectedTabHover) {
-    ok(
-      true,
-      "Should not send unselected tab hover msg, no one is listening for it."
-    );
-    return true;
-  }
-
+async function check_should_not_send_unselected_tab_hover_msg(browser) {
   info("did not update the value now, wait until it changes.");
-  return new Promise(resolve => {
-    browser.messageManager.addMessageListener(
-      "UnselectedTabHoverMsg:Disabled",
-      function() {
-        ok(
-          true,
-          "Should not send unselected tab hover msg, no one is listening for it."
-        );
-        resolve();
-      }
-    );
-  });
+  let timedout = false;
+  return BrowserTestUtils.waitForCondition(
+    () => browser.shouldHandleUnselectedTabHover
+  )
+    .catch(() => {
+      return (timedout = true);
+    })
+    .finally(() => {
+      ok(
+        timedout,
+        "Should not send unselected tab hover msg, no one is listening for it."
+      );
+      return true;
+    });
 }
 
 function get_video_decoding_suspend_promise(browser, reload) {
   let suspend = true;
   return SpecialPowers.spawn(
     browser,
     [{ suspend, reload }],
     check_video_decoding_state