Bug 1065933 - only handle mozbrowserclose events from current frame, r=jgriffin

This commit is contained in:
Malini Das 2014-10-08 12:43:57 -04:00
parent bb25e23081
commit ac4d50c278
2 changed files with 10 additions and 6 deletions

View File

@ -133,7 +133,7 @@ FrameManager.prototype = {
} }
mm.sendAsyncMessage("Marionette:restart", {}); mm.sendAsyncMessage("Marionette:restart", {});
return; return oopFrame.id;
} }
} }
@ -149,6 +149,7 @@ FrameManager.prototype = {
aFrame.specialPowersObserver = new specialpowers.SpecialPowersObserver(); aFrame.specialPowersObserver = new specialpowers.SpecialPowersObserver();
aFrame.specialPowersObserver.init(mm); aFrame.specialPowersObserver.init(mm);
return oopFrame.id;
}, },
/* /*

View File

@ -141,6 +141,7 @@ function MarionetteServerConnection(aPrefix, aTransport, aServer)
this.currentFrameElement = null; this.currentFrameElement = null;
this.testName = null; this.testName = null;
this.mozBrowserClose = null; this.mozBrowserClose = null;
this.oopFrameId = null; // frame ID of current remote frame, used for mozbrowserclose events
} }
MarionetteServerConnection.prototype = { MarionetteServerConnection.prototype = {
@ -378,10 +379,12 @@ MarionetteServerConnection.prototype = {
addFrameCloseListener: function MDA_addFrameCloseListener(action) { addFrameCloseListener: function MDA_addFrameCloseListener(action) {
let curWindow = this.getCurrentWindow(); let curWindow = this.getCurrentWindow();
let self = this; let self = this;
this.mozBrowserClose = function() { this.mozBrowserClose = function(e) {
curWindow.removeEventListener('mozbrowserclose', self.mozBrowserClose, true); if (e.target.id == self.oopFrameId) {
self.switchToGlobalMessageManager(); curWindow.removeEventListener('mozbrowserclose', self.mozBrowserClose, true);
self.sendError("The frame closed during the " + action + ", recovering to allow further communications", 500, null, self.command_id); 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); curWindow.addEventListener('mozbrowserclose', this.mozBrowserClose, true);
}, },
@ -2602,7 +2605,7 @@ MarionetteServerConnection.prototype = {
this.sendToClient(message.json, -1); this.sendToClient(message.json, -1);
break; break;
case "Marionette:switchToFrame": case "Marionette:switchToFrame":
this.curBrowser.frameManager.switchToFrame(message); this.oopFrameId = this.curBrowser.frameManager.switchToFrame(message);
this.messageManager = this.curBrowser.frameManager.currentRemoteFrame.messageManager.get(); this.messageManager = this.curBrowser.frameManager.currentRemoteFrame.messageManager.get();
break; break;
case "Marionette:switchToModalOrigin": case "Marionette:switchToModalOrigin":