* 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)
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { webSourceOffset } from "./webSourcePosition.js";
|
|
|
|
it("uses UTF-16 columns and actual JavaScript line terminators", () => {
|
|
const text = "🎋a\r\nb\rc\nd\u2028e\u2029";
|
|
expect(webSourceOffset(text, { line: 1, column: 2 })).toBe(2);
|
|
expect(webSourceOffset(text, { line: 1, column: 3 })).toBe(3);
|
|
expect(webSourceOffset(text, { line: 1, column: 4 })).toBeUndefined();
|
|
expect(webSourceOffset(text, { line: 2, column: 0 })).toBe(5);
|
|
expect(webSourceOffset(text, { line: 6, column: 0 })).toBe(13);
|
|
expect(webSourceOffset(text, { line: 7, column: 0 })).toBeUndefined();
|
|
});
|
|
|
|
it.each([
|
|
{ line: 0, column: 0 },
|
|
{ line: 1, column: -1 },
|
|
{ line: 1.5, column: 0 },
|
|
])("rejects invalid source positions: %j", (position) => {
|
|
expect(webSourceOffset("", position)).toBeUndefined();
|
|
});
|
|
|
|
it("retains the empty source and the final empty line", () => {
|
|
expect(webSourceOffset("", { line: 1, column: 0 })).toBe(0);
|
|
expect(webSourceOffset("a\r\n", { line: 2, column: 0 })).toBe(3);
|
|
});
|