fix: regressions introduced by adding world isolation to Chrome extension content scripts (#17422)

This commit is contained in:
Milan Burda 2019-03-19 14:45:48 +01:00 committed by Alexey Kuzmin
parent 2fb9085e5b
commit 53f4af7722
6 changed files with 83 additions and 11 deletions

View file

@ -45,7 +45,7 @@ const runContentScript = function (this: any, extensionId: string, url: string,
})
const sources = [{ code, url }]
webFrame.executeJavaScriptInIsolatedWorld(worldId, sources)
return webFrame.executeJavaScriptInIsolatedWorld(worldId, sources)
}
const runAllContentScript = function (scripts: Array<Electron.InjectionBase>, extensionId: string) {
@ -102,8 +102,9 @@ ipcRendererInternal.on('CHROME_TABS_EXECUTESCRIPT', function (
url: string,
code: string
) {
const result = runContentScript.call(window, extensionId, url, code)
ipcRendererInternal.sendToAll(senderWebContentsId, `CHROME_TABS_EXECUTESCRIPT_RESULT_${requestId}`, result)
runContentScript.call(window, extensionId, url, code).then(result => {
ipcRendererInternal.sendToAll(senderWebContentsId, `CHROME_TABS_EXECUTESCRIPT_RESULT_${requestId}`, result)
})
})
module.exports = (getRenderProcessPreferences: typeof process.getRenderProcessPreferences) => {