@@ -238,8 +238,12 @@ func (h *ElementHandle) checkHitTargetAt(apiCtx context.Context, p Position) (bo
238
238
return injected.checkHitTargetAt(node, point);
239
239
}
240
240
` )
241
+ opts := evaluateOptions {
242
+ forceCallable : true ,
243
+ returnByValue : true ,
244
+ }
241
245
result , err := h .execCtx .evaluate (
242
- apiCtx , true , true , pageFn , []goja.Value {
246
+ apiCtx , opts , pageFn , []goja.Value {
243
247
rt .ToValue (injected ),
244
248
rt .ToValue (h ),
245
249
rt .ToValue (p ),
@@ -270,8 +274,12 @@ func (h *ElementHandle) checkElementState(apiCtx context.Context, state string)
270
274
return injected.checkElementState(node, state);
271
275
}
272
276
` )
277
+ opts := evaluateOptions {
278
+ forceCallable : true ,
279
+ returnByValue : true ,
280
+ }
273
281
result , err := h .execCtx .evaluate (
274
- apiCtx , true , true , pageFn , []goja.Value {
282
+ apiCtx , opts , pageFn , []goja.Value {
275
283
rt .ToValue (injected ),
276
284
rt .ToValue (h ),
277
285
rt .ToValue (state ),
@@ -397,8 +405,12 @@ func (h *ElementHandle) dispatchEvent(apiCtx context.Context, typ string, eventI
397
405
injected.dispatchEvent(node, type, eventInit);
398
406
}
399
407
` )
408
+ opts := evaluateOptions {
409
+ forceCallable : true ,
410
+ returnByValue : true ,
411
+ }
400
412
_ , err = h .execCtx .evaluate (
401
- apiCtx , true , true , pageFn , []goja.Value {
413
+ apiCtx , opts , pageFn , []goja.Value {
402
414
rt .ToValue (injected ),
403
415
rt .ToValue (h ),
404
416
rt .ToValue (typ ),
@@ -421,8 +433,12 @@ func (h *ElementHandle) fill(apiCtx context.Context, value string) (interface{},
421
433
return injected.fill(node, value);
422
434
}
423
435
` )
436
+ opts := evaluateOptions {
437
+ forceCallable : true ,
438
+ returnByValue : true ,
439
+ }
424
440
result , err := h .execCtx .evaluate (
425
- apiCtx , true , true , pageFn , []goja.Value {
441
+ apiCtx , opts , pageFn , []goja.Value {
426
442
rt .ToValue (injected ),
427
443
rt .ToValue (h ),
428
444
rt .ToValue (value ),
@@ -450,8 +466,12 @@ func (h *ElementHandle) focus(apiCtx context.Context, resetSelectionIfNotFocused
450
466
return injected.focusNode(node, resetSelectionIfNotFocused);
451
467
}
452
468
` )
469
+ opts := evaluateOptions {
470
+ forceCallable : true ,
471
+ returnByValue : true ,
472
+ }
453
473
result , err := h .execCtx .evaluate (
454
- apiCtx , true , true , pageFn , []goja.Value {
474
+ apiCtx , opts , pageFn , []goja.Value {
455
475
rt .ToValue (injected ),
456
476
rt .ToValue (h ),
457
477
rt .ToValue (resetSelectionIfNotFocused ),
@@ -473,7 +493,11 @@ func (h *ElementHandle) getAttribute(apiCtx context.Context, name string) (inter
473
493
return element.getAttribute('` + name + `');
474
494
}`
475
495
rt := k6common .GetRuntime (apiCtx )
476
- return h .execCtx .evaluate (apiCtx , true , true , rt .ToValue (js ), rt .ToValue (h ))
496
+ opts := evaluateOptions {
497
+ forceCallable : true ,
498
+ returnByValue : true ,
499
+ }
500
+ return h .execCtx .evaluate (apiCtx , opts , rt .ToValue (js ), rt .ToValue (h ))
477
501
}
478
502
479
503
func (h * ElementHandle ) hover (apiCtx context.Context , p * Position ) error {
@@ -485,15 +509,23 @@ func (h *ElementHandle) innerHTML(apiCtx context.Context) (interface{}, error) {
485
509
js := `(element) => {
486
510
return element.innerHTML;
487
511
}`
488
- return h .execCtx .evaluate (apiCtx , true , true , rt .ToValue (js ), rt .ToValue (h ))
512
+ opts := evaluateOptions {
513
+ forceCallable : true ,
514
+ returnByValue : true ,
515
+ }
516
+ return h .execCtx .evaluate (apiCtx , opts , rt .ToValue (js ), rt .ToValue (h ))
489
517
}
490
518
491
519
func (h * ElementHandle ) innerText (apiCtx context.Context ) (interface {}, error ) {
492
520
rt := k6common .GetRuntime (apiCtx )
493
521
js := `(element) => {
494
522
return element.innerText;
495
523
}`
496
- return h .execCtx .evaluate (apiCtx , true , true , rt .ToValue (js ), rt .ToValue (h ))
524
+ opts := evaluateOptions {
525
+ forceCallable : true ,
526
+ returnByValue : true ,
527
+ }
528
+ return h .execCtx .evaluate (apiCtx , opts , rt .ToValue (js ), rt .ToValue (h ))
497
529
}
498
530
499
531
func (h * ElementHandle ) inputValue (apiCtx context.Context ) (interface {}, error ) {
@@ -504,7 +536,11 @@ func (h *ElementHandle) inputValue(apiCtx context.Context) (interface{}, error)
504
536
}
505
537
return element.value;
506
538
}`
507
- return h .execCtx .evaluate (apiCtx , true , true , rt .ToValue (js ), rt .ToValue (h ))
539
+ opts := evaluateOptions {
540
+ forceCallable : true ,
541
+ returnByValue : true ,
542
+ }
543
+ return h .execCtx .evaluate (apiCtx , opts , rt .ToValue (js ), rt .ToValue (h ))
508
544
}
509
545
510
546
func (h * ElementHandle ) isChecked (apiCtx context.Context , timeout time.Duration ) (bool , error ) {
@@ -543,8 +579,12 @@ func (h *ElementHandle) offsetPosition(apiCtx context.Context, offset *Position)
543
579
return injected.getElementBorderWidth(node);
544
580
}
545
581
` )
582
+ opts := evaluateOptions {
583
+ forceCallable : true ,
584
+ returnByValue : true ,
585
+ }
546
586
result , err := h .execCtx .evaluate (
547
- apiCtx , true , true , pageFn , []goja.Value {
587
+ apiCtx , opts , pageFn , []goja.Value {
548
588
rt .ToValue (injected ),
549
589
rt .ToValue (h ),
550
590
}... )
@@ -709,8 +749,12 @@ func (h *ElementHandle) selectOption(apiCtx context.Context, values goja.Value)
709
749
return injected.selectOptions(node, values);
710
750
}
711
751
` )
752
+ opts := evaluateOptions {
753
+ forceCallable : true ,
754
+ returnByValue : false ,
755
+ }
712
756
result , err := h .execCtx .evaluate (
713
- apiCtx , true , false , pageFn , []goja.Value {
757
+ apiCtx , opts , pageFn , []goja.Value {
714
758
rt .ToValue (injected ),
715
759
rt .ToValue (h ),
716
760
rt .ToValue (convValues ),
@@ -738,8 +782,12 @@ func (h *ElementHandle) selectText(apiCtx context.Context) error {
738
782
return injected.selectText(node);
739
783
}
740
784
` )
785
+ opts := evaluateOptions {
786
+ forceCallable : true ,
787
+ returnByValue : true ,
788
+ }
741
789
result , err := h .execCtx .evaluate (
742
- apiCtx , true , true , pageFn , []goja.Value {
790
+ apiCtx , opts , pageFn , []goja.Value {
743
791
rt .ToValue (injected ),
744
792
rt .ToValue (h ),
745
793
}... )
@@ -789,7 +837,11 @@ func (h *ElementHandle) textContent(apiCtx context.Context) (interface{}, error)
789
837
js := `(element) => {
790
838
return element.textContent;
791
839
}`
792
- return h .execCtx .evaluate (apiCtx , true , true , rt .ToValue (js ), rt .ToValue (h ))
840
+ opts := evaluateOptions {
841
+ forceCallable : true ,
842
+ returnByValue : true ,
843
+ }
844
+ return h .execCtx .evaluate (apiCtx , opts , rt .ToValue (js ), rt .ToValue (h ))
793
845
}
794
846
795
847
func (h * ElementHandle ) typ (apiCtx context.Context , text string , opts * KeyboardOptions ) error {
@@ -811,7 +863,11 @@ func (h *ElementHandle) waitAndScrollIntoViewIfNeeded(apiCtx context.Context, fo
811
863
element.scrollIntoViewIfNeeded(true);
812
864
return [window.scrollX, window.scrollY];
813
865
}` )
814
- return h .execCtx .evaluate (apiCtx , true , true , pageFn , rt .ToValue (h ))
866
+ opts := evaluateOptions {
867
+ forceCallable : true ,
868
+ returnByValue : true ,
869
+ }
870
+ return h .execCtx .evaluate (apiCtx , opts , pageFn , rt .ToValue (h ))
815
871
}
816
872
actFn := elementHandleActionFn (h , []string {"visible" , "stable" }, fn , force , noWaitAfter , timeout )
817
873
_ , err := callApiWithTimeout (h .ctx , actFn , timeout )
@@ -832,8 +888,12 @@ func (h *ElementHandle) waitForElementState(apiCtx context.Context, states []str
832
888
return injected.waitForElementStates(node, states, timeout);
833
889
}
834
890
` )
891
+ opts := evaluateOptions {
892
+ forceCallable : true ,
893
+ returnByValue : true ,
894
+ }
835
895
result , err := h .execCtx .evaluate (
836
- apiCtx , true , true , pageFn , []goja.Value {
896
+ apiCtx , opts , pageFn , []goja.Value {
837
897
rt .ToValue (injected ),
838
898
rt .ToValue (h ),
839
899
rt .ToValue (states ),
@@ -873,8 +933,12 @@ func (h *ElementHandle) waitForSelector(apiCtx context.Context, selector string,
873
933
return injected.waitForSelector(selector, scope, strict, state, 'raf', timeout, ...args);
874
934
}
875
935
` )
936
+ eopts := evaluateOptions {
937
+ forceCallable : true ,
938
+ returnByValue : false ,
939
+ }
876
940
result , err := h .execCtx .evaluate (
877
- apiCtx , true , false , pageFn , []goja.Value {
941
+ apiCtx , eopts , pageFn , []goja.Value {
878
942
rt .ToValue (injected ),
879
943
rt .ToValue (parsedSelector ),
880
944
rt .ToValue (h ),
@@ -1166,7 +1230,11 @@ func (h *ElementHandle) OwnerFrame() api.Frame {
1166
1230
return injected.getDocumentElement(node);
1167
1231
}
1168
1232
` )
1169
- res , err := h .execCtx .evaluate (h .ctx , true , false , pageFn , []goja.Value {rt .ToValue (injected ), rt .ToValue (h )}... )
1233
+ opts := evaluateOptions {
1234
+ forceCallable : true ,
1235
+ returnByValue : false ,
1236
+ }
1237
+ res , err := h .execCtx .evaluate (h .ctx , opts , pageFn , []goja.Value {rt .ToValue (injected ), rt .ToValue (h )}... )
1170
1238
if err != nil {
1171
1239
k6common .Throw (rt , fmt .Errorf ("failed getting document element: %w" , err ))
1172
1240
}
@@ -1226,8 +1294,12 @@ func (h *ElementHandle) Query(selector string) api.ElementHandle {
1226
1294
return injected.querySelector(selector, scope || document, false);
1227
1295
}
1228
1296
` )
1297
+ opts := evaluateOptions {
1298
+ forceCallable : true ,
1299
+ returnByValue : false ,
1300
+ }
1229
1301
result , err := h .execCtx .evaluate (
1230
- h .ctx , true , false , pageFn , []goja.Value {
1302
+ h .ctx , opts , pageFn , []goja.Value {
1231
1303
rt .ToValue (injected ),
1232
1304
rt .ToValue (parsedSelector ),
1233
1305
rt .ToValue (h ),
@@ -1267,8 +1339,12 @@ func (h *ElementHandle) QueryAll(selector string) []api.ElementHandle {
1267
1339
return injected.querySelectorAll(selector, scope || document, false);
1268
1340
}
1269
1341
` )
1342
+ opts := evaluateOptions {
1343
+ forceCallable : true ,
1344
+ returnByValue : false ,
1345
+ }
1270
1346
result , err := h .execCtx .evaluate (
1271
- h .ctx , true , false , pageFn , []goja.Value {
1347
+ h .ctx , opts , pageFn , []goja.Value {
1272
1348
rt .ToValue (injected ),
1273
1349
rt .ToValue (parsedSelector ),
1274
1350
rt .ToValue (h ),
0 commit comments