Bug 1494170: Show proper runtime's name and version. r=jdescottes
☠☠ backed out by 452e1706609f ☠ ☠
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Mon, 01 Oct 2018 12:38:53 +0900
changeset 495340 b1c901b2d6619e0ab52a7d7fb3bc9082204eeb57
parent 495339 41216e689dda9bafb0ce5cf852d517a1c0b9727f
child 495341 567f15a5455a2a08226afb80f05d5e5444bf8bcd
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
bugs1494170
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 1494170: Show proper runtime's name and version. r=jdescottes Summary: Depends on D6881 Reviewers: jdescottes Subscribers: MarcoM, ochameau, yulia Bug #: 1494170 Differential Revision: https://phabricator.services.mozilla.com/D7036
devtools/client/aboutdebugging-new/src/actions/runtimes.js
devtools/client/aboutdebugging-new/src/components/RuntimePage.js
devtools/client/aboutdebugging-new/src/modules/runtimes-state-helper.js
devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js
@@ -61,28 +61,41 @@ async function createClientForRuntime(ru
     return createNetworkClient(host, port);
   } else if (type === RUNTIMES.USB) {
     return createUSBClient(runtime.socketPath);
   }
 
   return null;
 }
 
+async function getRuntimeInfo(client) {
+  const deviceFront = await client.mainRoot.getFront("device");
+  const { brandName: name, version } = await deviceFront.getDescription();
+
+  return {
+    icon: "chrome://branding/content/icon64.png",
+    name,
+    version,
+  };
+}
+
 function connectRuntime(id) {
   return async (dispatch, getState) => {
     dispatch({ type: CONNECT_RUNTIME_START });
     try {
       const runtime = findRuntimeById(id, getState().runtimes);
       const client = await createClientForRuntime(runtime);
+      const info = await getRuntimeInfo(client);
 
       dispatch({
         type: CONNECT_RUNTIME_SUCCESS,
         runtime: {
           id,
           client,
+          info,
           type: runtime.type,
         }
       });
     } catch (e) {
       dispatch({ type: CONNECT_RUNTIME_FAILURE, error: e.message });
     }
   };
 }
--- a/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
+++ b/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
@@ -18,54 +18,58 @@ const InspectAction = createFactory(requ
 const RuntimeInfo = createFactory(require("./RuntimeInfo"));
 const ServiceWorkerAction = createFactory(require("./debugtarget/ServiceWorkerAction"));
 const TabDetail = createFactory(require("./debugtarget/TabDetail"));
 const TemporaryExtensionAction = createFactory(require("./debugtarget/TemporaryExtensionAction"));
 const TemporaryExtensionInstaller =
   createFactory(require("./debugtarget/TemporaryExtensionInstaller"));
 const WorkerDetail = createFactory(require("./debugtarget/WorkerDetail"));
 
-const Services = require("Services");
 const { DEBUG_TARGET_PANE } = require("../constants");
+const { getCurrentRuntimeInfo } = require("../modules/runtimes-state-helper");
 
 class RuntimePage extends PureComponent {
   static get propTypes() {
     return {
       collapsibilities: PropTypes.object.isRequired,
       dispatch: PropTypes.func.isRequired,
       installedExtensions: PropTypes.arrayOf(PropTypes.object).isRequired,
       otherWorkers: PropTypes.arrayOf(PropTypes.object).isRequired,
+      runtimeInfo: PropTypes.object,
       serviceWorkers: PropTypes.arrayOf(PropTypes.object).isRequired,
       sharedWorkers: PropTypes.arrayOf(PropTypes.object).isRequired,
       tabs: PropTypes.arrayOf(PropTypes.object).isRequired,
       temporaryExtensions: PropTypes.arrayOf(PropTypes.object).isRequired,
     };
   }
 
   render() {
     const {
       collapsibilities,
       dispatch,
       installedExtensions,
       otherWorkers,
+      runtimeInfo,
       serviceWorkers,
       sharedWorkers,
       tabs,
       temporaryExtensions,
     } = this.props;
 
+    if (!runtimeInfo) {
+      // runtimeInfo can be null when the selectPage action navigates from a runtime A
+      // to a runtime B (between unwatchRuntime and watchRuntime).
+      return null;
+    }
+
     return dom.article(
       {
         className: "page js-runtime-page",
       },
-      RuntimeInfo({
-        icon: "chrome://branding/content/icon64.png",
-        name: Services.appinfo.name,
-        version: Services.appinfo.version,
-      }),
+      RuntimeInfo(runtimeInfo),
       TemporaryExtensionInstaller({ dispatch }),
       Localized(
         {
           id: "about-debugging-runtime-temporary-extensions",
           attrs: { name: true }
         },
         DebugTargetPane({
           actionComponent: TemporaryExtensionAction,
@@ -156,16 +160,17 @@ class RuntimePage extends PureComponent 
   }
 }
 
 const mapStateToProps = state => {
   return {
     collapsibilities: state.ui.debugTargetCollapsibilities,
     installedExtensions: state.debugTargets.installedExtensions,
     otherWorkers: state.debugTargets.otherWorkers,
+    runtimeInfo: getCurrentRuntimeInfo(state.runtimes),
     serviceWorkers: state.debugTargets.serviceWorkers,
     sharedWorkers: state.debugTargets.sharedWorkers,
     tabs: state.debugTargets.tabs,
     temporaryExtensions: state.debugTargets.temporaryExtensions,
   };
 };
 
 module.exports = connect(mapStateToProps)(RuntimePage);
--- a/devtools/client/aboutdebugging-new/src/modules/runtimes-state-helper.js
+++ b/devtools/client/aboutdebugging-new/src/modules/runtimes-state-helper.js
@@ -10,16 +10,22 @@ function getCurrentRuntime(runtimesState
 }
 exports.getCurrentRuntime = getCurrentRuntime;
 
 function getCurrentClient(runtimesState) {
   return getCurrentRuntime(runtimesState).client;
 }
 exports.getCurrentClient = getCurrentClient;
 
+function getCurrentRuntimeInfo(runtimesState) {
+  const runtime = getCurrentRuntime(runtimesState);
+  return runtime ? runtime.info : null;
+}
+exports.getCurrentRuntimeInfo = getCurrentRuntimeInfo;
+
 function findRuntimeById(id, runtimesState) {
   const allRuntimes = [
     ...runtimesState.networkRuntimes,
     ...runtimesState.thisFirefoxRuntimes,
     ...runtimesState.usbRuntimes,
   ];
   return allRuntimes.find(r => r.id === id);
 }
--- a/devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
+++ b/devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
@@ -35,27 +35,27 @@ function RuntimesState(networkRuntimes =
     }],
     usbRuntimes: [],
   };
 }
 
 function runtimesReducer(state = RuntimesState(), action) {
   switch (action.type) {
     case CONNECT_RUNTIME_SUCCESS: {
-      const { id, client } = action.runtime;
+      const { id, client, info } = action.runtime;
 
       // Find the array of runtimes that contains the updated runtime.
       const runtime = findRuntimeById(id, state);
       const key = TYPE_TO_RUNTIMES_KEY[runtime.type];
       const runtimesToUpdate = state[key];
 
       // Add the new client to the runtime.
       const updatedRuntimes = runtimesToUpdate.map(r => {
         if (r.id === id) {
-          return Object.assign({}, r, { client });
+          return Object.assign({}, r, { client, info });
         }
         return r;
       });
       return Object.assign({}, state, { [key]: updatedRuntimes });
     }
 
     case DISCONNECT_RUNTIME_SUCCESS: {
       const { id } = action.runtime;
@@ -63,17 +63,17 @@ function runtimesReducer(state = Runtime
       // Find the array of runtimes that contains the updated runtime.
       const runtime = findRuntimeById(id, state);
       const key = TYPE_TO_RUNTIMES_KEY[runtime.type];
       const runtimesToUpdate = state[key];
 
       // Remove the client from the updated runtime.
       const updatedRuntimes = runtimesToUpdate.map(r => {
         if (r.id === id) {
-          return Object.assign({}, r, { client: null });
+          return Object.assign({}, r, { client: null, info: null });
         }
         return r;
       });
       return Object.assign({}, state, { [key]: updatedRuntimes });
     }
 
     case NETWORK_LOCATIONS_UPDATED: {
       const { locations } = action;