Bug 1497545 - clean up framerate tests; r=ochameau
authoryulia <ystartsev@mozilla.com>
Tue, 16 Oct 2018 14:18:10 +0000
changeset 499936 78b8e67c7e59ae3f3c0b7a309bfecedec60a5254
parent 499935 fb835f0cd5b620eddc4d754c17fcf2d6036e2249
child 499937 247936437060b0139fffbf827305c1e16c2df2cc
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1497545
milestone64.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 1497545 - clean up framerate tests; r=ochameau Depends on D8542 Differential Revision: https://phabricator.services.mozilla.com/D8543
devtools/server/tests/mochitest/chrome.ini
devtools/server/tests/mochitest/framerate-helpers.js
devtools/server/tests/mochitest/test_framerate_01.html
devtools/server/tests/mochitest/test_framerate_02.html
devtools/server/tests/mochitest/test_framerate_03.html
devtools/server/tests/mochitest/test_framerate_04.html
devtools/server/tests/mochitest/test_framerate_05.html
devtools/server/tests/mochitest/test_framerate_06.html
--- a/devtools/server/tests/mochitest/chrome.ini
+++ b/devtools/server/tests/mochitest/chrome.ini
@@ -2,16 +2,17 @@
 tags = devtools
 skip-if = os == 'android'
 support-files =
   animation-data.html
   doc_Debugger.Source.prototype.introductionType.xul
   Debugger.Source.prototype.element.js
   Debugger.Source.prototype.element-2.js
   Debugger.Source.prototype.element.html
+  framerate-helpers.js
   hello-actor.js
   iframe1_makeGlobalObjectReference.html
   iframe2_makeGlobalObjectReference.html
   inspector_css-properties.html
   inspector_display-type.html
   inspector_getImageData.html
   inspector_getOffsetParent.html
   inspector-delay-image-response.sjs
new file mode 100644
--- /dev/null
+++ b/devtools/server/tests/mochitest/framerate-helpers.js
@@ -0,0 +1,63 @@
+/* exported getTargetForSelectedTab, waitFor, plotFPS */
+"use strict";
+const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
+const {TargetFactory} = require("devtools/client/framework/target");
+const Services = require("Services");
+
+// Always log packets when running tests.
+Services.prefs.setBoolPref("devtools.debugger.log", true);
+SimpleTest.registerCleanupFunction(function() {
+  Services.prefs.clearUserPref("devtools.debugger.log");
+});
+
+SimpleTest.waitForExplicitFinish();
+
+/**
+ * Add a new test tab in the browser and load the given url.
+ * @return Promise a promise that resolves to the new target representing
+ *         the page currently opened.
+ */
+function getTargetForSelectedTab() {
+  // Get the target and get the necessary front
+  const {gBrowser} = Services.wm.getMostRecentWindow("navigator:browser");
+  return TargetFactory.forTab(gBrowser.selectedTab);
+}
+
+function waitFor(time) {
+  return new Promise(resolve => setTimeout(resolve, time));
+}
+
+function plotFPS(ticks, interval = 100, clamp = 60) {
+  const timeline = [];
+  const totalTicks = ticks.length;
+
+  // If the refresh driver didn't get a chance to tick before the
+  // recording was stopped, assume framerate was 0.
+  if (totalTicks == 0) {
+    timeline.push({ delta: 0, value: 0 });
+    timeline.push({ delta: interval, value: 0 });
+    return timeline;
+  }
+
+  let frameCount = 0;
+  let prevTime = ticks[0];
+
+  for (let i = 1; i < totalTicks; i++) {
+    const currTime = ticks[i];
+    frameCount++;
+
+    const elapsedTime = currTime - prevTime;
+    if (elapsedTime < interval) {
+      continue;
+    }
+
+    const framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
+    timeline.push({ delta: prevTime, value: framerate });
+    timeline.push({ delta: currTime, value: framerate });
+
+    frameCount = 0;
+    prevTime = currTime;
+  }
+
+  return timeline;
+}
--- a/devtools/server/tests/mochitest/test_framerate_01.html
+++ b/devtools/server/tests/mochitest/test_framerate_01.html
@@ -2,133 +2,69 @@
 <html>
 <!--
 Bug 1007200 - Create a framerate actor
 -->
 <head>
   <meta charset="utf-8">
   <title>Framerate actor test</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="framerate-helpers.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 </head>
 <body>
 <pre id="test">
 <script>
 "use strict";
 
