Bug 1311260 - Fix Intermittent toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html. r=mixedpuppy, a=test-only
authorBob Silverberg <bsilverberg@mozilla.com>
Wed, 08 Mar 2017 09:09:26 -0500
changeset 379321 38fce2379faf57f70099f00bb0d26ab9e3ff7aee
parent 379320 67a86746e6f1ab170c9fa6b1abb0e5d5a8f10258
child 379322 ec3ea5f067b6217d9a2c5a86358fa74c83eaaf62
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy, test-only
bugs1311260
milestone53.0
Bug 1311260 - Fix Intermittent toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html. r=mixedpuppy, a=test-only Bumped up the amount of time that we add to the current idleTime in the test, which is then used in the background page to test browser.idle.queryState() with an expectation that the state will be "active". Also added more logging to detect times when there is a large delay between getting the idleTime in the test, and when the idleTime is read by the API code in the background page, which I believe is the cause of this intermittent. MozReview-Commit-ID: DXvbYJ8zBKR
toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html
@@ -24,16 +24,17 @@ add_task(function* testWithRealIdleServi
         browser.idle.queryState(detectionInterval).then(status => {
           browser.test.assertEq("active", status, "Idle status is active");
         });
         browser.idle.setDetectionInterval(detectionInterval);
         browser.idle.onStateChanged.addListener(newState => {
           browser.test.assertEq("idle", newState, "listener fired with the expected state");
           browser.test.sendMessage("listenerFired");
         });
+        browser.test.sendMessage("listenerAdded");
       } else if (msg == "checkState") {
         browser.idle.queryState(detectionInterval).then(status => {
           browser.test.assertEq("idle", status, "Idle status is idle");
           browser.test.notifyPass("idle");
         });
       }
     });
   }
@@ -42,20 +43,21 @@ add_task(function* testWithRealIdleServi
     background,
     manifest: {
       permissions: ["idle"],
     },
   });
 
   yield extension.startup();
   let idleTime = idleService.idleTime;
-  let detectionInterval = Math.max(Math.ceil(idleTime / 1000) + 2, 15);
+  let detectionInterval = Math.max(Math.ceil(idleTime / 1000) + 10, 15);
   info(`idleTime: ${idleTime}, detectionInterval: ${detectionInterval}`);
   extension.sendMessage("addListener", detectionInterval);
-  info("Listener added");
+  yield extension.awaitMessage("listenerAdded");
+  info(`Listener added. idleTime: ${idleService.idleTime}`);
   yield extension.awaitMessage("listenerFired");
   info("Listener fired");
   extension.sendMessage("checkState", detectionInterval);
   yield extension.awaitFinish("idle");
   yield extension.unload();
 });
 
 </script>