




























@@ -454,6 +454,38 @@ describe("cdp internal", () => {
454454const out = formatAriaSnapshot(nodes, 3);
455455expect(out).toHaveLength(3);
456456});
457+458+it("returns nodes when snapshotAria receives a non-finite limit", async () => {
459+const server = await startMockWsServer((msg, socket) => {
460+if (msg.method === "Accessibility.enable") {
461+socket.send(JSON.stringify({ id: msg.id, result: {} }));
462+return;
463+}
464+if (msg.method === "Accessibility.getFullAXTree") {
465+socket.send(
466+JSON.stringify({
467+id: msg.id,
468+result: {
469+nodes: [
470+{
471+nodeId: "1",
472+role: { value: "RootWebArea" },
473+name: { value: "Home" },
474+childIds: [],
475+},
476+],
477+},
478+}),
479+);
480+}
481+});
482+wss = server.wss;
483+484+const snap = await snapshotAria({ wsUrl: server.wsUrl, limit: Number.NaN });
485+486+expect(snap.nodes).toHaveLength(1);
487+expect(snap.nodes[0]?.role).toBe("RootWebArea");
488+});
457489});
458490459491describe("snapshotAria", () => {
@@ -756,6 +788,31 @@ describe("cdp internal", () => {
756788const snap = await snapshotDom({ wsUrl: server.wsUrl });
757789expect(snap.nodes).toStrictEqual([]);
758790});
791+792+it("uses default DOM snapshot budgets for non-finite options", async () => {
793+const server = await startMockWsServer((msg, socket) => {
794+if (msg.method === "Runtime.enable") {
795+socket.send(JSON.stringify({ id: msg.id, result: {} }));
796+return;
797+}
798+if (msg.method === "Runtime.evaluate") {
799+const expression =
800+typeof msg.params?.expression === "string" ? msg.params.expression : "";
801+expect(expression).toContain("const maxNodes = 800;");
802+expect(expression).toContain("const maxText = 220;");
803+socket.send(JSON.stringify({ id: msg.id, result: { result: { value: { nodes: [] } } } }));
804+}
805+});
806+wss = server.wss;
807+808+const snap = await snapshotDom({
809+wsUrl: server.wsUrl,
810+limit: Number.NaN,
811+maxTextChars: Number.NaN,
812+});
813+814+expect(snap.nodes).toStrictEqual([]);
815+});
759816});
760817761818describe("getDomText", () => {
@@ -867,6 +924,34 @@ describe("cdp internal", () => {
867924const out = await querySelector({ wsUrl: server.wsUrl, selector: "button" });
868925expect(out.matches).toStrictEqual([]);
869926});
927+928+it("uses default query budgets for non-finite options", async () => {
929+const server = await startMockWsServer((msg, socket) => {
930+if (msg.method === "Runtime.enable") {
931+socket.send(JSON.stringify({ id: msg.id, result: {} }));
932+return;
933+}
934+if (msg.method === "Runtime.evaluate") {
935+const expression =
936+typeof msg.params?.expression === "string" ? msg.params.expression : "";
937+expect(expression).toContain("const lim = 20;");
938+expect(expression).toContain("const maxText = 500;");
939+expect(expression).toContain("const maxHtml = 1500;");
940+socket.send(JSON.stringify({ id: msg.id, result: { result: { value: [] } } }));
941+}
942+});
943+wss = server.wss;
944+945+const out = await querySelector({
946+wsUrl: server.wsUrl,
947+selector: "button",
948+limit: Number.NaN,
949+maxTextChars: Number.NaN,
950+maxHtmlChars: Number.NaN,
951+});
952+953+expect(out.matches).toStrictEqual([]);
954+});
870955});
871956872957describe("normalizeCdpWsUrl fill-in", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。