Bug 1485660 - Convert browser_db_listtabs-03.js to async and make it use TargetFront. r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 15 Oct 2018 08:36:17 +0000
changeset 496990 278e3ec5091b61d04a78637ca35dfcfff30dbca2
parent 496989 4ac958d94290160ed534261ec799b8a86f302029
child 496991 9b5cb8d01b721812b55c3f2d941437bb06081104
push id9996
push userarchaeopteryx@coole-files.de
push dateThu, 18 Oct 2018 18:37:15 +0000
treeherdermozilla-beta@8efe26839243 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1485660
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 1485660 - Convert browser_db_listtabs-03.js to async and make it use TargetFront. r=jdescottes MozReview-Commit-ID: KLqx50gwSXS Depends on D7460 Differential Revision: https://phabricator.services.mozilla.com/D7461
devtools/client/shared/test/browser_dbg_listtabs-03.js
--- a/devtools/client/shared/test/browser_dbg_listtabs-03.js
+++ b/devtools/client/shared/test/browser_dbg_listtabs-03.js
@@ -6,56 +6,46 @@
 "use strict";
 
 /**
  * Make sure the listTabs request works as specified.
  */
 
 var { DebuggerServer } = require("devtools/server/main");
 var { DebuggerClient } = require("devtools/shared/client/debugger-client");
-var { Task } = require("devtools/shared/task");
 
 const TAB1_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
 
-var gClient;
-
-function test() {
+add_task(async function test() {
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
 
   const transport = DebuggerServer.connectPipe();
-  gClient = new DebuggerClient(transport);
-  gClient.connect().then(Task.async(function* ([aType, aTraits]) {
-    is(aType, "browser",
-      "Root actor should identify itself as a browser.");
-    const tab = yield addTab(TAB1_URL);
+  const client = new DebuggerClient(transport);
+  const [type] = await client.connect();
+  is(type, "browser", "Root actor should identify itself as a browser.");
+  const tab = await addTab(TAB1_URL);
 
-    let { tabs } = yield gClient.listTabs();
-    is(tabs.length, 2, "Should be two tabs");
-    const tabGrip = tabs.filter(a => a.url == TAB1_URL).pop();
-    ok(tabGrip, "Should have an actor for the tab");
+  let { tabs } = await client.listTabs();
+  is(tabs.length, 2, "Should be two tabs");
+  const tabGrip = tabs.filter(a => a.url == TAB1_URL).pop();
+  ok(tabGrip, "Should have an actor for the tab");
 
-    let response = yield gClient.request({ to: tabGrip.actor, type: "attach" });
-    is(response.type, "tabAttached", "Should have attached");
-
-    response = yield gClient.listTabs();
-    tabs = response.tabs;
+  let [response, targetFront] = await client.attachTarget(tabGrip.actor);
+  is(response.type, "tabAttached", "Should have attached");
 
-    response = yield gClient.request({ to: tabGrip.actor, type: "detach" });
-    is(response.type, "detached", "Should have detached");
+  response = await client.listTabs();
+  tabs = response.tabs;
 
-    const newGrip = tabs.filter(a => a.url == TAB1_URL).pop();
-    is(newGrip.actor, tabGrip.actor, "Should have the same actor for the same tab");
+  response = await targetFront.detach();
+  is(response.type, "detached", "Should have detached");
+
+  const newGrip = tabs.filter(a => a.url == TAB1_URL).pop();
+  is(newGrip.actor, tabGrip.actor, "Should have the same actor for the same tab");
 
-    response = yield gClient.request({ to: tabGrip.actor, type: "attach" });
-    is(response.type, "tabAttached", "Should have attached");
-    response = yield gClient.request({ to: tabGrip.actor, type: "detach" });
-    is(response.type, "detached", "Should have detached");
+  [response, targetFront] = await client.attachTarget(tabGrip.actor);
+  is(response.type, "tabAttached", "Should have attached");
+  response = await targetFront.detach();
+  is(response.type, "detached", "Should have detached");
 
-    yield removeTab(tab);
-    yield gClient.close();
-    finish();
-  }));
-}
-
-registerCleanupFunction(function() {
-  gClient = null;
+  await removeTab(tab);
+  await client.close();
 });