electron/spec/fixtures/extensions/chrome-action-fail/main.js
2023-11-13 08:27:18 +01:00

30 lines
762 B
JavaScript

/* global chrome */
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
sendResponse(request);
});
const testMap = {
isEnabled () {
chrome.runtime.sendMessage({ method: 'isEnabled' }, response => {
console.log(JSON.stringify(response));
});
},
setIcon () {
chrome.runtime.sendMessage({ method: 'setIcon' }, response => {
console.log(JSON.stringify(response));
});
},
getBadgeText () {
chrome.runtime.sendMessage({ method: 'getBadgeText' }, response => {
console.log(JSON.stringify(response));
});
}
};
const dispatchTest = (event) => {
const { method, args = [] } = JSON.parse(event.data);
testMap[method](...args);
};
window.addEventListener('message', dispatchTest, false);