Bug 1051114 - 400 MozInterAppMessagePort registered on frame message manager r=bent

This commit is contained in:
Fabrice Desré 2014-08-11 10:37:09 -07:00
parent 9da0787380
commit 1b2c3f60c8
2 changed files with 16 additions and 2 deletions

View File

@ -804,6 +804,13 @@ this.InterAppCommService = {
if (pair.publisher.target === aTarget ||
pair.subscriber.target === aTarget) {
messagePortIDs.push(messagePortID);
// Send a shutdown message to the part of the pair that is still alive.
let actor = pair.publisher.target === aTarget ? pair.subscriber
: pair.publisher;
actor.target.sendAsyncMessage("InterAppMessagePort:Shutdown",
{ manifestURL: actor.manifestURL,
pageURL: actor.pageURL,
messagePortID: messagePortID });
}
}
messagePortIDs.forEach(function(aMessagePortID) {

View File

@ -30,7 +30,8 @@ XPCOMUtils.defineLazyServiceGetter(this, "appsService",
"@mozilla.org/AppsService;1",
"nsIAppsService");
const kMessages = ["InterAppMessagePort:OnMessage"];
const kMessages = ["InterAppMessagePort:OnMessage",
"InterAppMessagePort:Shutdown"];
function InterAppMessagePort() {
if (DEBUG) debug("InterAppMessagePort()");
@ -149,6 +150,8 @@ InterAppMessagePort.prototype = {
cpmm.sendAsyncMessage("InterAppMessagePort:Unregister",
{ messagePortID: this._messagePortID,
manifestURL: this._manifestURL });
this.removeMessageListeners(kMessages);
},
get onmessage() {
@ -193,7 +196,8 @@ InterAppMessagePort.prototype = {
if (message.manifestURL != this._manifestURL ||
message.pageURL != this._pageURL ||
message.messagePortID != this._messagePortID) {
if (DEBUG) debug("The message doesn't belong to this page. Returning.");
if (DEBUG) debug("The message doesn't belong to this page. Returning. " +
uneval(message));
return;
}
@ -213,6 +217,9 @@ InterAppMessagePort.prototype = {
this._dispatchMessage(message.message);
break;
case "InterAppMessagePort:Shutdown":
this.close();
break;
default:
if (DEBUG) debug("Error! Shouldn't fall into this case.");
break;