mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-05 14:57:11 +00:00
Make js.Bridge aware of string.String for input parameters
Avoids having to allocate small strings when going from v8 -> Zig. Also added a discriminatory type, string.Global which uses the arena, rather than the call_arena, if an allocation _is_ necessary. (This is similar to a feature we had before, but was lost in zigdom). Strings from v8 that need to be persisted, can be allocated directly v8 -> arena, rather than v8 -> call_arena -> arena. I think there are a lot of places where we should use string.String - where strings are expected to be short (e.g. attribute names). But started with just document.querySelector and querySelectorAll.
This commit is contained in:
@@ -344,7 +344,7 @@ test "cdp Node: Registry register" {
|
||||
var doc = page.window._document;
|
||||
|
||||
{
|
||||
const dom_node = (try doc.querySelector("#a1", page)).?.asNode();
|
||||
const dom_node = (try doc.querySelector(testing.newString("#a1"), page)).?.asNode();
|
||||
const node = try registry.register(dom_node);
|
||||
const n1b = registry.lookup_by_id.get(1).?;
|
||||
const n1c = registry.lookup_by_node.get(node.dom).?;
|
||||
@@ -356,7 +356,7 @@ test "cdp Node: Registry register" {
|
||||
}
|
||||
|
||||
{
|
||||
const dom_node = (try doc.querySelector("p", page)).?.asNode();
|
||||
const dom_node = (try doc.querySelector(testing.newString("p"), page)).?.asNode();
|
||||
const node = try registry.register(dom_node);
|
||||
const n1b = registry.lookup_by_id.get(2).?;
|
||||
const n1c = registry.lookup_by_node.get(node.dom).?;
|
||||
@@ -400,18 +400,18 @@ test "cdp Node: search list" {
|
||||
defer page._session.removePage();
|
||||
var doc = page.window._document;
|
||||
|
||||
const s1 = try search_list.create((try doc.querySelectorAll("a", page))._nodes);
|
||||
const s1 = try search_list.create((try doc.querySelectorAll(testing.newString("a"), page))._nodes);
|
||||
try testing.expectEqual("1", s1.name);
|
||||
try testing.expectEqualSlices(u32, &.{ 1, 2 }, s1.node_ids);
|
||||
|
||||
try testing.expectEqual(2, registry.lookup_by_id.count());
|
||||
try testing.expectEqual(2, registry.lookup_by_node.count());
|
||||
|
||||
const s2 = try search_list.create((try doc.querySelectorAll("#a1", page))._nodes);
|
||||
const s2 = try search_list.create((try doc.querySelectorAll(testing.newString("#a1"), page))._nodes);
|
||||
try testing.expectEqual("2", s2.name);
|
||||
try testing.expectEqualSlices(u32, &.{1}, s2.node_ids);
|
||||
|
||||
const s3 = try search_list.create((try doc.querySelectorAll("#a2", page))._nodes);
|
||||
const s3 = try search_list.create((try doc.querySelectorAll(testing.newString("#a2"), page))._nodes);
|
||||
try testing.expectEqual("3", s3.name);
|
||||
try testing.expectEqualSlices(u32, &.{2}, s3.node_ids);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ pub const expectEqual = base.expectEqual;
|
||||
pub const expectError = base.expectError;
|
||||
pub const expectEqualSlices = base.expectEqualSlices;
|
||||
pub const pageTest = base.pageTest;
|
||||
pub const newString = base.newString;
|
||||
|
||||
const Client = struct {
|
||||
allocator: Allocator,
|
||||
|
||||
Reference in New Issue
Block a user