From 5854f190c8b150db18f0d77be7deef133284ba26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0nan=C3=A7=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 7 Nov 2024 10:00:55 -0500 Subject: [PATCH] Add TestBrowserContextAllOptions --- browser/browser_context_options_test.go | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/browser/browser_context_options_test.go b/browser/browser_context_options_test.go index 82c713eda..dd6ab3adc 100644 --- a/browser/browser_context_options_test.go +++ b/browser/browser_context_options_test.go @@ -62,3 +62,46 @@ func TestBrowserContextDefaultOptions(t *testing.T) { assert.NotEqual(t, defaults.DeviceScaleFactor, opts.DeviceScaleFactor) assert.Equal(t, defaults.Locale, opts.Locale) // should remain as default } + +func TestBrowserContextAllOptions(t *testing.T) { + vu := k6test.NewVU(t) + + opts := common.BrowserContextOptions{ + AcceptDownloads: true, + DownloadsPath: "/tmp", + BypassCSP: true, + ColorScheme: common.ColorSchemeDark, + DeviceScaleFactor: 2.0, + ExtraHTTPHeaders: map[string]string{ + "X-Header": "value", + }, + Geolocation: &common.Geolocation{ + Latitude: 1.0, + Longitude: 2.0, + Accuracy: 3.0, + }, + HasTouch: true, + HTTPCredentials: common.Credentials{Username: "user", Password: "pass"}, + IgnoreHTTPSErrors: true, + IsMobile: true, + JavaScriptEnabled: true, + Locale: "en-US", + Offline: true, + Permissions: []string{"great power requires great responsibility"}, + ReducedMotion: common.ReducedMotionReduce, + Screen: common.Screen{ + Width: 1920, + Height: 1080, + }, + TimezoneID: "America/New_York", + UserAgent: "k6", + VideosPath: "/tmp", + Viewport: common.Viewport{ + Width: 1920, + Height: 1080, + }, + } + parsedOpts, err := parseBrowserContextOptions(vu.Runtime(), vu.ToSobekValue(opts)) + require.NoError(t, err) + assert.Equal(t, opts, *parsedOpts) +}