From 499d0d0e8a663304143ba7b4602398eabbf08c37 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Thu, 14 Sep 2023 17:26:19 +0100 Subject: [PATCH] Fix reload & setContent to use navigation timeout These methods should work with the default navigation instead of the default timeout to match the behaviour in Playwright. --- common/frame.go | 4 +++- common/page.go | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/common/frame.go b/common/frame.go index e5755f932..c96792dda 100644 --- a/common/frame.go +++ b/common/frame.go @@ -1428,7 +1428,9 @@ func (f *Frame) selectOption(selector string, values goja.Value, opts *FrameSele func (f *Frame) SetContent(html string, opts goja.Value) { f.log.Debugf("Frame:SetContent", "fid:%s furl:%q", f.ID(), f.URL()) - parsedOpts := NewFrameSetContentOptions(f.defaultTimeout()) + parsedOpts := NewFrameSetContentOptions( + time.Duration(f.manager.timeoutSettings.navigationTimeout()) * time.Second, + ) if err := parsedOpts.Parse(f.ctx, opts); err != nil { k6ext.Panic(f.ctx, "parsing set content options: %w", err) } diff --git a/common/page.go b/common/page.go index 3c38da14f..79ad34cbf 100644 --- a/common/page.go +++ b/common/page.go @@ -860,7 +860,10 @@ func (p *Page) QueryAll(selector string) ([]api.ElementHandle, error) { func (p *Page) Reload(opts goja.Value) api.Response { p.logger.Debugf("Page:Reload", "sid:%v", p.sessionID()) - parsedOpts := NewPageReloadOptions(LifecycleEventLoad, p.defaultTimeout()) + parsedOpts := NewPageReloadOptions( + LifecycleEventLoad, + time.Duration(p.timeoutSettings.navigationTimeout())*time.Second, + ) if err := parsedOpts.Parse(p.ctx, opts); err != nil { k6ext.Panic(p.ctx, "parsing reload options: %w", err) }