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