netsurf: fix DocumentHTMLParseFromStr and add test

This commit is contained in:
Pierre Tachoire
2024-01-09 11:33:02 +01:00
parent 57e948ded5
commit cc3a7ec4a1
2 changed files with 23 additions and 31 deletions

View File

@@ -98,3 +98,14 @@ test {
try jsruntime.loadEnv(&arena_alloc, testsAllExecFn, apis);
}
test "DocumentHTMLParseFromStr" {
const file = try std.fs.cwd().openFile("test.html", .{});
defer file.close();
const str = try file.readToEndAlloc(std.testing.allocator, std.math.maxInt(u32));
defer std.testing.allocator.free(str);
doc = try parser.documentHTMLParseFromStr(str);
parser.documentHTMLClose(doc) catch {};
}