perf(observation): validate document identity against snapshot roots

This commit is contained in:
Ljy-0827
2026-09-09 16:09:09 +08:00
committed by drakezhang
parent 2d1e5c6d9d
commit b4006d5b85
6 changed files with 118 additions and 256 deletions
@@ -2,24 +2,6 @@ import { describe, expect, it } from "vitest";
import { buildFrameGraph, type CdpFrameTreeNode, type CdpFrameTreeSource } from "../frame-graph";
describe("buildFrameGraph", () => {
it("preserves the owning target's loader identity", () => {
const graph = buildFrameGraph([
{
target: { tabId: 4 },
tree: {
frame: { id: "root", loaderId: "root-loader" },
childFrames: [{ frame: { id: "child", loaderId: "stale-placeholder" } }],
},
},
{
target: { tabId: 4, sessionId: "child-session" },
tree: { frame: { id: "child", loaderId: "child-loader" } },
},
]);
expect(graph?.frames.find((frame) => frame.frameId === "root")?.loaderId).toBe("root-loader");
expect(graph?.frames.find((frame) => frame.frameId === "child")?.loaderId).toBe("child-loader");
});
it("keeps sibling frames distinct and routes nested OOPIFs to their child sessions", () => {
const graph = buildFrameGraph([
{
@@ -8,7 +8,6 @@ export interface CdpFrame {
parentFrameId?: string;
ownerBackendNodeId?: number;
url?: string;
loaderId?: string;
target: CdpTarget;
}
@@ -22,7 +21,6 @@ export interface CdpFrameTreeNode {
id: string;
parentId?: string;
url?: string;
loaderId?: string;
};
childFrames?: CdpFrameTreeNode[];
}
@@ -50,7 +48,6 @@ function mergeFrame(
frameId: node.frame.id,
...(parentFrameId ? { parentFrameId } : {}),
...(url ? { url } : {}),
...(node.frame.loaderId ? { loaderId: node.frame.loaderId } : {}),
target,
});
}