electron/spec/fixtures/extensions/content-script/all_frames-preload.js
Shelley Vohr d87b3ead76 chore: remove promisification deprecation callbacks (#17907)
* chore: remove promisification deprecation callbacks

* update docs

* fix smoke test

* fix executejs issue

* cleanup leftovers

* fix webContents.executeJavaScript tests

* cleanup WebContents.prototype.takeHeapSnapshot

* fix "sets arbitrary webContents as devtools" test

* fix executeJavaScriptInFrame related tests
2019-04-30 07:08:32 -07:00

14 lines
538 B
JavaScript

const { ipcRenderer, webFrame } = require('electron')
if (process.isMainFrame) {
// https://github.com/electron/electron/issues/17252
ipcRenderer.on('executeJavaScriptInFrame', (event, frameRoutingId, code, responseId) => {
const frame = webFrame.findFrameByRoutingId(frameRoutingId)
if (!frame) {
throw new Error(`Can't find frame for routing ID ${frameRoutingId}`)
}
frame.executeJavaScript(code, false).then(result => {
event.sender.send(`executeJavaScriptInFrame_${responseId}`, result)
})
})
}