@@ -13,6 +13,7 @@ const PageMethods = enum {
1313 setLifecycleEventsEnabled ,
1414 addScriptToEvaluateOnNewDocument ,
1515 createIsolatedWorld ,
16+ navigate ,
1617};
1718
1819pub fn page (
@@ -30,6 +31,7 @@ pub fn page(
3031 .setLifecycleEventsEnabled = > setLifecycleEventsEnabled (alloc , id , scanner , ctx ),
3132 .addScriptToEvaluateOnNewDocument = > addScriptToEvaluateOnNewDocument (alloc , id , scanner , ctx ),
3233 .createIsolatedWorld = > createIsolatedWorld (alloc , id , scanner , ctx ),
34+ .navigate = > navigate (alloc , id , scanner , ctx ),
3335 };
3436}
3537
@@ -143,3 +145,38 @@ fn createIsolatedWorld(
143145
144146 return result (alloc , id , Resp , .{}, content .sessionID );
145147}
148+
149+ fn navigate (
150+ alloc : std.mem.Allocator ,
151+ id : u64 ,
152+ scanner : * std.json.Scanner ,
153+ ctx : * Ctx ,
154+ ) ! []const u8 {
155+
156+ // input
157+ const Params = struct {
158+ url : []const u8 ,
159+ referrer : ? []const u8 = null ,
160+ transitionType : ? []const u8 = null , // TODO: enum
161+ frameId : ? []const u8 = null ,
162+ referrerPolicy : ? []const u8 = null , // TODO: enum
163+ };
164+ const content = try cdp .getContent (alloc , Params , scanner );
165+ std .debug .assert (content .sessionID != null );
166+
167+ // change state
168+ ctx .state .url = content .params .url ;
169+ ctx .state .loaderID = "AF8667A203C5392DBE9AC290044AA4C2" ;
170+
171+ // output
172+ const Resp = struct {
173+ frameId : []const u8 ,
174+ loaderId : ? []const u8 ,
175+ errorText : ? []const u8 = null ,
176+ };
177+ const resp = Resp {
178+ .frameId = ctx .state .frameID ,
179+ .loaderId = ctx .state .loaderID ,
180+ };
181+ return result (alloc , id , Resp , resp , content .sessionID );
182+ }
0 commit comments