fix(extension): bound event execution and cancel pending engine calls

This commit is contained in:
Levi committed 2026-11-10 09:31:37 +08:00
1 parent ed125c2f19
commit 1bc31774cb
7 files changed
+123 -17

No files matched your search

+13
View File
@@ -1,6 +1,8 @@
package engine
import (
"context"
"errors"
"github.com/dop251/goja"
"testing"
"time"
@@ -32,3 +34,14 @@ func TestCloseUnblocksPendingPromise(t *testing.T) {
t.Fatal("Engine.Close left the Promise waiter blocked")
}
}
func TestExecutionDeadlineInterruptsSynchronousScript(t *testing.T) {
e := NewEngine(nil)
defer e.Close()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Millisecond)
defer cancel()
_, err := e.RunStringContext(ctx, `while (true) {}`)
if !errors.Is(err, context.DeadlineExceeded) {
t.Fatalf("got %v, want deadline exceeded", err)
}
}