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
Родитель 1efd46b659
Коммит 47ceb8da49
2 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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;