Index: ext/content.js |
=================================================================== |
--- a/ext/content.js |
+++ b/ext/content.js |
@@ -59,7 +59,7 @@ |
} |
}; |
- /* Polyfills */ |
+ /* Message passing */ |
if (!("runtime" in browser)) |
browser.runtime = {}; |
@@ -96,4 +96,21 @@ |
}); |
} |
}; |
+ |
+ function postMessage(msg) |
+ { |
+ ext.backgroundPage._sendRawMessage({ |
+ type: "port", |
+ name: this._name, |
+ payload: msg |
+ }); |
+ } |
+ ext._Port.prototype.postMessage = postMessage; |
+ |
+ function connect({name}) |
+ { |
+ ext.backgroundPage._sendRawMessage({type: "connect", name}); |
+ return new ext._Port(name); |
+ } |
+ browser.runtime.connect = connect; |
}()); |