Bug 898074 - Don't send multiple responses to deleteSession, r=dhylands
authorJonathan Griffin <jgriffin@mozilla.com>
Thu, 01 Aug 2013 18:20:22 -0700
changeset 153324 86269ff48a4c1055776182a6696f39b0030c3276
parent 153323 8b67eb363e5c0e8e773e4b4cb4dec38af8651474
child 153325 4173c694fb4335c6de5c7a275fb07fe8c5688039
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhylands
bugs898074
milestone25.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 898074 - Don't send multiple responses to deleteSession, r=dhylands
testing/marionette/marionette-server.js
--- a/testing/marionette/marionette-server.js
+++ b/testing/marionette/marionette-server.js
@@ -175,17 +175,17 @@ MarionetteServerConnection.prototype = {
                        message: ('Marionette does not ' +
                                  'recognize the packet type "' +
                                  aPacket.type + '"') });
     }
   },
 
   onClosed: function MSC_onClosed(aStatus) {
     this.server._connectionClosed(this);
-    this.deleteSession();
+    this.sessionTearDown();
   },
 
   /**
    * Helper methods:
    */
 
   /**
    * Switches to the global ChromeMessageBroadcaster, potentially replacing a frame-specific
@@ -1923,17 +1923,18 @@ MarionetteServerConnection.prototype = {
       let winEnum = this.getWinEnumerator();
       while (winEnum.hasMoreElements()) {
         numOpenWindows += 1;
         winEnum.getNext(); 
       }
 
       // if there is only 1 window left, delete the session
       if (numOpenWindows === 1){
-        this.deleteSession();
+        this.sessionTearDown();
+        this.sendOk(command_id);
         return;
       }
 
       try{
         this.messageManager.removeDelayedFrameScript(FRAME_SCRIPT); 
         this.getCurrentWindow().close();
         this.sendOk(command_id);
       }
@@ -1948,18 +1949,17 @@ MarionetteServerConnection.prototype = {
    * Deletes the session.
    * 
    * If it is a desktop environment, it will close the session's tab and close all listeners
    *
    * If it is a B2G environment, it will make the main content listener sleep, and close
    * all other listeners. The main content listener persists after disconnect (it's the homescreen),
    * and can safely be reused.
    */
-  deleteSession: function MDA_deleteSession() {
-    let command_id = this.command_id = this.getCommandId();
+  sessionTearDown: function MDA_sessionTearDown() {
     if (this.curBrowser != null) {
       if (appName == "B2G") {
         this.globalMessageManager.broadcastAsyncMessage(
             "Marionette:sleepSession" + this.curBrowser.mainContentId, {});
         this.curBrowser.knownFrames.splice(
             this.curBrowser.knownFrames.indexOf(this.curBrowser.mainContentId), 1);
       }
       else {
@@ -1973,33 +1973,42 @@ MarionetteServerConnection.prototype = {
           this.globalMessageManager.broadcastAsyncMessage("Marionette:deleteSession" + this.browsers[win].knownFrames[i], {});
         }
       }
       let winEnum = this.getWinEnumerator();
       while (winEnum.hasMoreElements()) {
         winEnum.getNext().messageManager.removeDelayedFrameScript(FRAME_SCRIPT); 
       }
     }
-    this.sendOk(command_id);
     this.removeMessageManagerListeners(this.globalMessageManager);
     this.switchToGlobalMessageManager();
     // reset frame to the top-most frame
     this.curFrame = null;
     if (this.mainFrame) {
       this.mainFrame.focus();
     }
     this.curBrowser = null;
     try {
       this.importedScripts.remove(false);
     }
     catch (e) {
     }
   },
 
   /**
+   * Processes the 'deleteSession' request from the client by tearing down
+   * the session and responding 'ok'.
+   */
+  deleteSession: function MDA_sessionTearDown() {
+    let command_id = this.command_id = this.getCommandId();
+    this.sessionTearDown();
+    this.sendOk(command_id);
+  },
+
+  /**
    * Returns the current status of the Application Cache
    */
   getAppCacheStatus: function MDA_getAppCacheStatus(aRequest) {
     this.command_id = this.getCommandId();
     this.sendAsync("getAppCacheStatus", {}, this.command_id);
   },
 
   _emu_cb_id: 0,