electron/spec/fixtures/extensions/chrome-action-fail/background.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
644 B
JavaScript
Raw Normal View History

/* 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;
});