add JavascriptResult
This commit is contained in:
parent
117ced0bf5
commit
dbecaff451
4 changed files with 40 additions and 3 deletions
|
@ -15,6 +15,7 @@ using SafeExamBrowser.Configuration.Contracts;
|
||||||
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
||||||
using SafeExamBrowser.I18n.Contracts;
|
using SafeExamBrowser.I18n.Contracts;
|
||||||
using SafeExamBrowser.UserInterface.Contracts.Browser;
|
using SafeExamBrowser.UserInterface.Contracts.Browser;
|
||||||
|
using SafeExamBrowser.UserInterface.Contracts.Browser.Data;
|
||||||
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
|
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Browser
|
namespace SafeExamBrowser.Browser
|
||||||
|
@ -147,10 +148,15 @@ namespace SafeExamBrowser.Browser
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the given Javascript code in the browser.
|
/// Executes the given Javascript code in the browser.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async void ExecuteJavascript(string javascript, System.Action<dynamic> callback)
|
public async void ExecuteJavascript(string javascript, Action<JavascriptResult> callback)
|
||||||
{
|
{
|
||||||
var result = await this.control.EvaluateScriptAsync(javascript);
|
var result = await this.control.EvaluateScriptAsync(javascript);
|
||||||
callback(result);
|
callback(new JavascriptResult()
|
||||||
|
{
|
||||||
|
Message = result.Message,
|
||||||
|
Result = result.Result,
|
||||||
|
Success = result.Success
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The data resulting from a Javascript expression evaluation.
|
||||||
|
/// </summary>
|
||||||
|
public class JavascriptResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the Javascript was evaluated successfully or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool Success { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The error message, in case of an unsuccessful evaluation of the Javascript expression.
|
||||||
|
/// </summary>
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The data item returned by the Javascript expression.
|
||||||
|
/// </summary>
|
||||||
|
public dynamic Result { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using SafeExamBrowser.UserInterface.Contracts.Browser.Data;
|
||||||
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
|
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
|
||||||
|
|
||||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser
|
namespace SafeExamBrowser.UserInterface.Contracts.Browser
|
||||||
|
@ -64,7 +65,7 @@ namespace SafeExamBrowser.UserInterface.Contracts.Browser
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the given Javascript code in the browser.
|
/// Executes the given Javascript code in the browser.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void ExecuteJavascript(string javascript, System.Action<dynamic> callback);
|
void ExecuteJavascript(string javascript, System.Action<JavascriptResult> callback);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to find the given term on the current page according to the specified parameters.
|
/// Attempts to find the given term on the current page according to the specified parameters.
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Browser\Data\DownloadItemState.cs" />
|
<Compile Include="Browser\Data\DownloadItemState.cs" />
|
||||||
|
<Compile Include="Browser\Data\JavascriptResult.cs" />
|
||||||
<Compile Include="Browser\Events\AddressChangedEventHandler.cs" />
|
<Compile Include="Browser\Events\AddressChangedEventHandler.cs" />
|
||||||
<Compile Include="Browser\Events\FindRequestedEventHandler.cs" />
|
<Compile Include="Browser\Events\FindRequestedEventHandler.cs" />
|
||||||
<Compile Include="Browser\Events\LoadFailedEventHandler.cs" />
|
<Compile Include="Browser\Events\LoadFailedEventHandler.cs" />
|
||||||
|
|
Loading…
Reference in a new issue