re-enable CDP dom domain

This commit is contained in:
Karl Seguin
2025-12-09 13:04:01 +08:00
parent 9132bc2375
commit 0e1b966dce
7 changed files with 653 additions and 657 deletions

View File

@@ -109,7 +109,7 @@ pub fn getRemoteObject(
group: []const u8,
value: anytype,
) !RemoteObject {
const js_value = try context.zigValueToJs(value);
const js_value = try context.zigValueToJs(value, .{});
// We do not want to expose this as a parameter for now
const generate_preview = false;
@@ -127,8 +127,10 @@ pub fn getNodePtr(self: *const Inspector, allocator: Allocator, object_id: []con
const unwrapped = try self.session.unwrapObject(allocator, object_id);
// The values context and groupId are not used here
const toa = getTaggedAnyOpaque(unwrapped.value) orelse return null;
if (toa.subtype == null or toa.subtype != .node) return error.ObjectIdIsNotANode;
return toa.ptr;
if (toa.subtype == null or toa.subtype != .node) {
return error.ObjectIdIsNotANode;
}
return toa.value;
}
const NoopInspector = struct {

View File

@@ -0,0 +1 @@
<p>1</p> <p>2</p>

View File

@@ -0,0 +1 @@
<div><p>2</p></div>

View File

@@ -27,7 +27,6 @@ const reflect = @import("../reflect.zig");
const Node = @import("Node.zig");
const CSS = @import("CSS.zig");
const DOMRect = @import("DOMRect.zig");
const ShadowRoot = @import("ShadowRoot.zig");
const collections = @import("collections.zig");
const Selector = @import("selector/Selector.zig");
@@ -35,6 +34,7 @@ const Animation = @import("animation/Animation.zig");
const DOMStringMap = @import("element/DOMStringMap.zig");
const CSSStyleProperties = @import("css/CSSStyleProperties.zig");
pub const DOMRect = @import("DOMRect.zig");
pub const Svg = @import("element/Svg.zig");
pub const Html = @import("element/Html.zig");
pub const Attribute = @import("element/Attribute.zig");

File diff suppressed because it is too large Load Diff

View File

@@ -93,7 +93,7 @@ const TestContext = struct {
id: ?[]const u8 = null,
target_id: ?[]const u8 = null,
session_id: ?[]const u8 = null,
html: ?[]const u8 = null,
url: ?[:0]const u8 = null,
};
pub fn loadBrowserContext(self: *TestContext, opts: BrowserContextOpts) !*main.BrowserContext(TestCDP) {
var c = self.cdp();
@@ -116,12 +116,23 @@ const TestContext = struct {
bc.session_id = sid;
}
// @ZIGDOM
// if (opts.html) |html| {
// if (bc.session_id == null) bc.session_id = "SID-X";
// const page = try bc.session.createPage();
// page.window._document = (try Document.init(html)).doc;
// }
if (opts.url) |url| {
if (bc.session_id == null) {
bc.session_id = "SID-X";
}
if (bc.target_id == null) {
bc.target_id = "TID-X";
}
const page = try bc.session.createPage();
const full_url = try std.fmt.allocPrintSentinel(
self.arena.allocator(),
"http://127.0.0.1:9582/src/browser/tests/{s}",
.{ url },
0,
);
try page.navigate(full_url, .{});
bc.session.fetchWait(2000);
}
return bc;
}

View File

@@ -430,10 +430,6 @@ pub fn pageTest(comptime test_file: []const u8) !*Page {
try page.navigate(url, .{});
test_session.fetchWait(2000);
page._session.browser.runMicrotasks();
page._session.browser.runMessageLoop();
return page;
}