@@ -262,6 +262,35 @@ public event Action<InputEvent> InputEvent
262262
263263 private event Action < InputEvent > _inputEvent ;
264264
265+ /// <summary>
266+ /// Emitted when the document in the top-level frame is loaded.
267+ /// </summary>
268+ public event Action OnDomReady
269+ {
270+ add
271+ {
272+ if ( _domReady == null )
273+ {
274+ BridgeConnector . Socket . On ( "webContents-domReady" + Id , ( ) =>
275+ {
276+ _domReady ( ) ;
277+ } ) ;
278+
279+ BridgeConnector . Socket . Emit ( "register-webContents-domReady" , Id ) ;
280+ }
281+ _domReady += value ;
282+ }
283+ remove
284+ {
285+ _domReady -= value ;
286+
287+ if ( _domReady == null )
288+ BridgeConnector . Socket . Off ( "webContents-domReady" + Id ) ;
289+ }
290+ }
291+
292+ private event Action _domReady ;
293+
265294 internal WebContents ( int id )
266295 {
267296 Id = id ;
@@ -363,6 +392,37 @@ public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null)
363392 return taskCompletionSource . Task ;
364393 }
365394
395+ /// <summary>
396+ /// Evaluates script code in page.
397+ /// </summary>
398+ /// <param name="code">The code to execute.</param>
399+ /// <param name="userGesture">if set to <c>true</c> simulate a user gesture.</param>
400+ /// <returns>The result of the executed code.</returns>
401+ /// <remarks>
402+ /// <para>
403+ /// In the browser window some HTML APIs like `requestFullScreen` can only be
404+ /// invoked by a gesture from the user. Setting `userGesture` to `true` will remove
405+ /// this limitation.
406+ /// </para>
407+ /// <para>
408+ /// Code execution will be suspended until web page stop loading.
409+ /// </para>
410+ /// </remarks>
411+ public Task < object > ExecuteJavaScriptAsync ( string code , bool userGesture = false )
412+ {
413+ var taskCompletionSource = new TaskCompletionSource < object > ( ) ;
414+
415+ BridgeConnector . Socket . On ( "webContents-executeJavaScript-completed" , ( result ) =>
416+ {
417+ BridgeConnector . Socket . Off ( "webContents-executeJavaScript-completed" ) ;
418+ taskCompletionSource . SetResult ( result ) ;
419+ } ) ;
420+
421+ BridgeConnector . Socket . Emit ( "webContents-executeJavaScript" , Id , code , userGesture ) ;
422+
423+ return taskCompletionSource . Task ;
424+ }
425+
366426 /// <summary>
367427 /// Is used to get the Url of the loaded page.
368428 /// It's usefull if a web-server redirects you and you need to know where it redirects. For instance, It's useful in case of Implicit Authorization.
0 commit comments