Bug 917479 - Starting a simulator changes host and port settings. r=ochameau
authorPaul Rouget <paul@mozilla.com>
Tue, 01 Oct 2013 17:38:51 -0400
changeset 149523 d079bd51114c541d4079010e15cdf8522e7cec07
parent 149522 49e797ce0f2226550cc9bb45d9c6fab6e4914bc4
child 149524 30d25df61046d46ba925523249ed5222eba9c9e6
push id2912
push userryanvm@gmail.com
push dateTue, 01 Oct 2013 21:39:20 +0000
treeherderfx-team@d079bd51114c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs917479
milestone27.0a1
Bug 917479 - Starting a simulator changes host and port settings. r=ochameau
browser/devtools/app-manager/content/connection-footer.js
--- a/browser/devtools/app-manager/content/connection-footer.js
+++ b/browser/devtools/app-manager/content/connection-footer.js
@@ -115,16 +115,17 @@ let UI = {
   },
 
   installSimulator: function() {
     let url = "https://developer.mozilla.org/docs/Mozilla/Firefox_OS/Using_the_App_Manager#Simulator";
     window.open(url);
   },
 
   startSimulator: function(version) {
+    this._portBeforeSimulatorStarted = this.connection.port;
     let port = ConnectionManager.getFreeTCPPort();
     let simulator = Simulator.getByVersion(version);
     if (!simulator) {
       this.connection.log("Error: can't find simulator: " + version);
       return;
     }
     if (!simulator.launch) {
       this.connection.log("Error: invalid simulator: " + version);
@@ -147,16 +148,22 @@ let UI = {
         this.connection.connect();
       });
     document.body.classList.remove("show-simulators");
   },
 
   _onSimulatorConnected: function() {
     this.connection.log("Connected to simulator.");
     this.connection.keepConnecting = false;
+
+    // This doesn't change the current (successful) connection,
+    // but makes sure that when the simulator is disconnected, the
+    // connection doesn't end up with a random port number (from
+    // getFreeTCPPort).
+    this.connection.port = this._portBeforeSimulatorStarted;
   },
 
   _onSimulatorDisconnected: function() {
     this.connection.off("connected", this._onSimulatorConnected);
   },
 
   connectToAdbDevice: function(name) {
     let device = Devices.getByName(name);