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

28 lines
644 B
JavaScript

/* global chrome */
const handleRequest = async (request, sender, sendResponse) => {
const { method } = request;
const tabId = sender.tab.id;
switch (method) {
case 'isEnabled': {
chrome.action.isEnabled(tabId).then(sendResponse);
break;
}
case 'setIcon': {
chrome.action.setIcon({ tabId, imageData: {} }).then(sendResponse);
break;
}
case 'getBadgeText': {
chrome.action.getBadgeText({ tabId }).then(sendResponse);
break;
}
}
};
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
handleRequest(request, sender, sendResponse);
return true;
});