@@ -147,17 +147,32 @@ fn evaluate(
147147 const session = ctx .browser .currentSession ();
148148 // TODO: should we use instead the allocator of the page?
149149 // the following code does not work with session.page.?.arena.allocator() as alloc
150+ const res = try runtimeEvaluate (session .alloc , id , session .env , params .expression , "cdp" );
150151
151- _ = try runtimeEvaluate (session .alloc , id , session .env , params .expression , "cdp" );
152+ // check result
153+ const res_type = try res .typeOf (session .env );
152154
153155 // TODO: Resp should depends on JS result returned by the JS engine
154156 const Resp = struct {
155- type : []const u8 = "object" ,
156- className : []const u8 = "UtilityScript" ,
157- description : []const u8 = "UtilityScript" ,
158- objectId : []const u8 = "7481631759780215274.3.2" ,
157+ result : struct {
158+ type : []const u8 ,
159+ subtype : ? []const u8 = null ,
160+ className : ? []const u8 = null ,
161+ description : ? []const u8 = null ,
162+ objectId : ? []const u8 = null ,
163+ },
164+ };
165+ var resp = Resp {
166+ .result = .{
167+ .type = @tagName (res_type ),
168+ },
159169 };
160- return result (alloc , id , Resp , Resp {}, msg .sessionID );
170+ if (res_type == .object ) {
171+ resp .result .className = "Object" ;
172+ resp .result .description = "Object" ;
173+ resp .result .objectId = "-9051357107442861868.3.2" ;
174+ }
175+ return result (alloc , id , Resp , resp , msg .sessionID );
161176}
162177
163178fn addBinding (
0 commit comments