Skip to content

Instantly share code, notes, and snippets.

@baugarten
Created August 9, 2013 21:16
Show Gist options
  • Save baugarten/6197285 to your computer and use it in GitHub Desktop.
Save baugarten/6197285 to your computer and use it in GitHub Desktop.
Bug 903083
(function() {
window.get = function(tokens, cb) {
var data = {
method: "getValues",
tokens: tokens
};
window.self.port.emit('message', data);
window.self.port.once('getSuccess', function(message) {
console.log("Got success", JSON.stringify(message.tokens));
if (cb) {
return cb(message.tokens);
}
});
};
for (var i = 0; i < 5; i++) {
window.get(['api_token', 'github_token'], function(tokens) {
console.log("TOKENS", JSON.stringify(tokens));
});
}
}).call(this);
var pageMod = require('sdk/page-mod');
var self = require('sdk/self');
var mod = pageMod.PageMod({
include: "*",
contentScriptFile: [
self.data.url('test.js')
],
onAttach: function(worker) {
worker.port.on('message', function(message) {
res = {};
message.tokens.forEach(function(getKey) {
res[getKey] = ss.storage[getKey];
});
worker.port.emit('getSuccess', {
method: 'getSuccess',
tokens: res
});
});
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment