Bug 1509315 - Pass the full target form to all BrowsingContextTargetFront instances. r=yulia
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 27 Nov 2018 21:47:52 +0000
changeset 507604 ce2018b0349dc53c3394559a20e729797034ce8c
parent 507603 ed3560460fe93c21664313f318c25cf2cb5eefc6
child 507605 18f76c41550516fb1cf4bcbe8bfaf82d480322e7
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia
bugs1509315
milestone65.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 1509315 - Pass the full target form to all BrowsingContextTargetFront instances. r=yulia For now, we only pass { actor } for all tab target fronts created via DebuggerClient.attachTarget, whereas parent process target fronts were passing the full form from RootFront.getProcess. MozReview-Commit-ID: 1H2NxFv8glY Differential Revision: https://phabricator.services.mozilla.com/D12730
devtools/client/debugger/test/mochitest/head.js
devtools/client/framework/target.js
devtools/client/shared/test/browser_dbg_listtabs-03.js
devtools/client/shared/test/helper_workers.js
devtools/docs/backend/client-api.md
devtools/server/tests/browser/browser_webextension_inspected_window.js
devtools/server/tests/unit/head_dbg.js
devtools/shared/client/debugger-client.js
--- a/devtools/client/debugger/test/mochitest/head.js
+++ b/devtools/client/debugger/test/mochitest/head.js
@@ -903,17 +903,17 @@ function findTab(tabs, url) {
       return tab;
     }
   }
   return null;
 }
 
 function attachTarget(client, tab) {
   info("Attaching to tab with url '" + tab.url + "'.");
-  return client.attachTarget(tab.actor);
+  return client.attachTarget(tab);
 }
 
 function listWorkers(targetFront) {
   info("Listing workers.");
   return targetFront.listWorkers();
 }
 
 function findWorker(workers, url) {
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -524,17 +524,17 @@ Target.prototype = {
     // Attach the target actor
     const attachBrowsingContextTarget = async () => {
       // Some BrowsingContextTargetFront are already instantiated and passed as
       // contructor's argument, like for ParentProcessTargetActor.
       // For them, we only need to attach them.
       // The call to attachTarget is to be removed once all Target are having a front
       // passed as contructor's argument.
       if (!this.activeTab) {
-        const [, targetFront] = await this._client.attachTarget(this.form.actor);
+        const [, targetFront] = await this._client.attachTarget(this.form);
         this.activeTab = targetFront;
       } else {
         await this.activeTab.attach();
       }
 
       this.activeTab.on("tabNavigated", this._onTabNavigated);
       this._onFrameUpdate = packet => {
         this.emit("frame-update", packet);
--- a/devtools/client/shared/test/browser_dbg_listtabs-03.js
+++ b/devtools/client/shared/test/browser_dbg_listtabs-03.js
@@ -24,28 +24,28 @@ add_task(async function test() {
   is(type, "browser", "Root actor should identify itself as a browser.");
   const tab = await addTab(TAB1_URL);
 
   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, targetFront] = await client.attachTarget(tabGrip.actor);
+  let [response, targetFront] = await client.attachTarget(tabGrip);
   is(response.type, "tabAttached", "Should have attached");
 
   response = await client.listTabs();
   tabs = response.tabs;
 
   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, targetFront] = await client.attachTarget(tabGrip.actor);
+  [response, targetFront] = await client.attachTarget(tabGrip);
   is(response.type, "tabAttached", "Should have attached");
   response = await targetFront.detach();
   is(response.type, "detached", "Should have detached");
 
   await removeTab(tab);
   await client.close();
 });
--- a/devtools/client/shared/test/helper_workers.js
+++ b/devtools/client/shared/test/helper_workers.js
@@ -111,17 +111,17 @@ function findTab(tabs, url) {
       return tab;
     }
   }
   return null;
 }
 
 function attachTarget(client, tab) {
   info("Attaching to tab with url '" + tab.url + "'.");
-  return client.attachTarget(tab.actor);
+  return client.attachTarget(tab);
 }
 
 function listWorkers(targetFront) {
   info("Listing workers.");
   return targetFront.listWorkers();
 }
 
 function findWorker(workers, url) {
--- a/devtools/docs/backend/client-api.md
+++ b/devtools/docs/backend/client-api.md
@@ -73,17 +73,17 @@ Attaching to a browser tab requires enum
 ```javascript
 function attachToTab() {
   // Get the list of tabs to find the one to attach to.
   client.listTabs().then((response) => {
     // Find the active tab.
     let tab = response.tabs[response.selected];
 
     // Attach to the tab.
-    client.attachTarget(tab.actor).then(([response, targetFront]) => {
+    client.attachTarget(tab).then(([response, targetFront]) => {
       if (!targetFront) {
         return;
       }
 
       // Now the targetFront is ready and can be used.
 
       // Attach listeners for client events.
       targetFront.addListener("tabNavigated", onTab);
@@ -181,17 +181,17 @@ function shutdownDebugger() {
  * Start debugging the current tab.
  */
 function debugTab() {
   // Get the list of tabs to find the one to attach to.
   client.listTabs().then(response => {
     // Find the active tab.
     let tab = response.tabs[response.selected];
     // Attach to the tab.
-    client.attachTarget(tab.actor).then(([response, targetFront]) => {
+    client.attachTarget(tab).then(([response, targetFront]) => {
       if (!targetFront) {
         return;
       }
 
       // Attach to the thread (context).
       client.attachThread(response.threadActor, (response, thread) => {
         if (!thread) {
           return;
--- a/devtools/server/tests/browser/browser_webextension_inspected_window.js
+++ b/devtools/server/tests/browser/browser_webextension_inspected_window.js
@@ -21,17 +21,17 @@ async function setup(pageUrl) {
     lineNumber: 1,
     addonId: extension.id,
   };
 
   const target = await addTabTarget(pageUrl);
 
   const { client, form } = target;
 
-  const [, targetFront] = await client.attachTarget(form.actor);
+  const [, targetFront] = await client.attachTarget(form);
 
   const [, consoleClient] = await client.attachConsole(form.consoleActor, []);
 
   const inspectedWindowFront = await target.getFront("webExtensionInspectedWindow");
 
   return {
     client, form,
     targetFront, consoleClient,
--- a/devtools/server/tests/unit/head_dbg.js
+++ b/devtools/server/tests/unit/head_dbg.js
@@ -144,17 +144,17 @@ function findTab(tabs, title) {
       return tab;
     }
   }
   return null;
 }
 
 function attachTarget(client, tab) {
   dump("Attaching to tab with title '" + tab.title + "'.\n");
-  return client.attachTarget(tab.actor);
+  return client.attachTarget(tab);
 }
 
 function waitForNewSource(threadClient, url) {
   dump("Waiting for new source with url '" + url + "'.\n");
   return waitForEvent(threadClient, "newSource", function(packet) {
     return packet.source.url === url;
   });
 }
@@ -322,17 +322,17 @@ function getTestTab(client, title, callb
     callback(null);
   });
 }
 
 // Attach to |client|'s tab whose title is |title|; pass |callback| the
 // response packet and a TargetFront instance referring to that tab.
 function attachTestTab(client, title, callback) {
   getTestTab(client, title, function(tab) {
-    client.attachTarget(tab.actor).then(([response, targetFront]) => {
+    client.attachTarget(tab).then(([response, targetFront]) => {
       callback(response, targetFront);
     });
   });
 }
 
 // Attach to |client|'s tab whose title is |title|, and then attach to
 // that tab's thread. Pass |callback| the thread attach response packet, a
 // TargetFront referring to the tab, and a ThreadClient referring to the
--- a/devtools/shared/client/debugger-client.js
+++ b/devtools/shared/client/debugger-client.js
@@ -352,23 +352,24 @@ DebuggerClient.prototype = {
    * Attach to a target actor:
    *
    *  - start watching for new documents (emits `tabNativated` messages)
    *  - start watching for inner iframe updates (emits `frameUpdate` messages)
    *  - retrieve the thread actor:
    *    Instantiates a new ThreadActor that can be later attached to in order to
    *    debug JS sources in the document.
    *
-   * @param string targetActor
-   *        The target actor ID for the tab to attach.
+   * @param string targetActorForm
+   *        The target actor form for the tab to attach.
    */
-  attachTarget: async function(targetActor) {
-    let front = this._frontPool.actor(targetActor);
+  attachTarget: async function(targetActorForm) {
+    const actorID = targetActorForm.actor;
+    let front = this._frontPool.actor(actorID);
     if (!front) {
-      front = new BrowsingContextTargetFront(this, { actor: targetActor });
+      front = new BrowsingContextTargetFront(this, targetActorForm);
       this._frontPool.manage(front);
     }
 
     const response = await front.attach();
     return [response, front];
   },
 
   /**