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>
This commit is contained in:
parent
313476a724
commit
ba1e7fcaa7
4 changed files with 49 additions and 0 deletions
|
@ -39,6 +39,14 @@
|
||||||
"contexts": ["blessed_extension", "unblessed_extension", "content_script"],
|
"contexts": ["blessed_extension", "unblessed_extension", "content_script"],
|
||||||
"max_manifest_version": 2
|
"max_manifest_version": 2
|
||||||
},
|
},
|
||||||
|
"extension.lastError": {
|
||||||
|
"contexts": [
|
||||||
|
"blessed_extension",
|
||||||
|
"unblessed_extension",
|
||||||
|
"content_script"
|
||||||
|
],
|
||||||
|
"max_manifest_version": 2
|
||||||
|
},
|
||||||
"i18n": {
|
"i18n": {
|
||||||
"channel": "stable",
|
"channel": "stable",
|
||||||
"extension_types": ["extension"],
|
"extension_types": ["extension"],
|
||||||
|
@ -68,5 +76,10 @@
|
||||||
"scripting": {
|
"scripting": {
|
||||||
"dependencies": ["permission:scripting"],
|
"dependencies": ["permission:scripting"],
|
||||||
"contexts": ["blessed_extension"]
|
"contexts": ["blessed_extension"]
|
||||||
|
},
|
||||||
|
"scripting.globalParams": {
|
||||||
|
"channel": "trunk",
|
||||||
|
"dependencies": ["permission:scripting"],
|
||||||
|
"contexts": ["content_script"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1285,6 +1285,16 @@ describe('chrome extensions', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('globalParams', async () => {
|
||||||
|
await w.loadURL(url);
|
||||||
|
|
||||||
|
const message = { method: 'globalParams' };
|
||||||
|
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||||
|
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||||
|
const response = JSON.parse(responseString);
|
||||||
|
expect(response).to.deep.equal({ changed: true });
|
||||||
|
});
|
||||||
|
|
||||||
it('insertCSS', async () => {
|
it('insertCSS', async () => {
|
||||||
await w.loadURL(url);
|
await w.loadURL(url);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,27 @@ const handleRequest = async (request, sender, sendResponse) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'globalParams' : {
|
||||||
|
await chrome.scripting.executeScript({
|
||||||
|
target: { tabId },
|
||||||
|
func: () => {
|
||||||
|
chrome.scripting.globalParams.changed = true;
|
||||||
|
},
|
||||||
|
world: 'ISOLATED'
|
||||||
|
});
|
||||||
|
|
||||||
|
const results = await chrome.scripting.executeScript({
|
||||||
|
target: { tabId },
|
||||||
|
func: () => JSON.stringify(chrome.scripting.globalParams),
|
||||||
|
world: 'ISOLATED'
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = JSON.parse(results[0].result);
|
||||||
|
|
||||||
|
sendResponse(result);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'registerContentScripts': {
|
case 'registerContentScripts': {
|
||||||
await chrome.scripting.registerContentScripts([{
|
await chrome.scripting.registerContentScripts([{
|
||||||
id: 'session-script',
|
id: 'session-script',
|
||||||
|
|
|
@ -19,6 +19,11 @@ const map = {
|
||||||
chrome.runtime.sendMessage({ method: 'insertCSS' }, response => {
|
chrome.runtime.sendMessage({ method: 'insertCSS' }, response => {
|
||||||
console.log(JSON.stringify(response));
|
console.log(JSON.stringify(response));
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
globalParams () {
|
||||||
|
chrome.runtime.sendMessage({ method: 'globalParams' }, response => {
|
||||||
|
console.log(JSON.stringify(response));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue