diff --git a/testing/marionette/marionette-frame-manager.js b/testing/marionette/marionette-frame-manager.js index 9366a05423ad..5a6f6e9b7b8c 100644 --- a/testing/marionette/marionette-frame-manager.js +++ b/testing/marionette/marionette-frame-manager.js @@ -133,7 +133,7 @@ FrameManager.prototype = { } mm.sendAsyncMessage("Marionette:restart", {}); - return; + return oopFrame.id; } } @@ -149,6 +149,7 @@ FrameManager.prototype = { aFrame.specialPowersObserver = new specialpowers.SpecialPowersObserver(); aFrame.specialPowersObserver.init(mm); + return oopFrame.id; }, /* diff --git a/testing/marionette/marionette-server.js b/testing/marionette/marionette-server.js index 4218bc01ff9d..b4bb0891bbcb 100644 --- a/testing/marionette/marionette-server.js +++ b/testing/marionette/marionette-server.js @@ -141,6 +141,7 @@ function MarionetteServerConnection(aPrefix, aTransport, aServer) this.currentFrameElement = null; this.testName = null; this.mozBrowserClose = null; + this.oopFrameId = null; // frame ID of current remote frame, used for mozbrowserclose events } MarionetteServerConnection.prototype = { @@ -378,10 +379,12 @@ MarionetteServerConnection.prototype = { addFrameCloseListener: function MDA_addFrameCloseListener(action) { let curWindow = this.getCurrentWindow(); let self = this; - this.mozBrowserClose = function() { - curWindow.removeEventListener('mozbrowserclose', self.mozBrowserClose, true); - self.switchToGlobalMessageManager(); - self.sendError("The frame closed during the " + action + ", recovering to allow further communications", 500, null, self.command_id); + this.mozBrowserClose = function(e) { + if (e.target.id == self.oopFrameId) { + curWindow.removeEventListener('mozbrowserclose', self.mozBrowserClose, true); + self.switchToGlobalMessageManager(); + self.sendError("The frame closed during the " + action + ", recovering to allow further communications", 500, null, self.command_id); + } }; curWindow.addEventListener('mozbrowserclose', this.mozBrowserClose, true); }, @@ -2602,7 +2605,7 @@ MarionetteServerConnection.prototype = { this.sendToClient(message.json, -1); break; case "Marionette:switchToFrame": - this.curBrowser.frameManager.switchToFrame(message); + this.oopFrameId = this.curBrowser.frameManager.switchToFrame(message); this.messageManager = this.curBrowser.frameManager.currentRemoteFrame.messageManager.get(); break; case "Marionette:switchToModalOrigin":