Skip to content

Commit a25277e

Browse files
committed
In JavaScriptEngineSwitcher.Vroom added a ability to interrupt execution of the script
1 parent 61edb79 commit a25277e

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

NuGet/JavaScriptEngineSwitcher.Vroom/JavaScriptEngineSwitcher.Vroom.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
For correct working of the VroomJs on Windows require assemblies `msvcr110.dll` from the Visual C++ Redistributable for Visual Studio 2012 and `msvcp140.dll` from the Microsoft Visual C++ 2015 Redistributable.</description>
1616
<summary>JavaScriptEngineSwitcher.Vroom contains adapter `VroomJsEngine` (wrapper for the VroomJs version 1.2.3 with support of V8 version 3.17.16.2).</summary>
17+
<releaseNotes>Added a ability to interrupt execution of the script.</releaseNotes>
1718
<copyright>Copyright (c) 2013-2017 Andrey Taritsyn - http://www.taritsyn.ru</copyright>
1819
<language>en-US</language>
1920
<tags>JavaScriptEngineSwitcher JavaScript ECMAScript VroomJs V8</tags>

NuGet/JavaScriptEngineSwitcher.Vroom/readme.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
from the Visual C++ Redistributable for Visual Studio 2012 and `msvcp140.dll`
2020
from the Microsoft Visual C++ 2015 Redistributable.
2121

22+
=============
23+
RELEASE NOTES
24+
=============
25+
Added a ability to interrupt execution of the script.
26+
2227
====================
2328
POST-INSTALL ACTIONS
2429
====================

src/JavaScriptEngineSwitcher.Jint/JintJsEngine.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,9 @@ private JsRuntimeException ConvertScriptTimeoutExceptionToHostException(
238238
TimeoutException scriptTimeoutException)
239239
{
240240
var hostException = new JsRuntimeException(Strings.Runtime_ExecutionTimeout,
241-
EngineName, EngineVersion)
241+
EngineName, EngineVersion, scriptTimeoutException)
242242
{
243-
Category = "TimeoutError",
244-
Source = scriptTimeoutException.Source,
245-
HelpLink = scriptTimeoutException.HelpLink
243+
Category = "TimeoutError"
246244
};
247245

248246
return hostException;

src/JavaScriptEngineSwitcher.Vroom/VroomJsEngine.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ private static object MapToScriptType(object value)
121121
private static JsException ConvertScriptExceptionToHostException(
122122
OriginalJsException scriptException)
123123
{
124+
JsException hostException;
124125
string message = scriptException.Message;
125126
string category;
126127
int lineNumber = 0;
@@ -138,14 +139,22 @@ private static JsException ConvertScriptExceptionToHostException(
138139
columnNumber = scriptException.Column;
139140
}
140141

141-
var hostException = new JsRuntimeException(message, EngineName, EngineVersion,
142-
scriptException)
142+
if (category == null)
143143
{
144-
Category = category,
145-
LineNumber = lineNumber,
146-
ColumnNumber = columnNumber,
147-
SourceFragment = sourceFragment
148-
};
144+
hostException = new JsScriptInterruptedException(CoreStrings.Runtime_ScriptInterrupted,
145+
EngineName, EngineVersion, scriptException);
146+
}
147+
else
148+
{
149+
hostException = new JsRuntimeException(message, EngineName, EngineVersion,
150+
scriptException)
151+
{
152+
Category = category,
153+
LineNumber = lineNumber,
154+
ColumnNumber = columnNumber,
155+
SourceFragment = sourceFragment
156+
};
157+
}
149158

150159
return hostException;
151160
}
@@ -381,7 +390,7 @@ private void InnerEmbedHostItem(string itemName, object value)
381390

382391
protected override void InnerInterrupt()
383392
{
384-
throw new NotImplementedException();
393+
_jsEngine.TerminateExecution();
385394
}
386395

387396
protected override void InnerCollectGarbage()
@@ -412,7 +421,7 @@ public override string Version
412421
/// </summary>
413422
public override bool SupportsScriptInterruption
414423
{
415-
get { return false; }
424+
get { return true; }
416425
}
417426

418427
/// <summary>

0 commit comments

Comments
 (0)