Skip to content

Commit 6c2e42a

Browse files
committed
Update the page.waitForNavigate mapping
We're now injecting and retrieving the jsRegexChecker to pass into WaitForNavigation that will be used to perform a url match against the pattern input from the user script.
1 parent 8a47725 commit 6c2e42a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/js/modules/k6/browser/browser/page_mapping.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,15 @@ func mapPage(vu moduleVU, p *common.Page) mapping { //nolint:gocognit,cyclop
500500
return nil, fmt.Errorf("parsing page wait for navigation options: %w", err)
501501
}
502502

503-
return k6ext.Promise(vu.Context(), func() (result any, reason error) {
504-
resp, err := p.WaitForNavigation(popts, nil)
503+
// Inject JS regex checker for URL regex pattern matching
504+
ctx := vu.Context()
505+
jsRegexChecker, err := injectRegexMatcherScript(ctx, vu, p.TargetID())
506+
if err != nil {
507+
return nil, err
508+
}
509+
510+
return k6ext.Promise(ctx, func() (result any, reason error) {
511+
resp, err := p.WaitForNavigation(popts, jsRegexChecker)
505512
if err != nil {
506513
return nil, err //nolint:wrapcheck
507514
}

0 commit comments

Comments
 (0)