fix: remove race condition for executeJavaScript (#13692)

Replaces 'did-finish-load' with 'did-stop-loading' which semantically
maps to the events inside Chromium.  Before I think we were relying
on a natural 99% winnable race condition.

Fixes #13504
This commit is contained in:
trop[bot] 2018-07-16 21:22:27 -07:00 committed by Shelley Vohr
parent 1feb45da29
commit b49b071a1f

View file

@ -184,7 +184,7 @@ WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callba
return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
} else {
return new Promise((resolve, reject) => {
this.once('did-finish-load', () => {
this.once('did-stop-loading', () => {
asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture).then(resolve).catch(reject)
})
})