From cd487a47a10b1de22c00f063db663be3202a154f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:11:37 +0000 Subject: [PATCH] Upgrade experimental module (deps): Bump github.com/grafana/xk6-browser Bumps [github.com/grafana/xk6-browser](https://github.com/grafana/xk6-browser) from 1.5.2-0.20240607140836-ffcc1f5169ad to 1.6.0. - [Release notes](https://github.com/grafana/xk6-browser/releases) - [Commits](https://github.com/grafana/xk6-browser/commits/v1.6.0) --- updated-dependencies: - dependency-name: github.com/grafana/xk6-browser dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- .../grafana/xk6-browser/chromium/browser_type.go | 11 ++++++++++- .../grafana/xk6-browser/common/js_handle.go | 2 ++ vendor/github.com/grafana/xk6-browser/common/page.go | 7 ++++++- vendor/modules.txt | 2 +- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 85bad3bb2fb..99ce9480cff 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/golang/protobuf v1.5.4 github.com/gorilla/websocket v1.5.1 github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee - github.com/grafana/xk6-browser v1.5.2-0.20240607140836-ffcc1f5169ad + github.com/grafana/xk6-browser v1.6.0 github.com/grafana/xk6-dashboard v0.7.4 github.com/grafana/xk6-output-prometheus-remote v0.4.0 github.com/grafana/xk6-redis v0.3.0 diff --git a/go.sum b/go.sum index 451c6ed1cf2..78cedff99a2 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/ github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee h1:KjQPRiLoSZMz+oMdEyh8fE/rurMpx3lpRH8PIR66nzo= github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee/go.mod h1:4uA93vCOP7fFfkAEByuRieuU72pAc5DH05b71yCIVsQ= -github.com/grafana/xk6-browser v1.5.2-0.20240607140836-ffcc1f5169ad h1:q3sB942oYrD7NlcsS9hz26I9W+EKfpKVmhKe7dWUp3s= -github.com/grafana/xk6-browser v1.5.2-0.20240607140836-ffcc1f5169ad/go.mod h1:xLaGGhTMHIRsMvkVWFYh9RPy87kG2n4L4Or6DeI8U+o= +github.com/grafana/xk6-browser v1.6.0 h1:x8ZfBwiUJRRKNEw+Asr5ae9o2gFvYU1Ll/4dDMNIPZ8= +github.com/grafana/xk6-browser v1.6.0/go.mod h1:xLaGGhTMHIRsMvkVWFYh9RPy87kG2n4L4Or6DeI8U+o= github.com/grafana/xk6-dashboard v0.7.4 h1:0ZRPTAXW+6A3Xqq/a/OaIZhxUt1SOMwUFff0IPwBHrs= github.com/grafana/xk6-dashboard v0.7.4/go.mod h1:300QyQ+OQAYz/L/AzB5tKzPeBY5eKh2wl1NsRmCbsx4= github.com/grafana/xk6-output-prometheus-remote v0.4.0 h1:7k3xjuKaD9BwcX8iuu5v6PtAK1L53kvx1r8BaTUfRH4= diff --git a/vendor/github.com/grafana/xk6-browser/chromium/browser_type.go b/vendor/github.com/grafana/xk6-browser/chromium/browser_type.go index ed3c2f4b4d7..4f3dc65c0be 100644 --- a/vendor/github.com/grafana/xk6-browser/chromium/browser_type.go +++ b/vendor/github.com/grafana/xk6-browser/chromium/browser_type.go @@ -304,7 +304,7 @@ func parseArgs(flags map[string]any) ([]string, error) { for name, value := range flags { switch value := value.(type) { case string: - args = append(args, fmt.Sprintf("--%s=%s", name, value)) + args = append(args, parseStringArg(name, value)) case bool: if value { args = append(args, fmt.Sprintf("--%s", name)) @@ -324,6 +324,15 @@ func parseArgs(flags map[string]any) ([]string, error) { return args, nil } +func parseStringArg(flag string, value string) string { + if strings.TrimSpace(value) == "" { + // If the value is empty, we don't include it in the args list. + // Otherwise, it will produce "--name=" which is invalid. + return fmt.Sprintf("--%s", flag) + } + return fmt.Sprintf("--%s=%s", flag, value) +} + func prepareFlags(lopts *common.BrowserOptions, k6opts *k6lib.Options) (map[string]any, error) { // After Puppeteer's and Playwright's default behavior. f := map[string]any{ diff --git a/vendor/github.com/grafana/xk6-browser/common/js_handle.go b/vendor/github.com/grafana/xk6-browser/common/js_handle.go index 3f17b79acc8..a33cf054faa 100644 --- a/vendor/github.com/grafana/xk6-browser/common/js_handle.go +++ b/vendor/github.com/grafana/xk6-browser/common/js_handle.go @@ -124,6 +124,7 @@ func (h *BaseJSHandle) dispose() error { // Evaluate will evaluate provided page function within an execution context. func (h *BaseJSHandle) Evaluate(pageFunc string, args ...any) (any, error) { + args = append([]any{h}, args...) res, err := h.execCtx.Eval(h.ctx, pageFunc, args...) if err != nil { return nil, fmt.Errorf("evaluating element: %w", err) @@ -134,6 +135,7 @@ func (h *BaseJSHandle) Evaluate(pageFunc string, args ...any) (any, error) { // EvaluateHandle will evaluate provided page function within an execution context. func (h *BaseJSHandle) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error) { + args = append([]any{h}, args...) eh, err := h.execCtx.EvalHandle(h.ctx, pageFunc, args...) if err != nil { return nil, fmt.Errorf("evaluating handle for element: %w", err) diff --git a/vendor/github.com/grafana/xk6-browser/common/page.go b/vendor/github.com/grafana/xk6-browser/common/page.go index 96585993d6d..35b2f296ed0 100644 --- a/vendor/github.com/grafana/xk6-browser/common/page.go +++ b/vendor/github.com/grafana/xk6-browser/common/page.go @@ -1085,6 +1085,7 @@ func (p *Page) Reload(opts sobek.Value) (*Response, error) { //nolint:funlen,cyc ) select { case <-p.ctx.Done(): + err = fmt.Errorf("reloading page: %w", p.ctx.Err()) case <-timeoutCtx.Done(): err = wrapTimeoutError(timeoutCtx.Err()) case event := <-waitForFrameNavigation: @@ -1099,7 +1100,11 @@ func (p *Page) Reload(opts sobek.Value) (*Response, error) { //nolint:funlen,cyc } var resp *Response - if req := navigationEvent.newDocument.request; req != nil { + + // Sometimes the new document is not yet available when the navigation event is emitted. + newDocument := navigationEvent.newDocument + if newDocument != nil && newDocument.request != nil { + req := newDocument.request req.responseMu.RLock() resp = req.response req.responseMu.RUnlock() diff --git a/vendor/modules.txt b/vendor/modules.txt index 06b4ab96922..8ac8bdb447b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -176,7 +176,7 @@ github.com/gorilla/websocket # github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee ## explicit; go 1.20 github.com/grafana/sobek -# github.com/grafana/xk6-browser v1.5.2-0.20240607140836-ffcc1f5169ad +# github.com/grafana/xk6-browser v1.6.0 ## explicit; go 1.20 github.com/grafana/xk6-browser/browser github.com/grafana/xk6-browser/chromium