Bug 1602371 - Remove csp and contentPrincipal getters in LocalTabTargetFront r=ochameau
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 13 Dec 2019 10:00:25 +0000
changeset 506858 8ab51c4822d4059d03a0021524a8e6145adf7bcb
parent 506857 09beec6ec35dfe9e8420d2923860094293fd136b
child 506859 f8c1648fb4d0e49bd8353b33ee72809ec79d8f47
push id36913
push useropoprus@mozilla.com
push dateFri, 13 Dec 2019 16:53:24 +0000
treeherdermozilla-central@1ed684598bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1602371
milestone73.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 1602371 - Remove csp and contentPrincipal getters in LocalTabTargetFront r=ochameau Depends on D56327. Not reason to make target-mixin more complex for this workaround which already has access to the tab object. Differential Revision: https://phabricator.services.mozilla.com/D56330
devtools/client/shared/link.js
devtools/shared/fronts/targets/local-tab.js
devtools/shared/fronts/targets/target-mixin.js
--- a/devtools/client/shared/link.js
+++ b/devtools/client/shared/link.js
@@ -57,19 +57,18 @@ exports.openDocLink = async function(url
 exports.openContentLink = async function(url, options = {}) {
   const top = _getTopWindow();
   if (!top) {
     return;
   }
   if (!options.triggeringPrincipal && top.gBrowser) {
     const tab = top.gBrowser.selectedTab;
     if (TargetFactory.isKnownTab(tab)) {
-      const target = await TargetFactory.forTab(tab);
-      options.triggeringPrincipal = target.contentPrincipal;
-      options.csp = target.csp;
+      options.triggeringPrincipal = tab.linkedBrowser.contentPrincipal;
+      options.csp = tab.linkedBrowser.csp;
     }
   }
   top.openWebLinkIn(url, "tab", options);
 };
 
 /**
  * Open a trusted |url| in a new tab using the SystemPrincipal.
  *
--- a/devtools/shared/fronts/targets/local-tab.js
+++ b/devtools/shared/fronts/targets/local-tab.js
@@ -42,22 +42,16 @@ class LocalTabTargetFront extends Browsi
   }
 
   get isLocalTab() {
     return true;
   }
   get tab() {
     return this._tab;
   }
-  get contentPrincipal() {
-    return this.tab.linkedBrowser.contentPrincipal;
-  }
-  get csp() {
-    return this.tab.linkedBrowser.csp;
-  }
   toString() {
     return `Target:${this.tab}`;
   }
 
   /**
    * Listen to the different events.
    */
   _setupTabListeners() {
--- a/devtools/shared/fronts/targets/target-mixin.js
+++ b/devtools/shared/fronts/targets/target-mixin.js
@@ -166,34 +166,16 @@ function TargetMixin(parentClass) {
     get isLocalTab() {
       return false;
     }
 
     get tab() {
       return null;
     }
 
-    /**
-     * For local tabs, returns the tab's contentPrincipal, which can be used as a
-     * `triggeringPrincipal` when opening links.  However, this is a hack as it is not
-     * correct for subdocuments and it won't work for remote debugging.  Bug 1467945 hopes
-     * to devise a better approach.
-     */
-    get contentPrincipal() {
-      return null;
-    }
-
-    /**
-     * Similar to the above get contentPrincipal(), the get csp()
-     * returns the CSP which should be used for opening links.
-     */
-    get csp() {
-      return null;
-    }
-
     // Get a promise of the RootActor's form
     get root() {
       return this.client.mainRoot.rootForm;
     }
 
     // Get a Front for a target-scoped actor.
     // i.e. an actor served by RootActor.listTabs or RootActorActor.getTab requests
     async getFront(typeName) {