Bug 1494605 - Use target.getFront for PerformanceFront in tests; r=ochameau
authoryulia <ystartsev@mozilla.com>
Thu, 04 Oct 2018 14:57:32 +0000
changeset 495372 0a653b330b03ec8ce30b31275fa083061d698cc4
parent 495371 21e66bfa0cc4947247ba659e70e586c96c798792
child 495373 757135609fdb585335559ad5dd77162969562039
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1494605
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 1494605 - Use target.getFront for PerformanceFront in tests; r=ochameau Depends on D6768 Differential Revision: https://phabricator.services.mozilla.com/D7060
devtools/server/tests/browser/browser_markers-cycle-collection.js
devtools/server/tests/browser/browser_markers-gc.js
devtools/server/tests/browser/browser_markers-minor-gc.js
devtools/server/tests/browser/browser_markers-parse-html.js
devtools/server/tests/browser/browser_markers-styles.js
devtools/server/tests/browser/browser_markers-timestamp.js
devtools/server/tests/browser/browser_perf-allocation-data.js
devtools/server/tests/browser/browser_perf-profiler-01.js
devtools/server/tests/browser/browser_perf-profiler-02.js
devtools/server/tests/browser/browser_perf-profiler-03.js
devtools/server/tests/browser/browser_perf-realtime-markers.js
devtools/server/tests/browser/browser_perf-recording-actor-01.js
devtools/server/tests/browser/browser_perf-recording-actor-02.js
devtools/server/tests/browser/browser_perf-samples-01.js
devtools/server/tests/browser/browser_perf-samples-02.js
--- a/devtools/server/tests/browser/browser_markers-cycle-collection.js
+++ b/devtools/server/tests/browser/browser_markers-cycle-collection.js
@@ -2,35 +2,29 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that we get "nsCycleCollector::Collect" and
  * "nsCycleCollector::ForgetSkippable" markers when we force cycle collection.
  */
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
   // This test runs very slowly on linux32 debug EC2 instances.
   requestLongerTimeout(2);
 
