Skip to content

Commit

Permalink
Fix frame evaluates for missing arg
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Nov 26, 2024
1 parent 553f3a3 commit 094feea
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions browser/frame_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,25 @@ func mapFrame(vu moduleVU, f *common.Frame) mapping { //nolint:gocognit,cyclop
return nil, f.DispatchEvent(selector, typ, exportArg(eventInit), popts) //nolint:wrapcheck
}), nil
},
"evaluate": func(pageFunction sobek.Value, gargs ...sobek.Value) *sobek.Promise {
"evaluate": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
if sobekEmptyString(pageFunc) {
return nil, fmt.Errorf("evaluate requires a page function")
}
return k6ext.Promise(vu.Context(), func() (any, error) {
return f.Evaluate(pageFunction.String(), exportArgs(gargs)...) //nolint:wrapcheck
})
return f.Evaluate(pageFunc.String(), exportArgs(gargs)...)
}), nil
},
"evaluateHandle": func(pageFunction sobek.Value, gargs ...sobek.Value) *sobek.Promise {
"evaluateHandle": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
if sobekEmptyString(pageFunc) {
return nil, fmt.Errorf("evaluateHandle requires a page function")
}
return k6ext.Promise(vu.Context(), func() (any, error) {
jsh, err := f.EvaluateHandle(pageFunction.String(), exportArgs(gargs)...)
jsh, err := f.EvaluateHandle(pageFunc.String(), exportArgs(gargs)...)
if err != nil {
return nil, err //nolint:wrapcheck
}
return mapJSHandle(vu, jsh), nil
})
}), nil
},
"fill": func(selector, value string, opts sobek.Value) *sobek.Promise {
return k6ext.Promise(vu.Context(), func() (any, error) {
Expand Down

0 comments on commit 094feea

Please sign in to comment.