summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend-api-receiver.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-08-18 20:51:19 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-02 19:33:28 -0400
commit53aad0bef68bf6930b684fda4a25e1a045cd800e (patch)
tree4e91dd4f3e6bac8ceefd7ecb321d15c024459f3f /ext/fg/js/frontend-api-receiver.js
parent42ec3e2a43dfd9ac0748ca7c364cef2b44f625a2 (diff)
Fix messaging issues when iframes are present in the document
Diffstat (limited to 'ext/fg/js/frontend-api-receiver.js')
-rw-r--r--ext/fg/js/frontend-api-receiver.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/fg/js/frontend-api-receiver.js b/ext/fg/js/frontend-api-receiver.js
index f5d29f67..687e5c3c 100644
--- a/ext/fg/js/frontend-api-receiver.js
+++ b/ext/fg/js/frontend-api-receiver.js
@@ -31,7 +31,7 @@ class FrontendApiReceiver {
port.onMessage.addListener(this.onMessage.bind(this, port));
}
- onMessage(port, {id, action, params, target}) {
+ onMessage(port, {id, action, params, target, senderId}) {
if (
target !== this.source ||
!this.handlers.hasOwnProperty(action)
@@ -39,24 +39,24 @@ class FrontendApiReceiver {
return;
}
- this.sendAck(port, id);
+ this.sendAck(port, id, senderId);
const handler = this.handlers[action];
handler(params).then(
result => {
- this.sendResult(port, id, {result});
+ this.sendResult(port, id, senderId, {result});
},
e => {
const error = typeof e.toString === 'function' ? e.toString() : e;
- this.sendResult(port, id, {error});
+ this.sendResult(port, id, senderId, {error});
});
}
- sendAck(port, id) {
- port.postMessage({type: 'ack', id});
+ sendAck(port, id, senderId) {
+ port.postMessage({type: 'ack', id, senderId});
}
- sendResult(port, id, data) {
- port.postMessage({type: 'result', id, data});
+ sendResult(port, id, senderId, data) {
+ port.postMessage({type: 'result', id, senderId, data});
}
}