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 395502 765238f1fbd40538f69df38085d7ccd929ce775e
parent 395501 d9793b0ed9dc53a4720fc5d2815b485b69ab9b07
child 395503 dd7485776e0b5e33717b3c29efe05741a9f5c28b
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy, test-only
bugs1311260
milestone54.0a2
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>