char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Somtests: drop those that drive a real Firefox6483d2d

main
1.0 KiB33 linesraw
1import { assertEquals, assertRejects } from "@std/assert";
2import { testExtension } from "@berry/api/testing.ts";
3import browser from "./mod.ts";
4import type { BrowserViewData, Snapshot } from "./types.ts";
5
6Deno.test("historical snapshots can be read without reviving a browser", async () => {
7  const snapshot: Snapshot = {
8    tab: "t1",
9    url: "https://example.com/",
10    title: "Earlier page",
11    text: "Historical",
12    elements: [],
13    truncated: false,
14    frames: [],
15    diagnostics: [],
16  };
17  const ext = testExtension(browser, {
18    events: [{ type: "observed", version: 1, action: "open", snapshot, at: 100 }],
19  });
20  try {
21    const data = await ext.request("view", {}) as BrowserViewData;
22    assertEquals(data.active, false);
23    assertEquals(data.tabs, [snapshot]);
24    assertEquals((await ext.call("browser", { action: "tabs" }) as { tabs: unknown[] }).tabs, []);
25    await assertRejects(
26      () => ext.call("browser", { action: "snapshot", tab: "t1" }),
27      Error,
28      "No live tab",
29    );
30  } finally {
31    await ext.dispose();
32  }
33});