Bug 1471795 - Part 2: Introduce Runtime class. r?jdescottes draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 26 Jul 2018 17:52:10 +0900
changeset 822891 a1c75868748a98e6391f74763fb7203e7596e20e
parent 822890 ef8e0acc6b1167c9e5d02d94e3d6d653fcfd252a
child 822892 5ace67533bea4e333b397b3a9d2bdfa27e45e17c
push id117509
push userbmo:dakatsuka@mozilla.com
push dateThu, 26 Jul 2018 08:57:32 +0000
reviewersjdescottes
bugs1471795
milestone63.0a1
Bug 1471795 - Part 2: Introduce Runtime class. r?jdescottes MozReview-Commit-ID: EajaVnn9kR3
devtools/client/aboutdebugging-new/aboutdebugging.js
devtools/client/aboutdebugging-new/src/components/App.js
devtools/client/aboutdebugging-new/src/moz.build
devtools/client/aboutdebugging-new/src/runtimes/moz.build
devtools/client/aboutdebugging-new/src/runtimes/runtime.js
devtools/client/aboutdebugging-new/src/runtimes/this-firefox.js
--- a/devtools/client/aboutdebugging-new/aboutdebugging.js
+++ b/devtools/client/aboutdebugging-new/aboutdebugging.js
@@ -12,27 +12,30 @@ const { require } = BrowserLoader({
 });
 const Services = require("Services");
 
 const { createFactory } =
   require("devtools/client/shared/vendor/react");
 const { render, unmountComponentAtNode } =
   require("devtools/client/shared/vendor/react-dom");
 
+const ThisFirefox = require("./src/runtimes/this-firefox");
+
 const App = createFactory(require("./src/components/App"));
 
 const AboutDebugging = {
   init() {
     if (!Services.prefs.getBoolPref("devtools.enabled", true)) {
       // If DevTools are disabled, navigate to about:devtools.
       window.location = "about:devtools?reason=AboutDebugging";
       return;
     }
 
-    render(App(), this.mount);
+    const thisFirefox = new ThisFirefox();
+    render(App({ thisFirefox }), this.mount);
   },
 
   destroy() {
     unmountComponentAtNode(this.mount);
   },
 
   get mount() {
     return document.getElementById("mount");
--- a/devtools/client/aboutdebugging-new/src/components/App.js
+++ b/devtools/client/aboutdebugging-new/src/components/App.js
@@ -1,18 +1,27 @@
 /* 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 { PureComponent } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
+const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+
+const ThisFirefox = require("../runtimes/this-firefox");
 
 class App extends PureComponent {
+  static get propTypes() {
+    return {
+      thisFirefox: PropTypes.instanceOf(ThisFirefox).isRequired,
+    };
+  }
+
   render() {
     return dom.div(
       {
         className: "app",
       },
     );
   }
 }
--- a/devtools/client/aboutdebugging-new/src/moz.build
+++ b/devtools/client/aboutdebugging-new/src/moz.build
@@ -1,7 +1,8 @@
 # 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/.
 
 DIRS += [
     'components',
+    'runtimes',
 ]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/src/runtimes/moz.build
@@ -0,0 +1,8 @@
+# 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/.
+
+DevToolsModules(
+    'runtime.js',
+    'this-firefox.js',
+)
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/src/runtimes/runtime.js
@@ -0,0 +1,13 @@
+/* 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";
+
+/**
+ * This class represents a runtime, such as a remote Firefox.
+ */
+class Runtime {
+}
+
+module.exports = Runtime;
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/src/runtimes/this-firefox.js
@@ -0,0 +1,16 @@
+/* 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 Runtime = require("./runtime");
+
+/**
+ * This class represents the Firefox instance which runs in the same environment that
+ * opened about:debugging.
+ */
+class ThisFirefox extends Runtime {
+}
+
+module.exports = ThisFirefox;