File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,7 @@ pub fn BrowserContext(comptime CDP_T: type) type {
320320
321321 inspector : Inspector ,
322322 isolated_world : ? IsolatedWorld ,
323+ http_proxy_before : ?? std.Uri = null ,
323324
324325 const Self = @This ();
325326
@@ -374,6 +375,8 @@ pub fn BrowserContext(comptime CDP_T: type) type {
374375 self .node_registry .deinit ();
375376 self .node_search_list .deinit ();
376377 self .cdp .browser .notification .unregisterAll (self );
378+
379+ if (self .http_proxy_before ) | prev_proxy | self .cdp .browser .http_client .http_proxy = prev_proxy ;
377380 }
378381
379382 pub fn reset (self : * Self ) void {
Original file line number Diff line number Diff line change @@ -66,11 +66,30 @@ fn getBrowserContexts(cmd: anytype) !void {
6666}
6767
6868fn createBrowserContext (cmd : anytype ) ! void {
69+ const params = try cmd .params (struct {
70+ disposeOnDetach : bool = false ,
71+ proxyServer : ? []const u8 = null ,
72+ proxyBypassList : ? []const u8 = null ,
73+ originsWithUniversalNetworkAccess : ? []const []const u8 = null ,
74+ });
75+ if (params ) | p | {
76+ if (p .disposeOnDetach or p .proxyBypassList != null or p .originsWithUniversalNetworkAccess != null ) std .debug .print ("Target.createBrowserContext: Not implemented param set\n " , .{});
77+ }
78+
6979 const bc = cmd .createBrowserContext () catch | err | switch (err ) {
7080 error .AlreadyExists = > return cmd .sendError (-32000 , "Cannot have more than one browser context at a time" ),
7181 else = > return err ,
7282 };
7383
84+ if (params ) | p | {
85+ if (p .proxyServer ) | proxy | {
86+ // For now the http client is not in the browser context so we assume there is just 1.
87+ bc .http_proxy_before = cmd .cdp .browser .http_client .http_proxy ;
88+ const proxy_cp = try cmd .cdp .browser .http_client .allocator .dupe (u8 , proxy );
89+ cmd .cdp .browser .http_client .http_proxy = try std .Uri .parse (proxy_cp );
90+ }
91+ }
92+
7493 return cmd .sendResult (.{
7594 .browserContextId = bc .id ,
7695 }, .{});
You can’t perform that action at this time.
0 commit comments