mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
webContents: fix executejavascript when called before page load
This commit is contained in:
@@ -117,9 +117,11 @@ let wrapWebContents = function (webContents) {
|
||||
hasUserGesture = false
|
||||
}
|
||||
if (this.getURL() && !this.isLoadingMainFrame()) {
|
||||
return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
|
||||
asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
|
||||
} else {
|
||||
return this.once('did-finish-load', asyncWebFrameMethods.bind(this, requestId, 'executeJavaScript', callback, code, hasUserGesture))
|
||||
this.once('did-finish-load', () => {
|
||||
asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -870,6 +870,14 @@ describe('browser-window module', function () {
|
||||
})
|
||||
w.loadURL(server.url)
|
||||
})
|
||||
|
||||
it('executes after page load', function (done) {
|
||||
w.webContents.executeJavaScript(code, function(result) {
|
||||
assert.equal(result, expected)
|
||||
done()
|
||||
})
|
||||
w.loadURL(server.url)
|
||||
})
|
||||
})
|
||||
|
||||
describe('deprecated options', function () {
|
||||
|
||||
Reference in New Issue
Block a user