fix: remove race condition for executeJavaScript (#13691)

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:
Samuel Attard 2018-07-17 13:32:28 +10:00 committed by GitHub
parent 12fcac59a2
commit ad9e64d086
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -184,7 +184,7 @@ WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callba
return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture) return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
} else { } else {
return new Promise((resolve, reject) => { 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) asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture).then(resolve).catch(reject)
}) })
}) })