Add isLoadingMainFrame method to WebContents.

Also switch `webContents.executeJavaScript` to check it instead of `isLoading`.
There doesn’t seem to be a reasonable public way to get this information out of Chromium, so it’s synthesized here based on WebContentsObserver callbacks.
Fixes #5183.
This commit is contained in:
Rob Brackett 2016-04-18 10:37:08 -07:00
parent 3a9bbe30ac
commit 64a84dee3b
4 changed files with 44 additions and 3 deletions

View file

@ -116,7 +116,7 @@ let wrapWebContents = function (webContents) {
callback = hasUserGesture
hasUserGesture = false
}
if (this.getURL() && !this.isLoading()) {
if (this.getURL() && !this.isLoadingMainFrame()) {
return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
} else {
return this.once('did-finish-load', asyncWebFrameMethods.bind(this, requestId, 'executeJavaScript', callback, code, hasUserGesture))