fix broken remote browser init

Signed-off-by: RonniSkansing <rskansing@gmail.com>
This commit is contained in:
RonniSkansing committed 2026-09-12 20:17:05 +02:00
1 parent 1109a620ee
commit b9b40b1ec1
2 files changed
+17 -3

No files matched your search

+3 -1
View File
@@ -56,7 +56,9 @@
}
newSession = function (opts) {
var s = baseNewSession(opts);
// Default to {} so a no-argument newSession() call does not forward
// undefined, which the native binding would reject when it parses options.
var s = baseNewSession(opts || {});
// present is true when the selector matches at least one node.
s.present = function (sel) { return s.getNodeCount(sel) > 0; };
+14 -2
View File
@@ -19,7 +19,16 @@ func TestPreludeStateMachine(t *testing.T) {
// 0 password, 1 totp, 2 done.
stage := 0
newSession := func(goja.FunctionCall) goja.Value {
// badArg records the regression where the prelude wrapper forwards undefined
// to the native newSession for a no-argument call.
badArg := false
newSession := func(call goja.FunctionCall) goja.Value {
if len(call.Arguments) > 0 {
a := call.Argument(0)
if goja.IsUndefined(a) || goja.IsNull(a) {
badArg = true
}
}
s := vm.NewObject()
_ = s.Set("location", func(goja.FunctionCall) goja.Value {
if stage >= 2 {
@@ -60,7 +69,7 @@ func TestPreludeStateMachine(t *testing.T) {
var visited = [];
var beforeSeen = [];
var afterSeen = [];
var s = newSession({});
var s = newSession();
if (typeof s.states !== "function") { throw new Error("s.states missing"); }
if (typeof s.waitForState !== "function") { throw new Error("s.waitForState missing"); }
if (typeof s.present !== "function") { throw new Error("s.present missing"); }
@@ -98,6 +107,9 @@ func TestPreludeStateMachine(t *testing.T) {
if err != nil {
t.Fatalf("script failed: %v", err)
}
if badArg {
t.Fatalf("newSession wrapper forwarded undefined/null opts for a no-argument call")
}
got := v.String()
want := "password,totp,done|password,totp,done|password,totp,done"
if got != want {