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:
		
					parent
					
						
							
								12fcac59a2
							
						
					
				
			
			
				commit
				
					
						ad9e64d086
					
				
			
		
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
					@ -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)
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue