Created
August 9, 2013 21:16
-
-
Save baugarten/6197285 to your computer and use it in GitHub Desktop.
Bug 903083
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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