From 3d535c6c6926efe87888833d05356fedcbe19d0d Mon Sep 17 00:00:00 2001 From: Deathamns Date: Tue, 4 Nov 2014 16:31:57 +0100 Subject: [PATCH] Messaging fixes Checking the message name (and connectorId) is mandatory for Safari, because when the background page sends a response back to a document, then all the frames in its owner tab will receive the exact same message, which could confuse the script in some cases. --- src/js/vapi-background.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/vapi-background.js b/src/js/vapi-background.js index aedf8f0..cad732e 100644 --- a/src/js/vapi-background.js +++ b/src/js/vapi-background.js @@ -177,8 +177,8 @@ if (self.chrome) { vAPI.messaging = { ports: {}, listeners: {}, - listen: function(name, callback) { - this.listeners[name] = callback; + listen: function(listenerName, callback) { + this.listeners[listenerName] = callback; }, setup: function(connector) { if (this.connector) { @@ -654,8 +654,8 @@ if (self.chrome) { vAPI.messaging = { listeners: {}, - listen: function(name, callback) { - this.listeners[name] = callback; + listen: function(listenerName, callback) { + this.listeners[listenerName] = callback; }, setup: function(connector) { if (this.connector) { @@ -666,7 +666,7 @@ if (self.chrome) { var callback = function(response) { if (request.message.requestId && response !== undefined) { request.target.page.dispatchMessage( - 'message', + request.name, { requestId: request.message.requestId, portName: request.message.portName,