electron/spec/fixtures/extensions/chrome-scripting/main.js
trop[bot] ba1e7fcaa7
test: add test and api_feature definition for chrome.scripting.globalParams (#41700)
chore: add test and api_feature for chrome.scripting.globalParams

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2024-03-27 10:21:04 +01:00

35 lines
937 B
JavaScript

/* global chrome */
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
sendResponse(request);
});
const map = {
executeScript () {
chrome.runtime.sendMessage({ method: 'executeScript' }, response => {
console.log(JSON.stringify(response));
});
},
registerContentScripts () {
chrome.runtime.sendMessage({ method: 'registerContentScripts' }, response => {
console.log(JSON.stringify(response));
});
},
insertCSS () {
chrome.runtime.sendMessage({ method: 'insertCSS' }, response => {
console.log(JSON.stringify(response));
});
},
globalParams () {
chrome.runtime.sendMessage({ method: 'globalParams' }, response => {
console.log(JSON.stringify(response));
});
}
};
const dispatchTest = (event) => {
const { method, args = [] } = JSON.parse(event.data);
map[method](...args);
};
window.addEventListener('message', dispatchTest, false);