Files
reverse-engineering-anything/tests/acceptance/webSourceLocationCli.test.ts
T
ysopwnable f430c416c7 feat(browser): trace captured website source-map locations (#897)
* refactor(browser): share captured-script acquisition boundaries

Reuse stable capture/source acquisition and identity validation for module
and source-map analysis. Preserve host I/O, malformed input, unavailable
source and digest mismatch diagnostics.

Refs #851

Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)

* feat(browser): trace captured website source-map locations

Refs #851. Preserve selected capture/map byte identity, duplicate mappings and embedded source evidence through the pinned upstream codec.

Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)

* test(browser): verify source-map artifacts and synchronize generated contracts

Cover byte-preserving map reads and actionable filesystem constraints. Refresh generated public schemas and metadata on current main.

Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)

* fix(browser): preserve inert source-map URL context

The selected URL is local codec context and grants no transport authority. Preserve its reported text and verify normal/userinfo contexts through real public interfaces, alongside independent manifest byte identity.

Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
2026-10-07 16:21:18 +08:00

68 lines
2.1 KiB
TypeScript

import { expect } from "vitest";
import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { webSourceLocationFixture } from "../fixtures/webSourceLocation.js";
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
import { cliTest } from "../support/cli/cliFixture.js";
cliTest(
"accepts numeric UTF-16 coordinates and runs the actual owned source-map codec without a browser",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-source-map-cli-");
const fixture = webSourceLocationFixture();
await mkdir(join(root, "files", "modules"), { recursive: true });
await writeFile(join(root, "files", "modules", "main.js"), fixture.source);
const manifest = join(root, "manifest.json");
const map = join(root, "app.js.map");
await writeFile(manifest, JSON.stringify(fixture.manifest));
await writeFile(map, fixture.sourceMap.text);
const response = await cli.run({
arguments: [
"trace-web-source-location",
manifest,
"0",
map,
fixture.sourceMap.url,
"1",
"0",
"--json",
],
environment: {
REA_LOG_LEVEL: "silent",
REA_BROWSER_EXECUTABLE: "relative-unconfigured-browser",
},
timeoutMs: 15000,
});
expect(response.exitCode).toBe(0);
expect(response.json).toMatchObject({
normalized_result: {
source: { script_index: 0 },
source_map: { association: "caller-selected" },
generated_offset: 0,
execution: "unknown",
matches: [{ content: { text: "original" } }],
runtime: { id: "node-v8" },
},
});
const invalid = await cli.run({
arguments: [
"trace-web-source-location",
manifest,
"0",
map,
fixture.sourceMap.url,
"2",
"0",
"--json",
],
environment: { REA_LOG_LEVEL: "silent" },
timeoutMs: 15000,
});
expect(invalid.exitCode).toBe(1);
expect(invalid.json).toMatchObject({
code: "invalid_request",
details: { issues: [{ path: ["generated_position"] }] },
});
},
);