@@ -611,30 +611,31 @@ func NewFrameWaitForFunctionOptions(defaultTimeout time.Duration) *FrameWaitForF
611
611
612
612
// Parse JavaScript waitForFunction options.
613
613
func (o * FrameWaitForFunctionOptions ) Parse (ctx context.Context , opts sobek.Value ) error {
614
- rt := k6ext .Runtime (ctx )
614
+ if ! sobekValueExists (opts ) {
615
+ return nil
616
+ }
615
617
616
- if opts != nil && ! sobek .IsUndefined (opts ) && ! sobek .IsNull (opts ) {
617
- opts := opts .ToObject (rt )
618
- for _ , k := range opts .Keys () {
619
- v := opts .Get (k )
620
- switch k {
621
- case "timeout" :
622
- o .Timeout = time .Duration (v .ToInteger ()) * time .Millisecond
623
- case "polling" :
624
- switch v .ExportType ().Kind () { //nolint: exhaustive
625
- case reflect .Int64 :
626
- o .Polling = PollingInterval
627
- o .Interval = v .ToInteger ()
628
- case reflect .String :
629
- if p , ok := pollingTypeToID [v .ToString ().String ()]; ok {
630
- o .Polling = p
631
- break
632
- }
633
- fallthrough
634
- default :
635
- return fmt .Errorf ("wrong polling option value: %q; " +
636
- `possible values: "raf", "mutation" or number` , v )
618
+ rt := k6ext .Runtime (ctx )
619
+ obj := opts .ToObject (rt )
620
+ for _ , k := range obj .Keys () {
621
+ v := obj .Get (k )
622
+ switch k {
623
+ case "timeout" :
624
+ o .Timeout = time .Duration (v .ToInteger ()) * time .Millisecond
625
+ case "polling" :
626
+ switch v .ExportType ().Kind () { //nolint: exhaustive
627
+ case reflect .Int64 :
628
+ o .Polling = PollingInterval
629
+ o .Interval = v .ToInteger ()
630
+ case reflect .String :
631
+ if p , ok := pollingTypeToID [v .ToString ().String ()]; ok {
632
+ o .Polling = p
633
+ break
637
634
}
635
+ fallthrough
636
+ default :
637
+ return fmt .Errorf ("wrong polling option value: %q; " +
638
+ `possible values: "raf", "mutation" or number` , v )
638
639
}
639
640
}
640
641
}
0 commit comments