summaryrefslogtreecommitdiffstats
path: root/toolkit/components/webextensions/ExtensionChild.jsm
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/webextensions/ExtensionChild.jsm')
-rw-r--r--toolkit/components/webextensions/ExtensionChild.jsm28
1 files changed, 23 insertions, 5 deletions
diff --git a/toolkit/components/webextensions/ExtensionChild.jsm b/toolkit/components/webextensions/ExtensionChild.jsm
index c953dd685..5dc4e2277 100644
--- a/toolkit/components/webextensions/ExtensionChild.jsm
+++ b/toolkit/components/webextensions/ExtensionChild.jsm
@@ -325,7 +325,7 @@ class Messenger {
return this.sendMessage(messageManager, msg, recipient, responseCallback);
}
- onMessage(name) {
+ _onMessage(name, filter) {
return new SingletonEventManager(this.context, name, callback => {
let listener = {
messageFilterPermissive: this.optionalFilter,
@@ -333,7 +333,8 @@ class Messenger {
filterMessage: (sender, recipient) => {
// Ignore the message if it was sent by this Messenger.
- return sender.contextId !== this.context.contextId;
+ return (sender.contextId !== this.context.contextId &&
+ filter(sender, recipient));
},
receiveMessage: ({target, data: message, sender, recipient}) => {
@@ -373,6 +374,14 @@ class Messenger {
}).api();
}
+ onMessage(name) {
+ return this._onMessage(name, sender => sender.id === this.sender.id);
+ }
+
+ onMessageExternal(name) {
+ return this._onMessage(name, sender => sender.id !== this.sender.id);
+ }
+
_connect(messageManager, port, recipient) {
let msg = {
name: port.name,
@@ -407,7 +416,7 @@ class Messenger {
return this._connect(messageManager, port, recipient);
}
- onConnect(name) {
+ _onConnect(name, filter) {
return new SingletonEventManager(this.context, name, callback => {
let listener = {
messageFilterPermissive: this.optionalFilter,
@@ -415,7 +424,8 @@ class Messenger {
filterMessage: (sender, recipient) => {
// Ignore the port if it was created by this Messenger.
- return sender.contextId !== this.context.contextId;
+ return (sender.contextId !== this.context.contextId &&
+ filter(sender, recipient));
},
receiveMessage: ({target, data: message, sender}) => {
@@ -438,6 +448,14 @@ class Messenger {
};
}).api();
}
+
+ onConnect(name) {
+ return this._onConnect(name, sender => sender.id === this.sender.id);
+ }
+
+ onConnectExternal(name) {
+ return this._onConnect(name, sender => sender.id !== this.sender.id);
+ }
}
var apiManager = new class extends SchemaAPIManager {
@@ -745,7 +763,7 @@ class ExtensionPageContextChild extends BaseContext {
// This is the MessageSender property passed to extension.
// It can be augmented by the "page-open" hook.
- let sender = {id: extension.uuid};
+ let sender = {id: extension.id};
if (viewType == "tab") {
sender.tabId = tabId;
this.tabId = tabId;