Bug 844942 - Let switching to top-level frame work even when current frame is invalid, r=mdas
authorJonathan Griffin <jgriffin@mozilla.com>
Mon, 25 Feb 2013 13:24:19 -0800
changeset 122947 99f36af07e3b5bc446f38b4afac9faa4d4838690
parent 122946 c44f37baa96470725fd443921cec0a06d923eabc
child 122948 ea8134dfa48112e07bc36b85ed353fbd245b8340
push id1387
push userphilringnalda@gmail.com
push dateTue, 26 Feb 2013 22:32:56 +0000
treeherderfx-team@ad4cc4e97774 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdas
bugs844942
milestone22.0a1
Bug 844942 - Let switching to top-level frame work even when current frame is invalid, r=mdas
testing/marionette/marionette-actors.js
--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -180,17 +180,21 @@ MarionetteDriverActor.prototype = {
    * ChromeMessageSender.  Has no effect if the global ChromeMessageBroadcaster is already
    * in use.  If this replaces a frame-specific ChromeMessageSender, it removes the message
    * listeners from that sender, and then puts the corresponding frame script "to sleep",
    * which removes most of the message listeners from it as well.
    */
   switchToGlobalMessageManager: function MDA_switchToGlobalMM() {
     if (this.currentRemoteFrame !== null) {
       this.removeMessageManagerListeners(this.messageManager);
-      this.sendAsync("sleepSession");
+      try {
+        // this can fail if the frame is already gone
+        this.sendAsync("sleepSession");
+      }
+      catch(e) {}
     }
     this.messageManager = this.globalMessageManager;
     this.currentRemoteFrame = null;
   },
 
   /**
    * Helper method to send async messages to the content listener
    *
@@ -1200,17 +1204,17 @@ MarionetteDriverActor.prototype = {
         }
         checkTimer.initWithCallback(checkLoad.bind(this), 100, Ci.nsITimer.TYPE_ONE_SHOT);
       } else {
         this.sendError("Unable to locate frame: " + aRequest.value, 8, null,
                        command_id);
       }
     }
     else {
-      if ((aRequest.value == null) && (aRequest.element == null) &&
+      if ((!aRequest.value) && (!aRequest.element) &&
           (this.currentRemoteFrame !== null)) {
         // We're currently using a ChromeMessageSender for a remote frame, so this
         // request indicates we need to switch back to the top-level (parent) frame.
         // We'll first switch to the parent's (global) ChromeMessageBroadcaster, so
         // we send the message to the right listener.
         this.switchToGlobalMessageManager();
       }
       aRequest.command_id = command_id;