File tree 1 file changed +4
-8
lines changed
1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,11 @@ import (
10
10
"math/rand"
11
11
"strings"
12
12
"testing"
13
- "time"
14
13
15
14
v8 "rogchap.com/v8go"
16
15
)
17
16
18
- func TestIsolateTermination (t * testing.T ) {
17
+ func TestIsolateTerminateExecution (t * testing.T ) {
19
18
t .Parallel ()
20
19
iso := v8 .NewIsolate ()
21
20
defer iso .Dispose ()
@@ -27,6 +26,9 @@ func TestIsolateTermination(t *testing.T) {
27
26
var terminating bool
28
27
fooFn := v8 .NewFunctionTemplate (iso , func (info * v8.FunctionCallbackInfo ) * v8.Value {
29
28
loop , _ := info .Args ()[0 ].AsFunction ()
29
+ go func () {
30
+ iso .TerminateExecution ()
31
+ }()
30
32
loop .Call (v8 .Undefined (iso ))
31
33
32
34
terminating = iso .IsExecutionTerminating ()
@@ -39,12 +41,6 @@ func TestIsolateTermination(t *testing.T) {
39
41
ctx := v8 .NewContext (iso , global )
40
42
defer ctx .Close ()
41
43
42
- go func () {
43
- // [RC] find a better way to know when a script has started execution
44
- time .Sleep (time .Millisecond )
45
- iso .TerminateExecution ()
46
- }()
47
-
48
44
script := `function loop() { while (true) { } }; foo(loop);`
49
45
_ , e := ctx .RunScript (script , "forever.js" )
50
46
if e == nil || ! strings .HasPrefix (e .Error (), "ExecutionTerminated" ) {
You can’t perform that action at this time.
0 commit comments