electron/spec/fixtures/extensions/tabs-api-async/main.js
Shelley Vohr 67523a47b4
fix: chrome.tabs.update return value (#39365)
fix: chrome.tabs.update return value
2023-08-07 10:03:45 +02:00

50 lines
1.4 KiB
JavaScript

/* global chrome */
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
sendResponse(request);
});
const testMap = {
getZoomSettings () {
chrome.runtime.sendMessage({ method: 'getZoomSettings' }, response => {
console.log(JSON.stringify(response));
});
},
setZoomSettings (settings) {
chrome.runtime.sendMessage({ method: 'setZoomSettings', args: [settings] }, response => {
console.log(JSON.stringify(response));
});
},
getZoom () {
chrome.runtime.sendMessage({ method: 'getZoom', args: [] }, response => {
console.log(JSON.stringify(response));
});
},
setZoom (zoom) {
chrome.runtime.sendMessage({ method: 'setZoom', args: [zoom] }, response => {
console.log(JSON.stringify(response));
});
},
get () {
chrome.runtime.sendMessage({ method: 'get' }, response => {
console.log(JSON.stringify(response));
});
},
reload () {
chrome.runtime.sendMessage({ method: 'reload' }, response => {
console.log(JSON.stringify(response));
});
},
update (params) {
chrome.runtime.sendMessage({ method: 'update', args: [params] }, response => {
console.log(JSON.stringify(response));
});
}
};
const dispatchTest = (event) => {
const { method, args = [] } = JSON.parse(event.data);
testMap[method](...args);
};
window.addEventListener('message', dispatchTest, false);