Skip to content

Commit

Permalink
Merge branch 'master' into rm-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rogchap authored Nov 22, 2021
2 parents 24631f9 + a8a4920 commit eb46224
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions isolate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
"math/rand"
"strings"
"testing"
"time"

v8 "rogchap.com/v8go"
)

func TestIsolateTermination(t *testing.T) {
func TestIsolateTerminateExecution(t *testing.T) {
t.Parallel()
iso := v8.NewIsolate()
defer iso.Dispose()
Expand All @@ -27,6 +26,9 @@ func TestIsolateTermination(t *testing.T) {
var terminating bool
fooFn := v8.NewFunctionTemplate(iso, func(info *v8.FunctionCallbackInfo) *v8.Value {
loop, _ := info.Args()[0].AsFunction()
go func() {
iso.TerminateExecution()
}()
loop.Call(v8.Undefined(iso))

terminating = iso.IsExecutionTerminating()
Expand All @@ -39,12 +41,6 @@ func TestIsolateTermination(t *testing.T) {
ctx := v8.NewContext(iso, global)
defer ctx.Close()

go func() {
// [RC] find a better way to know when a script has started execution
time.Sleep(time.Millisecond)
iso.TerminateExecution()
}()

script := `function loop() { while (true) { } }; foo(loop);`
_, e := ctx.RunScript(script, "forever.js")
if e == nil || !strings.HasPrefix(e.Error(), "ExecutionTerminated") {
Expand Down

0 comments on commit eb46224

Please sign in to comment.