Bug 1373558 - Wait for next idle; r=ochameau draft
authorJan Odvarko <odvarko@gmail.com>
Thu, 08 Feb 2018 17:24:27 +0100
changeset 752588 9d46234c80ed58df9c7fa18d5ac59696bcf39861
parent 752552 d3fc6a142aec382be9937cb28f22ebad8c161c2f
push id98307
push userjodvarko@mozilla.com
push dateThu, 08 Feb 2018 16:25:25 +0000
reviewersochameau
bugs1373558
milestone60.0a1
Bug 1373558 - Wait for next idle; r=ochameau MozReview-Commit-ID: 5r19IJ93rHm
devtools/client/netmonitor/test/browser_net_statistics-01.js
--- a/devtools/client/netmonitor/test/browser_net_statistics-01.js
+++ b/devtools/client/netmonitor/test/browser_net_statistics-01.js
@@ -1,52 +1,57 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 /**
  * Tests if the statistics panel displays correctly.
  */
-
-add_task(function* () {
-  let { monitor } = yield initNetMonitor(STATISTICS_URL);
+add_task(async () => {
+  let { monitor } = await initNetMonitor(STATISTICS_URL);
   info("Starting test... ");
 
   let panel = monitor.panelWin;
   let { document, store, windowRequire, connector } = panel;
   let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
 
+  store.dispatch(Actions.batchEnable(false));
+
+  await new Promise(done => {
+    panel.requestIdleCallback(done);
+  });
+
   ok(document.querySelector(".monitor-panel"),
     "The current main panel is correct.");
 
   info("Displaying statistics panel");
   store.dispatch(Actions.openStatistics(connector, true));
 
   ok(document.querySelector(".statistics-panel"),
     "The current main panel is correct.");
 
   info("Waiting for placeholder to display");
 
-  yield waitUntil(
+  await waitUntil(
     () => document.querySelectorAll(".pie-chart-container[placeholder=true]")
                   .length == 2);
   ok(true, "Two placeholder pie charts appear to be rendered correctly.");
 
-  yield waitUntil(
+  await waitUntil(
     () => document.querySelectorAll(".table-chart-container[placeholder=true]")
                   .length == 2);
-  ok(true, "Two placeholde table charts appear to be rendered correctly.");
+  ok(true, "Two placeholder table charts appear to be rendered correctly.");
 
   info("Waiting for chart to display");
 
-  yield waitUntil(
+  await waitUntil(
     () => document.querySelectorAll(".pie-chart-container:not([placeholder=true])")
                   .length == 2);
   ok(true, "Two real pie charts appear to be rendered correctly.");
 
-  yield waitUntil(
+  await waitUntil(
     () => document.querySelectorAll(".table-chart-container:not([placeholder=true])")
                   .length == 2);
   ok(true, "Two real table charts appear to be rendered correctly.");
 
-  yield teardown(monitor);
+  await teardown(monitor);
 });