Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: extensions/renderer/resources/port.js

Issue 1135123002: Clear the onMessage and onDisconnect listeners when their Extension Port is destroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/messaging/connect/test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/port.js
diff --git a/extensions/renderer/resources/port.js b/extensions/renderer/resources/port.js
index a3bb7af42c764338c36ff57aca25818306e5458b..425fa3a34bc1fdbca6d3d0072dd7428a7500df4f 100644
--- a/extensions/renderer/resources/port.js
+++ b/extensions/renderer/resources/port.js
@@ -16,8 +16,8 @@ function Port(portId, opt_name) {
var messageSchema = {name: 'message', type: 'any', optional: true};
var options = {unmanaged: true};
- this.onDisconnect = new Event(null, [portSchema], options);
this.onMessage = new Event(null, [messageSchema, portSchema], options);
+ this.onDisconnect = new Event(null, [portSchema], options);
this.onDestroy_ = null;
}
@@ -49,14 +49,16 @@ Port.prototype.disconnect = function() {
};
Port.prototype.destroy_ = function() {
- // Note: it's not necessary to destroy the onDisconnect/onMessage events
- // because they're unmanaged.
if (this.onDestroy_)
this.onDestroy_();
+ // Destroy the onMessage/onDisconnect events in case the extension added
+ // listeners, but didn't remove them, when the port closed.
+ privates(this.onMessage).impl.destroy_();
+ privates(this.onDisconnect).impl.destroy_();
messagingNatives.PortRelease(this.portId_);
};
exports.Port = utils.expose('Port', Port, {
functions: ['disconnect', 'postMessage'],
- properties: ['name', 'onDisconnect', 'onMessage']
+ properties: ['name', 'onMessage', 'onDisconnect']
});
« no previous file with comments | « chrome/test/data/extensions/api_test/messaging/connect/test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698