Skip to content

Commit

Permalink
add test for eval
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Sep 3, 2022
1 parent 8d369bf commit 0acf6e2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions page_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,24 @@ func TestEvalOptionsString(t *testing.T) {

g.Eq(rod.Eval(`() => this.parentElement`).This(el.Object).String(), "() => this.parentElement() button")
}

func TestEvalObjectReferenceChainIsTooLong(t *testing.T) {
g := setup(t)

p := g.page.MustNavigate(g.blank())

obj, err := p.Evaluate(&rod.EvalOptions{
JS: `() => {
let a = {b: 1}
a.c = a
return a
}`,
})
g.E(err)

_, err = p.Eval(`a => a`, obj)
g.Eq(err.Error(), "{-32000 Object reference chain is too long }")

val := p.MustEval(`a => a.c.c.c.c.b`, obj)
g.Eq(val.Int(), 1)
}

0 comments on commit 0acf6e2

Please sign in to comment.