Index: ext/content.js |
=================================================================== |
--- a/ext/content.js |
+++ b/ext/content.js |
@@ -44,40 +44,31 @@ |
for (let message of queue) |
backgroundFrame.contentWindow.postMessage(message, "*"); |
} |
window.removeEventListener("message", loadHandler); |
} |
}; |
window.addEventListener("message", loadHandler); |
- ext.backgroundPage = { |
Manish Jethani
2017/10/11 23:37:33
ext.backgroundPage is no longer necessary.
|
- _sendRawMessage(message) |
- { |
- if (messageQueue) |
- messageQueue.push(message); |
- else |
- backgroundFrame.contentWindow.postMessage(message, "*"); |
- } |
- }; |
- |
/* Polyfills */ |
if (!("runtime" in chrome)) |
chrome.runtime = {}; |
chrome.runtime.sendMessage = (message, responseCallback) => |
{ |
let messageId = ++maxMessageId; |
- ext.backgroundPage._sendRawMessage({ |
- type: "message", |
- messageId, |
- payload: message |
- }); |
+ let rawMessage = {type: "message", messageId, payload: message}; |
+ |
+ if (messageQueue) |
+ messageQueue.push(rawMessage); |
+ else |
+ backgroundFrame.contentWindow.postMessage(rawMessage, "*"); |
if (responseCallback) |
{ |
let callbackWrapper = event => |
{ |
if (event.data.type == "response" && event.data.messageId == messageId) |
{ |
window.removeEventListener("message", callbackWrapper); |