-  await addTab(MAIN_DOMAIN + "doc_force_cc.html");
-
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_force_cc.html");
+  const front = target.getFront("performance");
   await front.connect();
   const rec = await front.startRecording({ withMarkers: true });
 
   const markers = await waitForMarkerType(front,
     ["nsCycleCollector::Collect", "nsCycleCollector::ForgetSkippable"]);
   await front.stopRecording(rec);
 
   ok(markers.some(m => m.name === "nsCycleCollector::Collect"),
     "got some nsCycleCollector::Collect markers");
   ok(markers.some(m => m.name === "nsCycleCollector::ForgetSkippable"),
     "got some nsCycleCollector::Collect markers");
 
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_markers-gc.js
+++ b/devtools/server/tests/browser/browser_markers-gc.js
@@ -1,26 +1,21 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that we get "GarbageCollection" markers.
  */
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
 const MARKER_NAME = "GarbageCollection";
 
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_force_gc.html");
-
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_force_gc.html");
+  const front = target.getFront("performance");
   await front.connect();
   const rec = await front.startRecording({ withMarkers: true });
 
   let markers = await waitForMarkerType(front, MARKER_NAME);
   await front.stopRecording(rec);
 
   ok(markers.some(m => m.name === MARKER_NAME), `got some ${MARKER_NAME} markers`);
   ok(markers.every(({causeName}) => typeof causeName === "string"),
@@ -41,11 +36,11 @@ add_task(async function() {
         start time (${current.start}) thanprevious: ${previousStart}`);
       ordered = false;
     }
     return current.start;
   });
 
   is(ordered, true, "All GC and non-GC markers are in order by start time.");
 
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_markers-minor-gc.js
+++ b/devtools/server/tests/browser/browser_markers-minor-gc.js
@@ -2,32 +2,26 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that we get "MinorGC" markers when we continue to steadily allocate
  * objects.
  */
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
   // This test runs very slowly on linux32 debug EC2 instances.
   requestLongerTimeout(2);
 
-  await addTab(MAIN_DOMAIN + "doc_allocations.html");
-
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_allocations.html");
+  const front = target.getFront("performance");
   await front.connect();
   const rec = await front.startRecording({ withMarkers: true });
 
   const markers = await waitForMarkerType(front, ["MinorGC"]);
   await front.stopRecording(rec);
 
   ok(markers.some(m => m.name === "MinorGC" && m.causeName),
      "got some MinorGC markers");
 
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_markers-parse-html.js
+++ b/devtools/server/tests/browser/browser_markers-parse-html.js
@@ -1,29 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that we get "Parse HTML" markers.
  */
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
 const MARKER_NAME = "Parse HTML";
 
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_innerHTML.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_innerHTML.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
   const rec = await front.startRecording({ withMarkers: true });
 
   const markers = await waitForMarkerType(front, MARKER_NAME);
   await front.stopRecording(rec);
 
   ok(markers.some(m => m.name === MARKER_NAME), `got some ${MARKER_NAME} markers`);
 
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_markers-styles.js
+++ b/devtools/server/tests/browser/browser_markers-styles.js
@@ -1,30 +1,26 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that we get "Styles" markers with correct meta.
  */
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
 const MARKER_NAME = "Styles";
 
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
   const rec = await front.startRecording({ withMarkers: true });
 
   const markers = await waitForMarkerType(front, MARKER_NAME);
 
   await front.stopRecording(rec);
 
   ok(markers.some(m => m.name === MARKER_NAME), `got some ${MARKER_NAME} markers`);
 
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_markers-timestamp.js
+++ b/devtools/server/tests/browser/browser_markers-timestamp.js
@@ -1,28 +1,24 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that we get a "TimeStamp" marker.
  */
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
 const { pmmConsoleMethod, pmmLoadFrameScripts, pmmClearFrameScripts }
   = require("devtools/client/performance/test/helpers/profiler-mm-utils");
 const MARKER_NAME = "TimeStamp";
 
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
   const rec = await front.startRecording({ withMarkers: true });
 
   pmmLoadFrameScripts(gBrowser);
   pmmConsoleMethod("timeStamp");
   pmmConsoleMethod("timeStamp", "myLabel");
 
   const markers = await waitForMarkerType(front, MARKER_NAME, m => m.length >= 2);
@@ -36,11 +32,11 @@ add_task(async function() {
   ok(markers.length === 2, "found 2 TimeStamp markers");
   ok(markers.every(({start, end}) => typeof start === "number" && start === end),
     "All markers have equal start and end times");
   is(markers[0].causeName, void 0, "Unlabeled timestamps have an empty causeName");
   is(markers[1].causeName, "myLabel", "Labeled timestamps have correct causeName");
 
   pmmClearFrameScripts();
 
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_perf-allocation-data.js
+++ b/devtools/server/tests/browser/browser_perf-allocation-data.js
@@ -2,25 +2,19 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that we have allocation data coming from the front.
  */
 
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_allocations.html");
-
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const target  = await addTabTarget(MAIN_DOMAIN + "doc_allocations.html");
+  const front = target.getFront("performance");
   await front.connect();
 
   const rec = await front.startRecording(
     { withMarkers: true, withAllocations: true, withTicks: true });
 
   await waitUntil(() => rec.getAllocations().frames.length);
   await waitUntil(() => rec.getAllocations().timestamps.length);
   await waitUntil(() => rec.getAllocations().sizes.length);
@@ -31,11 +25,11 @@ add_task(async function() {
   const { timestamps, sizes } = rec.getAllocations();
 
   is(timestamps.length, sizes.length, "we have the same amount of timestamps and sizes");
   ok(timestamps.every(time => time > 0 && typeof time === "number"),
     "all timestamps have numeric values");
   ok(sizes.every(n => n > 0 && typeof n === "number"), "all sizes are positive numbers");
 
   await front.destroy();
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_perf-profiler-01.js
+++ b/devtools/server/tests/browser/browser_perf-profiler-01.js
@@ -4,26 +4,22 @@
 /**
  * Tests if the profiler connection front does not activate the built-in
  * profiler module if not necessary, and doesn't deactivate it when
  * a recording is stopped.
  */
 
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
 const { pmmIsProfilerActive, pmmLoadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
 
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
 
   pmmLoadFrameScripts(gBrowser);
 
   ok(!(await pmmIsProfilerActive()),
     "The built-in profiler module should not have been automatically started.");
 
   let rec = await front.startRecording();
@@ -32,15 +28,15 @@ add_task(async function() {
     "The built-in profiler module should still be active (1).");
 
   rec = await front.startRecording();
   await front.stopRecording(rec);
   ok((await pmmIsProfilerActive()),
     "The built-in profiler module should still be active (2).");
 
   await front.destroy();
-  await client.close();
+  await target.destroy();
 
   ok(!(await pmmIsProfilerActive()),
     "The built-in profiler module should no longer be active.");
 
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_perf-profiler-02.js
+++ b/devtools/server/tests/browser/browser_perf-profiler-02.js
@@ -3,46 +3,40 @@
 
 /**
  * Tests if the built-in profiler module doesn't deactivate when the toolbox
  * is destroyed if there are other consumers using it.
  */
 
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
 const { pmmIsProfilerActive, pmmLoadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
 
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const firstFront = PerformanceFront(client, form);
+  const target1 = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
+  const firstFront = target1.getFront("performance");
   await firstFront.connect();
 
   pmmLoadFrameScripts(gBrowser);
 
   await firstFront.startRecording();
 
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
-  const client2 = new DebuggerClient(DebuggerServer.connectPipe());
-  const form2 = await connectDebuggerClient(client2);
-  const secondFront = PerformanceFront(client2, form2);
+  const target2 = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
+  const secondFront = target2.getFront("performance");
   await secondFront.connect();
   pmmLoadFrameScripts(gBrowser);
 
   await secondFront.startRecording();
 
   // Manually teardown the tabs so we can check profiler status
   await secondFront.destroy();
-  await client2.close();
+  await target2.destroy();
   ok((await pmmIsProfilerActive()),
     "The built-in profiler module should still be active.");
 
   await firstFront.destroy();
-  await client.close();
+  await target1.destroy();
   ok(!(await pmmIsProfilerActive()),
     "The built-in profiler module should no longer be active.");
 
   gBrowser.removeCurrentTab();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_perf-profiler-03.js
+++ b/devtools/server/tests/browser/browser_perf-profiler-03.js
@@ -5,52 +5,46 @@
  * Tests if the built-in profiler module is not reactivated if no other
  * consumer was using it over the remote debugger protocol, and ensures
  * that the actor will work properly even in such cases (e.g. the Gecko Profiler
  * addon was installed and automatically activated the profiler module).
  */
 
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
 const { pmmIsProfilerActive, pmmStartProfiler, pmmLoadFrameScripts, pmmClearFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
 
 add_task(async function() {
   // Ensure the profiler is already running when the test starts.
   pmmLoadFrameScripts(gBrowser);
   const entries = 1000000;
   const interval = 1;
   const features = ["js"];
   await pmmStartProfiler({ entries, interval, features });
 
   ok((await pmmIsProfilerActive()),
     "The built-in profiler module should still be active.");
 
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const firstFront = PerformanceFront(client, form);
+  const target1 = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
+  const firstFront = target1.getFront("performance");
   await firstFront.connect();
 
   await firstFront.startRecording();
 
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
-  const client2 = new DebuggerClient(DebuggerServer.connectPipe());
-  const form2 = await connectDebuggerClient(client2);
-  const secondFront = PerformanceFront(client2, form2);
+  const target2 = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
+  const secondFront = target2.getFront("performance");
   await secondFront.connect();
 
   await secondFront.destroy();
-  await client2.close();
+  await target2.destroy();
   ok((await pmmIsProfilerActive()),
     "The built-in profiler module should still be active.");
 
   await firstFront.destroy();
-  await client.close();
+  await target1.destroy();
   ok(!(await pmmIsProfilerActive()),
     "The built-in profiler module should have been automatically stopped.");
 
   pmmClearFrameScripts();
 
   gBrowser.removeCurrentTab();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_perf-realtime-markers.js
+++ b/devtools/server/tests/browser/browser_perf-realtime-markers.js
@@ -2,25 +2,20 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test functionality of real time markers.
  */
 
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
 
   let lastMemoryDelta = 0;
   let lastTickDelta = 0;
 
   const counters = {
     markers: [],
     memory: [],
@@ -41,17 +36,17 @@ add_task(async function() {
   await front.stopRecording(rec);
   front.off("timeline-data", handler);
 
   is(counters.markers.length, 1, "one marker event fired.");
   is(counters.memory.length, 3, "three memory events fired.");
   is(counters.ticks.length, 3, "three ticks events fired.");
 
   await front.destroy();
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 
   function handler(name, data) {
     if (name === "markers") {
       if (counters.markers.length >= 1) {
         return;
       }
       ok(data.markers[0].start, "received atleast one marker with `start`");
--- a/devtools/server/tests/browser/browser_perf-recording-actor-01.js
+++ b/devtools/server/tests/browser/browser_perf-recording-actor-01.js
@@ -3,25 +3,19 @@
 
 /**
  * Tests the state of a recording rec from start to finish for recording,
  * completed, and rec data.
  */
 
 "use strict";
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
-
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
+  const front = target.getFront("performance");
   await front.connect();
 
   const rec = await front.startRecording(
     { withMarkers: true, withTicks: true, withMemory: true });
   ok(rec.isRecording(), "RecordingModel is recording when created");
   await busyWait(100);
   await waitUntil(() => rec.getMemory().length);
   ok(true, "RecordingModel populates memory while recording");
@@ -66,17 +60,17 @@ add_task(async function() {
   ok(importedModel.isCompleted(), "All imported recordings should be completed");
   ok(!importedModel.isRecording(), "All imported recordings should not be recording");
   ok(importedModel.isImported(), "All imported recordings should be considerd imported");
 
   checkSystemInfo(importedModel, "Host");
   checkSystemInfo(importedModel, "Client");
 
   await front.destroy();
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
 
 function checkSystemInfo(recording, type) {
   const data = recording[`get${type}SystemInfo`]();
   for (const field of ["appid", "apptype", "vendor", "name", "version"]) {
     ok(data[field], `get${type}SystemInfo() has ${field} property`);
   }
--- a/devtools/server/tests/browser/browser_perf-recording-actor-02.js
+++ b/devtools/server/tests/browser/browser_perf-recording-actor-02.js
@@ -5,25 +5,20 @@
  * Test that buffer status is correctly updated in recording models.
  */
 
 "use strict";
 
 var BUFFER_SIZE = 20000;
 var config = { bufferSize: BUFFER_SIZE };
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
 
   await front.setProfilerStatusInterval(10);
   const model = await front.startRecording(config);
   const stats = await once(front, "profiler-status");
   is(stats.totalSize, BUFFER_SIZE,
     `profiler-status event has totalSize: ${stats.totalSize}`);
   ok(stats.position < BUFFER_SIZE,
@@ -49,11 +44,11 @@ add_task(async function() {
   ok(checkCount >= 1, "atleast 1 event were fired until the buffer was filled");
   is(lastBufferStatus, 1, "buffer usage cannot surpass 100%");
   await front.stopRecording(model);
 
   is(front.getBufferUsageForRecording(model), null,
     "buffer usage should be null when no longer recording.");
 
   await front.destroy();
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_perf-samples-01.js
+++ b/devtools/server/tests/browser/browser_perf-samples-01.js
@@ -6,26 +6,21 @@
  * normalized before passed to consumers.
  */
 
 "use strict";
 
 // time in ms
 const WAIT_TIME = 1000;
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
   await SpecialPowers.pushPrefEnv({"set": [["privacy.reduceTimerPrecision", false]]});
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
 
   // Perform the first recording...
 
   const firstRecording = await front.startRecording();
   const firstRecordingStartTime = firstRecording._startTime;
   info("Started profiling at: " + firstRecordingStartTime);
 
@@ -60,11 +55,11 @@ add_task(async function() {
     "The second recorded sample times were normalized correctly.");
   ok(!secondRecordingSamples.find(
         e => e[TIME_SLOT] + secondRecordingStartTime <= firstRecording.getDuration()
     ),
     "There should be no samples from the first recording in the second one, " +
     "even though the total number of frames did not overflow.");
 
   await front.destroy();
-  await client.close();
+  await target.destroy();
   gBrowser.removeCurrentTab();
 });
--- a/devtools/server/tests/browser/browser_perf-samples-02.js
+++ b/devtools/server/tests/browser/browser_perf-samples-02.js
@@ -7,25 +7,20 @@
  * devtools/client/performance/modules/logic/tree-model.js will have to be changed.
  */
 
 "use strict";
 
 // Time in ms
 const WAIT_TIME = 1000;
 
-const { PerformanceFront } = require("devtools/shared/fronts/performance");
-
 add_task(async function() {
-  await addTab(MAIN_DOMAIN + "doc_perf.html");
+  const target = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
 
-  initDebuggerServer();
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
-  const front = PerformanceFront(client, form);
+  const front = target.getFront("performance");
   await front.connect();
 
   const rec = await front.startRecording();
   // allow the profiler module to sample some cpu activity
   busyWait(WAIT_TIME);
 
   await front.stopRecording(rec);
   const profile = rec.getProfile();
@@ -43,17 +38,17 @@ add_task(async function() {
       }
     }
   }
 
   ok(sampleCount > 0,
     "At least some samples have been iterated over, checking for root nodes.");
 
   await front.destroy();
-  await client.close();
+  await target.getFront("performance");
   gBrowser.removeCurrentTab();
 });
 
 /**
  * Inflate a particular sample's stack and return an array of strings.
  */
 function getInflatedStackLocations(thread, sample) {
   const stackTable = thread.stackTable;