From 8a8b11cf10f0c107f91915e407e021f95a8f3c38 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 15 Sep 2015 09:21:15 +0800 Subject: [PATCH] Do not use did-finish-load to detect whether WebContents is ready The WebContents JS object can be created way later after the C++ object gets created. --- atom/browser/api/lib/web-contents.coffee | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/atom/browser/api/lib/web-contents.coffee b/atom/browser/api/lib/web-contents.coffee index 1bb82dec1a66..3a2abfb5155f 100644 --- a/atom/browser/api/lib/web-contents.coffee +++ b/atom/browser/api/lib/web-contents.coffee @@ -44,10 +44,8 @@ wrapWebContents = (webContents) -> # Make sure webContents.executeJavaScript would run the code only when the # web contents has been loaded. - webContents.loaded = false - webContents.once 'did-finish-load', -> @loaded = true webContents.executeJavaScript = (code, hasUserGesture=false) -> - if @loaded + if @getUrl() and not @isLoading() @_executeJavaScript code, hasUserGesture else webContents.once 'did-finish-load', @_executeJavaScript.bind(this, code, hasUserGesture)