ECMA-426 DecodeSourceMapSources reads a content slot only while its index is within sourcesContent, so a shorter array leaves trailing sources without content and a longer array adds no sources. Local application analysis and browser collection rejected any length mismatch and dropped every original from the map. The content helper now checks only entry types. Browser collection drops its separate check because the leaf schema already validates every supplied entry, and the raw records are still budgeted before parsing. Fixes #2821
20 lines
828 B
TypeScript
20 lines
828 B
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { hasValidSourceMapContents } from "./sourceMapContents.js";
|
|
|
|
it("accepts absent map-level source contents and nullable string slots", () => {
|
|
expect(hasValidSourceMapContents(undefined)).toBe(true);
|
|
expect(hasValidSourceMapContents(null)).toBe(true);
|
|
expect(hasValidSourceMapContents([null, "retained source"])).toBe(true);
|
|
expect(hasValidSourceMapContents([null, 42])).toBe(false);
|
|
expect(hasValidSourceMapContents("retained source")).toBe(false);
|
|
});
|
|
|
|
it("leaves sourcesContent length to source decoding (ECMA-426 DecodeSourceMapSources)", () => {
|
|
expect(hasValidSourceMapContents([])).toBe(true);
|
|
expect(hasValidSourceMapContents(["retained source"])).toBe(true);
|
|
expect(
|
|
hasValidSourceMapContents(["a", null, "unused trailing content"]),
|
|
).toBe(true);
|
|
});
|