Bug 1462232 - Links don't work if devtools are in a separate window. r=nchevobbe draft
authorBelén Albeza <balbeza@mozilla.com>
Thu, 24 May 2018 18:01:39 +0200
changeset 799395 c7d1219ba158b152922a7eea9973236243deebfe
parent 799267 043e4ab6e72469ed8121f4da98dcdfef983a49d9
push id111036
push userbalbeza@mozilla.com
push dateThu, 24 May 2018 16:02:39 +0000
reviewersnchevobbe
bugs1462232
milestone62.0a1
Bug 1462232 - Links don't work if devtools are in a separate window. r=nchevobbe MozReview-Commit-ID: 2yK63fjjXvs
devtools/client/application/initializer.js
devtools/client/application/src/components/App.js
devtools/client/application/src/components/WorkerList.js
devtools/client/application/src/components/WorkerListEmpty.js
--- a/devtools/client/application/initializer.js
+++ b/devtools/client/application/initializer.js
@@ -32,26 +32,16 @@ window.Application = {
     this.mount = document.querySelector("#mount");
     this.toolbox = toolbox;
     this.client = toolbox.target.client;
 
     this.store = configureStore();
     this.actions = bindActionCreators(actions, this.store.dispatch);
 
     const serviceContainer = {
-      openWebLink(url) {
-        let win = toolbox.doc.defaultView.top;
-        win.openWebLinkIn(url, "tab", { relatedToCurrent: true });
-      },
-
-      openTrustedLink(url) {
-        let win = toolbox.doc.defaultView.top;
-        win.openTrustedLinkIn(url, "tab", { relatedToCurrent: true });
-      },
-
       selectTool(toolId) {
         return toolbox.selectTool(toolId);
       }
     };
 
     // Render the root Application component.
     const app = App({ client: this.client, serviceContainer });
     render(Provider({ store: this.store }, app), this.mount);
--- a/devtools/client/application/src/components/App.js
+++ b/devtools/client/application/src/components/App.js
@@ -32,17 +32,17 @@ class App extends Component {
     workers = workers.filter((x) => new URL(x.url).hostname === domain);
     const isEmpty = workers.length === 0;
 
     return (
       main(
         { className: `application ${isEmpty ? "application--empty" : ""}` },
         isEmpty
           ? WorkerListEmpty({ serviceContainer })
-          : WorkerList({ workers, client, serviceContainer })
+          : WorkerList({ workers, client })
       )
     );
   }
 }
 
 // Exports
 
 module.exports = connect(
--- a/devtools/client/application/src/components/WorkerList.js
+++ b/devtools/client/application/src/components/WorkerList.js
@@ -1,36 +1,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
+const { openTrustedLink } = require("devtools/client/shared/link");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 const { createFactory, Component } = require("devtools/client/shared/vendor/react");
 const { a, article, footer, h1, ul } = require("devtools/client/shared/vendor/react-dom-factories");
 const Worker = createFactory(require("./Worker"));
 
 /**
  * This component handles the list of service workers displayed in the application panel
  * and also displays a suggestion to use about debugging for debugging other service
  * workers.
  */
 class WorkerList extends Component {
   static get propTypes() {
     return {
       client: PropTypes.object.isRequired,
       workers: PropTypes.object.isRequired,
-      serviceContainer: PropTypes.object.isRequired,
     };
   }
 
   render() {
-    const { workers, client, serviceContainer } = this.props;
-    const { openTrustedLink } = serviceContainer;
+    const { workers, client } = this.props;
 
     return [
       article({ className: "workers-container" },
         h1({}, "Service Workers"),
         ul({},
           workers.map(worker => Worker({
             client,
             debugDisabled: false,
--- a/devtools/client/application/src/components/WorkerListEmpty.js
+++ b/devtools/client/application/src/components/WorkerListEmpty.js
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
+const { openWebLink, openTrustedLink } = require("devtools/client/shared/link");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 const { Component } = require("devtools/client/shared/vendor/react");
 const { a, article, p, li, ul } = require("devtools/client/shared/vendor/react-dom-factories");
 const DOC_URL = "https://developer.mozilla.org/docs/Web/API/Service_Worker_API/Using_Service_Workers" +
   "?utm_source=devtools&utm_medium=sw-panel-blank";
 
 /**
  * This component displays help information when no service workers are found for the
@@ -25,21 +26,21 @@ class WorkerListEmpty extends Component 
     this.props.serviceContainer.selectTool("webconsole");
   }
 
   switchToDebugger() {
     this.props.serviceContainer.selectTool("jsdebugger");
   }
 
   openAboutDebugging() {
-    this.props.serviceContainer.openTrustedLink("about:debugging#workers");
+    openTrustedLink("about:debugging#workers");
   }
 
   openDocumentation() {
-    this.props.serviceContainer.openWebLink(DOC_URL);
+    openWebLink(DOC_URL);
   }
 
   render() {
     return article(
       { className: "worker-list-empty" },
       p(
         {},
         "You need to register a Service Worker to inspect it here.",