diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs
index 54902832..3b569d43 100644
--- a/SafeExamBrowser.Browser/BrowserControl.cs
+++ b/SafeExamBrowser.Browser/BrowserControl.cs
@@ -15,6 +15,7 @@ using SafeExamBrowser.Configuration.Contracts;
using SafeExamBrowser.Configuration.Contracts.Cryptography;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Browser;
+using SafeExamBrowser.UserInterface.Contracts.Browser.Data;
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
namespace SafeExamBrowser.Browser
@@ -147,10 +148,15 @@ namespace SafeExamBrowser.Browser
///
/// Executes the given Javascript code in the browser.
///
- public async void ExecuteJavascript(string javascript, System.Action callback)
+ public async void ExecuteJavascript(string javascript, Action callback)
{
var result = await this.control.EvaluateScriptAsync(javascript);
- callback(result);
+ callback(new JavascriptResult()
+ {
+ Message = result.Message,
+ Result = result.Result,
+ Success = result.Success
+ });
}
}
}
diff --git a/SafeExamBrowser.UserInterface.Contracts/Browser/Data/JavascriptResult.cs b/SafeExamBrowser.UserInterface.Contracts/Browser/Data/JavascriptResult.cs
new file mode 100644
index 00000000..82459ff0
--- /dev/null
+++ b/SafeExamBrowser.UserInterface.Contracts/Browser/Data/JavascriptResult.cs
@@ -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
+{
+ ///
+ /// The data resulting from a Javascript expression evaluation.
+ ///
+ public class JavascriptResult
+ {
+ ///
+ /// Indicates if the Javascript was evaluated successfully or not.
+ ///
+ public bool Success { get; set; }
+
+ ///
+ /// The error message, in case of an unsuccessful evaluation of the Javascript expression.
+ ///
+ public string Message { get; set; }
+
+ ///
+ /// The data item returned by the Javascript expression.
+ ///
+ public dynamic Result { get; set; }
+ }
+}
diff --git a/SafeExamBrowser.UserInterface.Contracts/Browser/IBrowserControl.cs b/SafeExamBrowser.UserInterface.Contracts/Browser/IBrowserControl.cs
index 7118af86..a27c5c8e 100644
--- a/SafeExamBrowser.UserInterface.Contracts/Browser/IBrowserControl.cs
+++ b/SafeExamBrowser.UserInterface.Contracts/Browser/IBrowserControl.cs
@@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+using SafeExamBrowser.UserInterface.Contracts.Browser.Data;
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
namespace SafeExamBrowser.UserInterface.Contracts.Browser
@@ -64,7 +65,7 @@ namespace SafeExamBrowser.UserInterface.Contracts.Browser
///
/// Executes the given Javascript code in the browser.
///
- void ExecuteJavascript(string javascript, System.Action callback);
+ void ExecuteJavascript(string javascript, System.Action callback);
///
/// Attempts to find the given term on the current page according to the specified parameters.
diff --git a/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj b/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj
index 68674df9..5eb5ab83 100644
--- a/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj
+++ b/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj
@@ -55,6 +55,7 @@
+