Files
rea/src/domain/webRuntime.test.ts
T
Kaoru0822andClaude Opus 5.5 99d31ee24a fix(browser): treat module-import initiator positions as script positions
An empty script_id also marks a script-type initiator, such as a module
import, whose url is the importing script file. Its position is a real
script position without a session-script association. The previous
wording called every empty-ID callsite parser markup with "no script
position" and excluded it from the external-script conversion. Describe
the empty ID as a missing session-script association, which only rules
out joining captured source or resource_start, and keep the
external-script conversion for script-file positions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 16:44:25 +00:00

38 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { z } from "zod";
import {
webRuntimeLocationSchema,
webRuntimeSourceSchema,
} from "./webRuntime.js";
const properties = (schema: z.ZodType) =>
z
.object({ properties: z.record(z.string(), z.unknown()) })
.parse(z.toJSONSchema(schema, { io: "output" })).properties;
describe("web runtime coordinate contract", () => {
it("advertises zero-based resource-relative CDP lines and UTF-16 columns", () => {
const location = properties(webRuntimeLocationSchema);
expect(location.line_number).toMatchObject({
description: expect.stringContaining(
"Zero-based line in the resource named by url",
),
});
expect(location.script_id).toMatchObject({
description: expect.stringContaining("no session-script association"),
});
expect(location.column_number).toMatchObject({
description: expect.stringContaining("Zero-based UTF-16 column"),
});
const start = properties(
webRuntimeSourceSchema.shape.resource_start.unwrap(),
);
expect(start.line_number).toMatchObject({
description: expect.stringContaining(
"Zero-based line where the script text starts",
),
});
});
});