-window.onload = function() {
-  const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const Services = require("Services");
-  const { DebuggerClient } = require("devtools/shared/client/debugger-client");
-  const { DebuggerServer } = require("devtools/server/main");
+window.onload = async function() {
+  const target = await getTargetForSelectedTab();
+  const front = target.getFront("framerate");
+  const TICK = 1000;
 
-  // Always log packets when running tests.
-  Services.prefs.setBoolPref("devtools.debugger.log", true);
-  SimpleTest.registerCleanupFunction(function() {
-    Services.prefs.clearUserPref("devtools.debugger.log");
-  });
+  await waitFor(TICK);
+  await front.startRecording();
+  await waitFor(TICK);
+  const rawData = await front.stopRecording();
+  await onRecordingStopped(front, rawData);
+  await target.destroy();
+  SimpleTest.finish();
+};
 
-  SimpleTest.waitForExplicitFinish();
-
-  const { FramerateFront } = require("devtools/shared/fronts/framerate");
-
-  function plotFPS(ticks, interval = 100, clamp = 60) {
-    const timeline = [];
-    const totalTicks = ticks.length;
+// Local Helpers
+async function onRecordingStopped(front, rawData) {
+  ok(rawData, "There should be a recording available.");
 
-    // If the refresh driver didn't get a chance to tick before the
-    // recording was stopped, assume framerate was 0.
-    if (totalTicks == 0) {
-      timeline.push({ delta: 0, value: 0 });
-      timeline.push({ delta: interval, value: 0 });
-      return timeline;
-    }
+  const timeline = plotFPS(rawData);
+  ok(timeline.length >= 2,
+    "There should be at least one measurement available, with two entries.");
 
-    let frameCount = 0;
-    let prevTime = ticks[0];
-
-    for (let i = 1; i < totalTicks; i++) {
-      const currTime = ticks[i];
-      frameCount++;
+  let prevTimeStart = timeline[0].delta;
 
-      const elapsedTime = currTime - prevTime;
-      if (elapsedTime < interval) {
-        continue;
-      }
+  for (let i = 0; i < timeline.length; i += 2) {
+    const currTimeStart = timeline[i].delta;
+    const currTimeEnd = timeline[i + 1].delta;
+    info("Testing delta: " + currTimeStart + " vs. " + currTimeEnd);
 
-      const framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
-      timeline.push({ delta: prevTime, value: framerate });
-      timeline.push({ delta: currTime, value: framerate });
+    ok(currTimeStart < currTimeEnd,
+      "The start and end time deltas should be consecutive.");
+    is(currTimeStart, prevTimeStart,
+      "There should be two time deltas for each framerate value.");
 
-      frameCount = 0;
-      prevTime = currTime;
-    }
-
-    return timeline;
+    prevTimeStart = currTimeEnd;
   }
 
-  DebuggerServer.init();
-  DebuggerServer.registerAllActors();
-
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  client.connect().then(function onConnect() {
-    client.listTabs().then(function onListTabs(response) {
-      const form = response.tabs[response.selected];
-      const front = FramerateFront(client, form);
-
-      window.setTimeout(() => {
-        /* eslint-disable max-nested-callbacks */
-        front.startRecording().then(() => {
-          window.setTimeout(() => {
-            front.stopRecording().then(rawData => {
-              onRecordingStopped(front, rawData);
-            });
-          }, 1000);
-        });
-        /* eslint-enable max-nested-callbacks */
-      }, 1000);
-    });
-  });
-
-  function onRecordingStopped(front, rawData) {
-    ok(rawData, "There should be a recording available.");
-
-    const timeline = plotFPS(rawData);
-    ok(timeline.length >= 2,
-      "There should be at least one measurement available, with two entries.");
-
-    let prevTimeStart = timeline[0].delta;
+  for (let i = 0; i < timeline.length; i += 2) {
+    const currFramerateStart = timeline[i].value;
+    const currFramerateEnd = timeline[i + 1].value;
+    info("Testing framerate: " + currFramerateStart);
 
-    for (let i = 0; i < timeline.length; i += 2) {
-      const currTimeStart = timeline[i].delta;
-      const currTimeEnd = timeline[i + 1].delta;
-      info("Testing delta: " + currTimeStart + " vs. " + currTimeEnd);
-
-      ok(currTimeStart < currTimeEnd,
-        "The start and end time deltas should be consecutive.");
-      is(currTimeStart, prevTimeStart,
-        "There should be two time deltas for each framerate value.");
-
-      prevTimeStart = currTimeEnd;
-    }
+    is(currFramerateStart, currFramerateEnd,
+      "The start and end framerate values should be equal.");
 
-    for (let i = 0; i < timeline.length; i += 2) {
-      const currFramerateStart = timeline[i].value;
-      const currFramerateEnd = timeline[i + 1].value;
-      info("Testing framerate: " + currFramerateStart);
-
-      is(currFramerateStart, currFramerateEnd,
-        "The start and end framerate values should be equal.");
-
-      is(typeof currFramerateStart, "number", "All values should be numbers.");
-      ok(currFramerateStart <= 60, "All values were correctly clamped.");
-    }
-
-    client.close().then(() => {
-      DebuggerServer.destroy();
-      SimpleTest.finish();
-    });
+    is(typeof currFramerateStart, "number", "All values should be numbers.");
+    ok(currFramerateStart <= 60, "All values were correctly clamped.");
   }
-};
+}
 </script>
 </pre>
 </body>
 </html>
--- a/devtools/server/tests/mochitest/test_framerate_02.html
+++ b/devtools/server/tests/mochitest/test_framerate_02.html
@@ -2,108 +2,47 @@
 <html>
 <!--
 Bug 1007200 - Create a framerate actor
 -->
 <head>
   <meta charset="utf-8">
   <title>Framerate actor test</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="framerate-helpers.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 </head>
 <body>
 <pre id="test">
 <script>
 "use strict";
 
-window.onload = function() {
-  const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const {DebuggerClient} = require("devtools/shared/client/debugger-client");
-  const {DebuggerServer} = require("devtools/server/main");
-  const Services = require("Services");
-
-  // Always log packets when running tests.
-  Services.prefs.setBoolPref("devtools.debugger.log", true);
-  SimpleTest.registerCleanupFunction(function() {
-    Services.prefs.clearUserPref("devtools.debugger.log");
-  });
-
-  SimpleTest.waitForExplicitFinish();
-
-  const {FramerateFront} = require("devtools/shared/fronts/framerate");
-
-  function plotFPS(ticks, interval = 100, clamp = 60) {
-    const timeline = [];
-    const totalTicks = ticks.length;
+window.onload = async function() {
+  const target = await getTargetForSelectedTab();
+  const front = target.getFront("framerate");
 
-    // If the refresh driver didn't get a chance to tick before the
-    // recording was stopped, assume framerate was 0.
-    if (totalTicks == 0) {
-      timeline.push({ delta: 0, value: 0 });
-      timeline.push({ delta: interval, value: 0 });
-      return timeline;
-    }
-
-    let frameCount = 0;
-    let prevTime = ticks[0];
+  const rawData = await front.stopRecording();
+  ok(rawData, "There should be a recording available.");
+  is(rawData.length, 0, "...but it should be empty.");
 
-    for (let i = 1; i < totalTicks; i++) {
-      const currTime = ticks[i];
-      frameCount++;
-
-      const elapsedTime = currTime - prevTime;
-      if (elapsedTime < interval) {
-        continue;
-      }
-
-      const framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
-      timeline.push({ delta: prevTime, value: framerate });
-      timeline.push({ delta: currTime, value: framerate });
+  const timeline = plotFPS(rawData);
+  is(timeline.length, 2,
+    "There should be one measurement plotted, with two entries.");
 
-      frameCount = 0;
-      prevTime = currTime;
-    }
-
-    return timeline;
-  }
-
-  DebuggerServer.init();
-  DebuggerServer.registerAllActors();
+  info("The framerate should be assumed to be 0 if the recording is empty.");
 
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  client.connect().then(function onConnect() {
-    client.listTabs().then(function onListTabs(response) {
-      const form = response.tabs[response.selected];
-      const front = FramerateFront(client, form);
-
-      front.stopRecording().then(rawData => {
-        ok(rawData, "There should be a recording available.");
-        is(rawData.length, 0, "...but it should be empty.");
+  is(timeline[0].delta, 0,
+    "The first time delta should be 0.");
+  is(timeline[0].value, 0,
+    "The first framerate value should be 0.");
 
-        const timeline = plotFPS(rawData);
-        is(timeline.length, 2,
-          "There should be one measurement plotted, with two entries.");
-
-        info("The framerate should be assumed to be 0 if the recording is empty.");
-
-        is(timeline[0].delta, 0,
-          "The first time delta should be 0.");
-        is(timeline[0].value, 0,
-          "The first framerate value should be 0.");
+  is(timeline[1].delta, 100,
+    "The last time delta should be 100 (the default interval value).");
+  is(timeline[1].value, 0,
+    "The last framerate value should be 0.");
 
-        is(timeline[1].delta, 100,
-          "The last time delta should be 100 (the default interval value).");
-        is(timeline[1].value, 0,
-          "The last framerate value should be 0.");
-
-        // eslint-disable-next-line max-nested-callbacks
-        client.close().then(() => {
-          DebuggerServer.destroy();
-          SimpleTest.finish();
-        });
-      });
-    });
-  });
+  await target.destroy();
+  SimpleTest.finish();
 };
 </script>
 </pre>
 </body>
 </html>
--- a/devtools/server/tests/mochitest/test_framerate_03.html
+++ b/devtools/server/tests/mochitest/test_framerate_03.html
@@ -2,78 +2,50 @@
 <html>
 <!--
 Bug 1023018 - Tests whether or not the framerate actor can handle time ranges.
 -->
 <head>
   <meta charset="utf-8">
   <title>Framerate actor test</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="framerate-helpers.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 </head>
 <body>
 <pre id="test">
 <script>
 "use strict";
 
-window.onload = function() {
-  const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const {DebuggerClient} = require("devtools/shared/client/debugger-client");
-  const {DebuggerServer} = require("devtools/server/main");
-  const Services = require("Services");
-
-  // Always log packets when running tests.
-  Services.prefs.setBoolPref("devtools.debugger.log", true);
-  SimpleTest.registerCleanupFunction(function() {
-    Services.prefs.clearUserPref("devtools.debugger.log");
-  });
-
-  SimpleTest.waitForExplicitFinish();
+const START_TICK = 2000;
+const STOP_TICK = 3000;
+const TOTAL_TIME = 5000;
 
-  const {FramerateFront} = require("devtools/shared/fronts/framerate");
-  const START_TICK = 2000;
-  const STOP_TICK = 3000;
-  const TOTAL_TIME = 5000;
-
-  DebuggerServer.init();
-  DebuggerServer.registerAllActors();
-
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  client.connect().then(function onConnect() {
-    client.listTabs().then(function onListTabs(response) {
-      const form = response.tabs[response.selected];
-      const front = FramerateFront(client, form);
+window.onload = async function() {
+  const target = await getTargetForSelectedTab();
+  const front = target.getFront("framerate");
 
-      front.startRecording().then(() => {
-        /* eslint-disable max-nested-callbacks */
-        window.setTimeout(() => {
-          front.stopRecording(START_TICK, STOP_TICK).then(rawData => {
-            onRecordingStopped(front, rawData);
-          });
-        }, TOTAL_TIME);
-        /* eslint-enable max-nested-callbacks */
-      });
-    });
-  });
-
-  function onRecordingStopped(front, rawData) {
-    ok(rawData, "There should be a recording available.");
+  await front.startRecording();
+  await waitFor(TOTAL_TIME);
+  const rawData = await front.stopRecording(START_TICK, STOP_TICK);
+  await onRecordingStopped(front, rawData);
+  await target.destroy();
+  SimpleTest.finish();
+};
 
-    ok(!rawData.find(e => e < START_TICK),
-      "There should be no tick before 2000ms.");
-    ok(!rawData.find(e => e > STOP_TICK),
-      "There should be no tick after 3000ms.");
+// Local Helper Functions
+async function onRecordingStopped(front, rawData) {
+  ok(rawData, "There should be a recording available.");
 
-    for (const tick of rawData) {
-      info("Testing tick: " + tick);
-      is(typeof tick, "number", "All values should be numbers.");
-    }
+  ok(!rawData.find(e => e < START_TICK),
+    "There should be no tick before 2000ms.");
+  ok(!rawData.find(e => e > STOP_TICK),
+    "There should be no tick after 3000ms.");
 
-    client.close().then(() => {
-      DebuggerServer.destroy();
-      SimpleTest.finish();
-    });
+  for (const tick of rawData) {
+    info("Testing tick: " + tick);
+    is(typeof tick, "number", "All values should be numbers.");
   }
-};
+}
 </script>
 </pre>
 </body>
 </html>
--- a/devtools/server/tests/mochitest/test_framerate_04.html
+++ b/devtools/server/tests/mochitest/test_framerate_04.html
@@ -11,57 +11,56 @@ Bug 1023018 - Tests if the framerate act
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 </head>
 <body>
 <pre id="test">
 <script>
 "use strict";
 
 window.onload = async function() {
+  // inspector-helpers doesnt wait for explicit finish
   SimpleTest.waitForExplicitFinish();
 
+  const TICK = 1000;
   const url = document.getElementById("testContent").href;
-  const { client, target, doc } = await attachURL(url);
+  const { target, doc } = await attachURL(url);
   const contentWin = doc.defaultView;
-  const chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
-
   const front = target.getFront("framerate");
 
   await front.startRecording();
-  window.setTimeout(() => {
-    front.getPendingTicks().then(firstBatch => {
-      /* eslint-disable max-nested-callbacks */
-      target.once("will-navigate", () => {
-        window.setTimeout(() => {
-          front.stopRecording().then(secondBatch => {
-            onRecordingStopped(client, firstBatch, secondBatch);
-          });
-        }, 1000);
-      });
-      /* eslint-enable max-nested-callbacks */
-      contentWin.location.reload();
-    });
-  }, 1000);
+  await waitFor(TICK);
+  const firstBatch = await front.getPendingTicks();
+  await waitFor(TICK);
+
+  const onWillNavigate = target.once("will-navigate");
+  contentWin.location.reload();
+  await onWillNavigate;
+
+  await waitFor(TICK);
+  const secondBatch = await front.stopRecording();
+  await onRecordingStopped(firstBatch, secondBatch);
+  target.destroy();
+  SimpleTest.finish();
+};
 
-  function onRecordingStopped(client, firstBatch, secondBatch) {
-    ok(firstBatch, "There should be a first batch recording available.");
-    ok(secondBatch, "There should be a second batch recording available.");
+// Local Helpers
+function waitFor(time) {
+  return new Promise(resolve => setTimeout(resolve, time));
+}
 
-    const diff = secondBatch.length - firstBatch.length;
-    info("Difference in ticks: " + diff);
-    ok(diff > 0, "More ticks should be recorded in the second batch.");
+function onRecordingStopped(firstBatch, secondBatch) {
+  ok(firstBatch, "There should be a first batch recording available.");
+  ok(secondBatch, "There should be a second batch recording available.");
 
-    ok(firstBatch.every((e) => secondBatch.includes(e)),
-      "All the ticks in the first batch should be in the second batch as well.");
-    ok(secondBatch.every((e, i, array) => i < array.length - 1 ? e < array[i + 1] : true),
-      "All the ticks in the final batch should be ascending in value.");
+  const diff = secondBatch.length - firstBatch.length;
+  info("Difference in ticks: " + diff);
+  ok(diff > 0, "More ticks should be recorded in the second batch.");
 
-    client.close().then(() => {
-      DebuggerServer.destroy();
-      SimpleTest.finish();
-    });
-  }
-};
+  ok(firstBatch.every((e) => secondBatch.includes(e)),
+    "All the ticks in the first batch should be in the second batch as well.");
+  ok(secondBatch.every((e, i, array) => i < array.length - 1 ? e < array[i + 1] : true),
+    "All the ticks in the final batch should be ascending in value.");
+}
 </script>
 </pre>
 <a id="testContent" target="_blank" href="inspector_getImageData.html">Test Document</a>
 </body>
 </html>
--- a/devtools/server/tests/mochitest/test_framerate_05.html
+++ b/devtools/server/tests/mochitest/test_framerate_05.html
@@ -2,75 +2,46 @@
 <html>
 <!--
 Bug 1034648 - Tests whether a framerate recording can be cancelled.
 -->
 <head>
   <meta charset="utf-8">
   <title>Framerate actor test</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="framerate-helpers.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 </head>
 <body>
 <pre id="test">
 <script>
 "use strict";
 
-window.onload = function() {
-  const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const {DebuggerClient} = require("devtools/shared/client/debugger-client");
-  const {DebuggerServer} = require("devtools/server/main");
-  const Services = require("Services");
-
-  // Always log packets when running tests.
-  Services.prefs.setBoolPref("devtools.debugger.log", true);
-  SimpleTest.registerCleanupFunction(function() {
-    Services.prefs.clearUserPref("devtools.debugger.log");
-  });
+window.onload = async function() {
+  const target = await getTargetForSelectedTab();
+  const front = target.getFront("framerate");
+  const TICK = 1000;
 
-  SimpleTest.waitForExplicitFinish();
-
-  const {FramerateFront} = require("devtools/shared/fronts/framerate");
+  await front.startRecording();
+  await waitFor(TICK);
 
-  DebuggerServer.init();
-  DebuggerServer.registerAllActors();
-
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  client.connect().then(function onConnect() {
-    client.listTabs().then(function onListTabs(response) {
-      const form = response.tabs[response.selected];
-      const front = FramerateFront(client, form);
+  await front.cancelRecording();
+  await waitFor(TICK);
 
-      front.startRecording().then(() => {
-        /* eslint-disable max-nested-callbacks */
-        window.setTimeout(() => {
-          front.cancelRecording().then(() => {
-            window.setTimeout(() => {
-              front.getPendingTicks().then(rawTicks => {
-                ok(rawTicks,
-                  "The returned pending ticks should be empty (1).");
-                is(rawTicks.length, 0,
-                  "The returned pending ticks should be empty (2).");
+  const rawTicks = await front.getPendingTicks();
+  ok(rawTicks,
+    "The returned pending ticks should be empty (1).");
+  is(rawTicks.length, 0,
+    "The returned pending ticks should be empty (2).");
 
-                front.stopRecording().then(rawData => {
-                  ok(rawData,
-                    "The returned raw data should be an empty array (1).");
-                  is(rawData.length, 0,
-                    "The returned raw data should be an empty array (2).");
+  const newRawData = await front.stopRecording();
+  ok(newRawData,
+    "The returned raw data should be an empty array (1).");
+  is(newRawData.length, 0,
+    "The returned raw data should be an empty array (2).");
 
-                  client.close().then(() => {
-                    DebuggerServer.destroy();
-                    SimpleTest.finish();
-                  });
-                });
-              });
-            }, 1000);
-          });
-        }, 1000);
-        /* eslint-enable max-nested-callbacks */
-      });
-    });
-  });
+  await target.destroy();
+  SimpleTest.finish();
 };
 </script>
 </pre>
 </body>
 </html>
--- a/devtools/server/tests/mochitest/test_framerate_06.html
+++ b/devtools/server/tests/mochitest/test_framerate_06.html
@@ -11,68 +11,77 @@ Bug 1171489 - Tests if the framerate act
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 </head>
 <body>
 <pre id="test">
 <script>
 "use strict";
 
 window.onload = async function() {
+  // inspector-helpers doesnt wait for explicit finish
   SimpleTest.waitForExplicitFinish();
 
+  const TICK = 1000;
   const url = document.getElementById("testContent").href;
-  const { client, target, doc } = await attachURL(url);
+  const { target, doc } = await attachURL(url);
   const contentWin = doc.defaultView;
 
   const front = target.getFront("framerate");
 
   await front.startRecording();
-  window.setTimeout(() => {
-    // Wait for the iframe to be loaded again
+  await waitFor(TICK);
+  const onWindowReady = waitForWindowReady();
+  contentWin.location.reload();
+
+  // Wait for the iframe to be loaded again
+  await onWindowReady;
+  await waitFor(TICK);
+  const ticks = await front.stopRecording();
+  await onRecordingStopped(ticks);
+
+  await target.destroy();
+  SimpleTest.finish();
+};
+
+// Local Helpers
+function waitFor(time) {
+  return new Promise(resolve => setTimeout(resolve, time));
+}
+
+function waitForWindowReady() {
+  return new Promise(resolve => {
     window.addEventListener("message", function loaded(event) {
       if (event.data === "ready") {
         window.removeEventListener("message", loaded);
-        /* eslint-disable max-nested-callbacks */
-        window.setTimeout(async () => {
-          front.stopRecording().then(ticks => {
-            onRecordingStopped(client, ticks);
-          });
-        }, 1000);
-        /* eslint-enable max-nested-callbacks */
+        resolve();
       }
     });
-    contentWin.location.reload();
-  }, 1000);
-
-  function onRecordingStopped(client, ticks) {
-    const diffs = [];
+  });
+}
 
-    info(`Got ${ticks.length} ticks.`);
+function onRecordingStopped(ticks) {
+  const diffs = [];
 
-    for (let i = 1; i < ticks.length; i++) {
-      const prev = ticks[i - 1];
-      const curr = ticks[i];
-      diffs.push(curr - prev);
-      info(curr + " - " + (curr - prev));
-    }
+  info(`Got ${ticks.length} ticks.`);
 
-    // 1000 / 60 => 16.666... so we shouldn't get more than diffs of 16.66.. but
-    // when we get ticks from other frames they're usually at diffs of < 1. Sometimes
-    // ticks can still be less than 16ms even on one frame (usually following a very slow
-    // frame), so use a low number (2) to be our threshold
-    const THRESHOLD = 2;
-    ok(ticks.length >= 20,
-       "we should have atleast 20 ticks over the course of two seconds.");
-    const belowThreshold = diffs.filter(v => v <= THRESHOLD);
-    ok(belowThreshold.length <= 10,
-       "we should have very few frames less than the threshold");
+  for (let i = 1; i < ticks.length; i++) {
+    const prev = ticks[i - 1];
+    const curr = ticks[i];
+    diffs.push(curr - prev);
+    info(curr + " - " + (curr - prev));
+  }
 
-    client.close().then(() => {
-      DebuggerServer.destroy();
-      SimpleTest.finish();
-    });
-  }
-};
+  // 1000 / 60 => 16.666... so we shouldn't get more than diffs of 16.66.. but
+  // when we get ticks from other frames they're usually at diffs of < 1. Sometimes
+  // ticks can still be less than 16ms even on one frame (usually following a very slow
+  // frame), so use a low number (2) to be our threshold
+  const THRESHOLD = 2;
+  ok(ticks.length >= 20,
+     "we should have atleast 20 ticks over the course of two seconds.");
+  const belowThreshold = diffs.filter(v => v <= THRESHOLD);
+  ok(belowThreshold.length <= 10,
+     "we should have very few frames less than the threshold");
+}
 </script>
 </pre>
 <a id="testContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
 </body>
 </html>