This commit is contained in:
parent
82e8166fd5
commit
9d7b89d36c
1 changed files with 18 additions and 6 deletions
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using CefSharp;
|
using CefSharp;
|
||||||
using SafeExamBrowser.Browser.Wrapper;
|
using SafeExamBrowser.Browser.Wrapper;
|
||||||
using SafeExamBrowser.Browser.Wrapper.Events;
|
using SafeExamBrowser.Browser.Wrapper.Events;
|
||||||
|
@ -64,15 +65,26 @@ namespace SafeExamBrowser.Browser
|
||||||
|
|
||||||
public void ExecuteJavascript(string javascript, Action<JavascriptResult> callback)
|
public void ExecuteJavascript(string javascript, Action<JavascriptResult> callback)
|
||||||
{
|
{
|
||||||
control.EvaluateScriptAsync(javascript).ContinueWith(t =>
|
if ((control as IWebBrowser)?.CanExecuteJavascriptInMainFrame == true)
|
||||||
{
|
{
|
||||||
callback(new JavascriptResult()
|
control.EvaluateScriptAsync(javascript).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
Message = t.Result.Message,
|
callback(new JavascriptResult
|
||||||
Result = t.Result.Result,
|
{
|
||||||
Success = t.Result.Success
|
Message = t.Result.Message,
|
||||||
|
Result = t.Result.Result,
|
||||||
|
Success = t.Result.Success
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Task.Run(() => callback(new JavascriptResult
|
||||||
|
{
|
||||||
|
Message = "JavaScript can't be executed in the main frame!",
|
||||||
|
Success = false
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Find(string term, bool isInitial, bool caseSensitive, bool forward = true)
|
public void Find(string term, bool isInitial, bool caseSensitive, bool forward = true)
|
||||||
|
|
Loading…
Add table
Reference in a new issue