Skip to content

Instantly share code, notes, and snippets.

@jsantell
Created August 9, 2013 20:59
Show Gist options
  • Select an option

  • Save jsantell/6197141 to your computer and use it in GitHub Desktop.

Select an option

Save jsantell/6197141 to your computer and use it in GitHub Desktop.
Bug 903083
self.port.emit('message', 'hi!');
self.port.on('messageSuccess', function (msg) {
console.log('my message is', msg);
});
self.port.on('key', function (key) {
console.log('my key is', key);
});
let { PageMod } = require('sdk/page-mod');
let { url: getLocal } = require('sdk/self').data;
PageMod({
include: '*',
contentScriptFile: getLocal('test.js'),
onAttach: function (worker) {
worker.port.emit('key', 'myvalue');
worker.port.on('message', function (msg) {
worker.port.emit('messageSuccess', msg);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment