Bug 1471795 - Part 2: Introduce Runtime class. r?jdescottes draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Wed, 25 Jul 2018 17:33:03 +0900
changeset 822426 e39eb586b3fca783674975bb6cbba413ab128a53
parent 822425 d7aa49eac4daa5e7dbfc5f223d5bbe3e659ab7bb
child 822427 e40e0c65ed3b487a522c1f6388edf814d5cccd2c
push id117369
push userbmo:dakatsuka@mozilla.com
push dateWed, 25 Jul 2018 09:09:50 +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;