feat: support chrome.scripting
extension APIs (#39395)
feat: support chrome.scripting extension APIs
This commit is contained in:
parent
5078cae861
commit
f0ad357af2
16 changed files with 2087 additions and 15 deletions
30
spec/fixtures/extensions/chrome-scripting/main.js
vendored
Normal file
30
spec/fixtures/extensions/chrome-scripting/main.js
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* 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));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const dispatchTest = (event) => {
|
||||
const { method, args = [] } = JSON.parse(event.data);
|
||||
map[method](...args);
|
||||
};
|
||||
|
||||
window.addEventListener('message', dispatchTest, false);
|
Loading…
Add table
Add a link
Reference in a new issue