Skip to content

Instantly share code, notes, and snippets.

@oslego
Created July 6, 2014 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oslego/3813910f4b3b2eee704f to your computer and use it in GitHub Desktop.
Save oslego/3813910f4b3b2eee704f to your computer and use it in GitHub Desktop.
Mock impl of chrome.runtime for static development
/*
Mock-implementation of chrome.runtime messaging API
*/
var Messager = (function (){
var _listeners = [];
return {
onMessage: {
addListener: function(cb){
_listeners.push(cb);
}
},
postMessage: function(data){
_listeners.forEach(function(cb){
cb.call(this, data);
});
}
};
})();
chrome.runtime.connect = function(){
return Messager;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment