@@ -40,18 +40,51 @@ func mapBrowserToGoja(vu k6modules.VU) *goja.Object {
40
40
return obj
41
41
}
42
42
43
+ // mapBrowserContext to the JS module.
44
+ func mapBrowserContext (rt * goja.Runtime , bc api.BrowserContext ) mapping {
45
+ _ = rt
46
+ return mapping {
47
+ "addCookies" : bc .AddCookies ,
48
+ "addInitScript" : bc .AddInitScript ,
49
+ "browser" : bc .Browser ,
50
+ "clearCookies" : bc .ClearCookies ,
51
+ "clearPermissions" : bc .ClearPermissions ,
52
+ "close" : bc .Close ,
53
+ "cookies" : bc .Cookies ,
54
+ "exposeBinding" : bc .ExposeBinding ,
55
+ "exposeFunction" : bc .ExposeFunction ,
56
+ "grantPermissions" : bc .GrantPermissions ,
57
+ "newCDPSession" : bc .NewCDPSession ,
58
+ "route" : bc .Route ,
59
+ "setDefaultNavigationTimeout" : bc .SetDefaultNavigationTimeout ,
60
+ "setDefaultTimeout" : bc .SetDefaultTimeout ,
61
+ "setExtraHTTPHeaders" : bc .SetExtraHTTPHeaders ,
62
+ "setGeolocation" : bc .SetGeolocation ,
63
+ "setHTTPCredentials" : bc .SetHTTPCredentials , //nolint:staticcheck
64
+ "setOffline" : bc .SetOffline ,
65
+ "storageState" : bc .StorageState ,
66
+ "unroute" : bc .Unroute ,
67
+ "waitForEvent" : bc .WaitForEvent ,
68
+ "pages" : bc .Pages ,
69
+ "newPage" : bc .NewPage ,
70
+ }
71
+ }
72
+
43
73
// mapBrowser to the JS module.
44
74
func mapBrowser (rt * goja.Runtime , b api.Browser ) mapping {
45
- _ = rt
46
75
return mapping {
47
76
"close" : b .Close ,
48
77
"contexts" : b .Contexts ,
49
78
"isConnected" : b .IsConnected ,
50
79
"on" : b .On ,
51
80
"userAgent" : b .UserAgent ,
52
81
"version" : b .Version ,
53
- "newContext" : b .NewContext ,
54
- "newPage" : b .NewPage ,
82
+ "newContext" : func (opts goja.Value ) * goja.Object {
83
+ bctx := b .NewContext (opts )
84
+ m := mapBrowserContext (rt , bctx )
85
+ return rt .ToValue (m ).ToObject (rt )
86
+ },
87
+ "newPage" : b .NewPage ,
55
88
}
56
89
}
57
90
0 commit comments