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>
This commit is contained in:
Kaoru0822
2026-10-08 16:44:25 +00:00
co-authored by Claude Opus 5.5
parent 3c157b4ec6
commit 99d31ee24a
3 changed files with 12 additions and 12 deletions
+1 -3
View File
@@ -20,9 +20,7 @@ describe("web runtime coordinate contract", () => {
),
});
expect(location.script_id).toMatchObject({
description: expect.stringContaining(
"empty for a position taken from a request initiator",
),
description: expect.stringContaining("no session-script association"),
});
expect(location.column_number).toMatchObject({
description: expect.stringContaining("Zero-based UTF-16 column"),
+9 -7
View File
@@ -8,15 +8,17 @@ import { jsonObjectSchema } from "./jsonValue.js";
// CDP positions are zero-based and relative to the resource named by url.
// With a script ID that is the script's enclosing resource: the script file,
// or the HTML document for an inline script. An empty script ID marks the
// position a request's initiator reported, such as parser markup, which has
// no script to convert. trace_web_source_location takes one-based,
// script-relative lines, so the advertised units keep callers from passing a
// position off by one or by the inline script's offset.
// or the HTML document for an inline script. An empty script ID marks a
// position a request initiator reported, such as parser markup or a module
// import in a script file; it still locates url, but has no session-script
// association to join captured source or resource_start.
// trace_web_source_location takes one-based, script-relative lines, so the
// advertised units keep callers from passing a position off by one or by an
// inline script's offset.
const SCRIPT_ID =
"CDP session script ID; empty for a position taken from a request initiator rather than a script call frame.";
"CDP session script ID; empty for a position a request initiator reported, which has no session-script association for joining captured source or resource_start.";
const RESOURCE_LINE =
"Zero-based line in the resource named by url, as reported by CDP. With a script_id this is the script's enclosing resource (the script file, or the HTML document for an inline script); with an empty script_id it is the request initiator's reported position, such as parser markup in a document.";
"Zero-based line in the resource named by url, as reported by CDP: the script file for an external script (including a module-import initiator), or the HTML document for an inline script or parser markup.";
const RESOURCE_COLUMN =
"Zero-based UTF-16 column on that line of the resource named by url, as reported by CDP.";
const START_LINE =