@@ -1369,26 +1369,19 @@ private static string GetPromiseHandlerScript(string script, string javascriptBi
13691369 /// When false don't include a return statement e.g. 42;
13701370 /// </param>
13711371 /// <returns>
1372- /// <see cref="Task{JavascriptResponse}"/> that can be awaited to perform the script execution.
1372+ /// <see cref="Task{JavascriptResponse}"/> that can be awaited to obtain the result of the script execution.
13731373 /// </returns>
1374- public static Task < JavascriptResponse > EvaluateScriptAsync ( this IWebBrowser browser , string script , TimeSpan ? timeout = null , bool useImmediatelyInvokedFuncExpression = false )
1374+ public static Task < JavascriptResponse > EvaluateScriptAsync ( this IChromiumWebBrowserBase browser , string script , TimeSpan ? timeout = null , bool useImmediatelyInvokedFuncExpression = false )
13751375 {
1376- if ( timeout . HasValue && timeout . Value . TotalMilliseconds > UInt32 . MaxValue )
1377- {
1378- throw new ArgumentOutOfRangeException ( "timeout" , "Timeout greater than Maximum allowable value of " + UInt32 . MaxValue ) ;
1379- }
1380-
1381- if ( browser . CanExecuteJavascriptInMainFrame == false )
1376+ if ( browser is IWebBrowser b )
13821377 {
1383- ThrowExceptionIfCanExecuteJavascriptInMainFrameFalse ( ) ;
1378+ if ( b . CanExecuteJavascriptInMainFrame == false )
1379+ {
1380+ ThrowExceptionIfCanExecuteJavascriptInMainFrameFalse ( ) ;
1381+ }
13841382 }
13851383
1386- using ( var frame = browser . GetMainFrame ( ) )
1387- {
1388- ThrowExceptionIfFrameNull ( frame ) ;
1389-
1390- return frame . EvaluateScriptAsync ( script , timeout : timeout , useImmediatelyInvokedFuncExpression : useImmediatelyInvokedFuncExpression ) ;
1391- }
1384+ return browser . BrowserCore . EvaluateScriptAsync ( script , timeout , useImmediatelyInvokedFuncExpression ) ;
13921385 }
13931386
13941387 /// <summary>
@@ -1404,7 +1397,7 @@ public static Task<JavascriptResponse> EvaluateScriptAsync(this IWebBrowser brow
14041397 /// When false don't include a return statement e.g. 42;
14051398 /// </param>
14061399 /// <returns>
1407- /// <see cref="Task{JavascriptResponse}"/> that can be awaited to perform the script execution.
1400+ /// <see cref="Task{JavascriptResponse}"/> that can be awaited to obtain the result of the script execution.
14081401 /// </returns>
14091402 public static Task < JavascriptResponse > EvaluateScriptAsync ( this IBrowser browser , string script , TimeSpan ? timeout = null , bool useImmediatelyInvokedFuncExpression = false )
14101403 {
@@ -1432,7 +1425,7 @@ public static Task<JavascriptResponse> EvaluateScriptAsync(this IBrowser browser
14321425 /// <param name="methodName">The javascript method name to execute.</param>
14331426 /// <param name="args">the arguments to be passed as params to the method.</param>
14341427 /// <returns>
1435- /// <see cref="Task{JavascriptResponse}"/> that can be awaited to perform the script execution.
1428+ /// <see cref="Task{JavascriptResponse}"/> that can be awaited to obtain the result of the script execution.
14361429 /// </returns>
14371430 public static Task < JavascriptResponse > EvaluateScriptAsync ( this IChromiumWebBrowserBase browser , string methodName , params object [ ] args )
14381431 {
0 commit comments