})
}
args.push(responseCallback)
- electron.webFrame[method].apply(electron.webFrame, args)
+ electron.webFrame[method](...args)
})
// Process command line arguments.
describe('window.webContents.executeJavaScript', function () {
var expected = 'hello, world!'
var code = '(() => "' + expected + '")()'
+ var asyncCode = '(() => new Promise(r => setTimeout(() => r("' + expected + '"), 500)))()'
it('doesnt throw when no calback is provided', function () {
const result = ipcRenderer.sendSync('executeJavaScript', code, false)
})
})
+ it('returns result if the code returns an asyncronous promise', function (done) {
+ ipcRenderer.send('executeJavaScript', asyncCode, true)
+ ipcRenderer.once('executeJavaScript-response', function (event, result) {
+ assert.equal(result, expected)
+ done()
+ })
+ })
+
it('works after page load and during subframe load', function (done) {
w.webContents.once('did-finish-load', function () {
// initiate a sub-frame load, then try and execute script during it