fix: chrome.action
API registration (#40500)
This commit is contained in:
parent
cf5f0419f1
commit
7981d955b8
11 changed files with 536 additions and 1 deletions
28
spec/fixtures/extensions/chrome-action-fail/background.js
vendored
Normal file
28
spec/fixtures/extensions/chrome-action-fail/background.js
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* 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;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue