Bug 1492434 - Use a trait to differenciate browsing context target actors r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 03 Oct 2018 16:43:13 +0000
changeset 495164 9368d2715723b4f692b67ae088c125cbb26cb2ea
parent 495163 9cd5d357528d307a79a4568c141cc707c7424d75
child 495165 5099db41a664d28a75e0bc2c384a111bf5f2b044
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)
reviewersjdescottes
bugs1492434
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 1492434 - Use a trait to differenciate browsing context target actors r=jdescottes MozReview-Commit-ID: Gp0cjWDHCou Depends on D7414 Differential Revision: https://phabricator.services.mozilla.com/D7415
devtools/client/framework/target.js
devtools/server/actors/targets/browsing-context.js
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -214,20 +214,30 @@ function TabTarget({ form, client, chrom
 
   // isBrowsingContext is true for all target connected to an actor that inherits from
   // BrowsingContextTargetActor. It happens to be the case for almost all targets but:
   // * legacy add-ons (old bootstrapped add-ons)
   // * content process (browser content toolbox)
   // * xpcshell debugging (it uses ParentProcessTargetActor, which inherits from
   //                       BrowsingContextActor, but doesn't have any valid browsing
   //                       context to attach to.)
-  // Unfortunately, for now, because of bug 1492265, we don't flag xpcshell correctly
-  // as there is no way to identify the target actor correctly.
-  const isContentProcessTarget = this._form.actor.match(/conn\d+\.content-process\d+\/contentProcessTarget\d+/);
-  this._isBrowsingContext = !this.isLegacyAddon && !isContentProcessTarget;
+  // Starting with FF64, BrowsingContextTargetActor exposes a traits to help identify
+  // the target actors inheriting from it. It also help identify the xpcshell debugging
+  // target actor that doesn't have any valid browsing context.
+  // (Once FF63 is no longer supported, we can remove the `else` branch and only look
+  // for the traits)
+  if (this._form.traits && ("isBrowsingContext" in this._form.traits)) {
+    this._isBrowsingContext = this._form.traits.isBrowsingContext;
+  } else {
+    // browser content toolbox's form will be of the form:
+    //   server0.conn0.content-process0/contentProcessTarget7
+    const isContentProcessTarget =
+      this._form.actor.match(/conn\d+\.content-process\d+\/contentProcessTarget\d+/);
+    this._isBrowsingContext = !this.isLegacyAddon && !isContentProcessTarget;
+  }
 
   // Cache of already created targed-scoped fronts
   // [typeName:string => Front instance]
   this.fronts = new Map();
 }
 
 exports.TabTarget = TabTarget;
 
--- a/devtools/server/actors/targets/browsing-context.js
+++ b/devtools/server/actors/targets/browsing-context.js
@@ -453,17 +453,23 @@ const browsingContextTargetPrototype = {
 
   form() {
     assert(!this.exited,
                "form() shouldn't be called on exited browser actor.");
     assert(this.actorID,
                "Actor should have an actorID.");
 
     const response = {
-      actor: this.actorID
+      actor: this.actorID,
+      traits: {
+        // FF64+ exposes a new trait to help identify ParentProcessTargetActor used for
+        // xpcshell that isn't attached to any valid browsing context and so shouldn't
+        // be considered as a browsing context-inherited target on the client side.
+        isBrowsingContext: !!this.docShell,
+      },
     };
 
     // We may try to access window while the document is closing, then
     // accessing window throws. Also on xpcshell we are using this actor even if
     // there is no valid document.
     if (this.docShell && !this.docShell.isBeingDestroyed()) {
       response.title = this.title;
       response.url = this.url;