summaryrefslogtreecommitdiffstats
path: root/toolkit/components/webextensions/ExtensionChild.jsm
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-04-20 20:16:18 -0400
committerMatt A. Tobin <email@mattatobin.com>2018-04-20 20:16:18 -0400
commit94a484dd7e224ef6f4fc5994fa50478d41f72638 (patch)
tree5d91fbb0d1ebeeb1cf0a9ab266effb29ce4c1764 /toolkit/components/webextensions/ExtensionChild.jsm
parent754ad610489603f80ea38bbd2cf18b28f0d8bf1d (diff)
parentb3bf60f4264b9acfbd2cb34fed4a66915012803c (diff)
downloadUXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar.gz
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar.lz
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar.xz
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.zip
Merge branch 'master' into xulrunner
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;