mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 14:28:33 +02:00
* convert chrome. to browser. Issue #165 * fix browser-polyfill * convert chrome.* to browser.* (#166) * convert chrome.* to browser.* * change chrome to browser * change the callback-style to promise-style * change the callback-style to promise-style
16 lines
506 B
JavaScript
16 lines
506 B
JavaScript
var Background = {
|
|
receiveMessage: function(msg, sender, sendResponse) {
|
|
if (msg && msg.action && Background.hasOwnProperty(msg.action)) {
|
|
return Background[msg.action](msg, sender, sendResponse);
|
|
} else {
|
|
console.warn('No handler for message: ' + JSON.stringify(msg));
|
|
}
|
|
},
|
|
ping: function(msg, sender, sendResponse) {
|
|
sendResponse('pong');
|
|
return true;
|
|
}
|
|
};
|
|
|
|
browser.runtime.onMessage.addListener(Background.receiveMessage);
|