@@ -62,3 +62,75 @@ func TestBrowserContextDefaultOptions(t *testing.T) {
62
62
assert .NotEqual (t , defaults .DeviceScaleFactor , opts .DeviceScaleFactor )
63
63
assert .Equal (t , defaults .Locale , opts .Locale ) // should remain as default
64
64
}
65
+
66
+ func TestBrowserContextAllOptions (t * testing.T ) {
67
+ vu := k6test .NewVU (t )
68
+ opts , err := vu .Runtime ().RunString (`const opts = {
69
+ acceptDownloads: true,
70
+ downloadsPath: '/tmp',
71
+ bypassCSP: true,
72
+ colorScheme: 'dark',
73
+ deviceScaleFactor: 1,
74
+ extraHTTPHeaders: {
75
+ 'X-Header': 'value',
76
+ },
77
+ geolocation: { latitude: 51.509865, longitude: -0.118092, accuracy: 1 },
78
+ hasTouch: true,
79
+ httpCredentials: { username: 'admin', password: 'password' },
80
+ ignoreHTTPSErrors: true,
81
+ isMobile: true,
82
+ javaScriptEnabled: true,
83
+ locale: 'fr-FR',
84
+ offline: true,
85
+ permissions: ['camera', 'microphone'],
86
+ reducedMotion: 'no-preference',
87
+ screen: { width: 800, height: 600 },
88
+ timezoneID: 'Europe/Paris',
89
+ userAgent: 'my agent',
90
+ viewport: { width: 800, height: 600 },
91
+ };
92
+ opts;
93
+ ` )
94
+ require .NoError (t , err )
95
+
96
+ parsedOpts , err := parseBrowserContextOptions (vu .Runtime (), opts )
97
+ require .NoError (t , err )
98
+
99
+ assert .Equal (t , & common.BrowserContextOptions {
100
+ AcceptDownloads : true ,
101
+ DownloadsPath : "/tmp" ,
102
+ BypassCSP : true ,
103
+ ColorScheme : common .ColorSchemeDark ,
104
+ DeviceScaleFactor : 1 ,
105
+ ExtraHTTPHeaders : map [string ]string {
106
+ "X-Header" : "value" ,
107
+ },
108
+ Geolocation : & common.Geolocation {
109
+ Latitude : 51.509865 ,
110
+ Longitude : - 0.118092 ,
111
+ Accuracy : 1 ,
112
+ },
113
+ HasTouch : true ,
114
+ HTTPCredentials : common.Credentials {
115
+ Username : "admin" ,
116
+ Password : "password" ,
117
+ },
118
+ IgnoreHTTPSErrors : true ,
119
+ IsMobile : true ,
120
+ JavaScriptEnabled : true ,
121
+ Locale : "fr-FR" ,
122
+ Offline : true ,
123
+ Permissions : []string {"camera" , "microphone" },
124
+ ReducedMotion : common .ReducedMotionNoPreference ,
125
+ Screen : common.Screen {
126
+ Width : 800 ,
127
+ Height : 600 ,
128
+ },
129
+ TimezoneID : "Europe/Paris" ,
130
+ UserAgent : "my agent" ,
131
+ Viewport : common.Viewport {
132
+ Width : 800 ,
133
+ Height : 600 ,
134
+ },
135
+ }, parsedOpts )
136
+ }
0 commit comments