Files
reverse-engineering-anything/src/browser/CdpOriginScopeError.ts
T
morluto 09c2a2d241 fix(browser): preserve main-frame identity and scope refusal context
Read screenshot identity from the selected frame-tree root instead of a
filtered inventory that could substitute a child. Reuse the frame record
parser for initial and event identities, rejecting malformed roots before
capture while preserving known origin refusals.

Share explicit origin-scope diagnostics across CDP workflows without
changing policy or conflating startup uncertainty, document replacement,
worker protection, and Inspector restrictions. Document the recovery and
make screenshot navigation fixture ordering explicit.

Validation: 577 focused checks passed across 13 files; one platform-specific
invalid-byte-filename case skipped. Build, typecheck, lint, formatting,
generated documentation checks, README conformance, and discovery passed.
No full suite or live browser/provider execution.
2026-10-24 08:48:19 +08:00

17 lines
783 B
TypeScript

import { BrowserObservationError } from "../domain/browserObservationError.js";
import type { BrowserObservationOperation } from "../domain/browserObservationErrors.js";
/** Use only after a CDP document is known to be outside its HTTP(S) scope. */
export const cdpOriginScopeRefusal = (
operation: BrowserObservationOperation,
options?: { readonly cause?: unknown; readonly detail?: string },
): BrowserObservationError =>
new BrowserObservationError(operation, "target_not_allowed", {
...options,
detail:
options?.detail ??
"The current document is outside the permitted HTTP(S) origin scope.",
remediationAction:
"Select a document within allowed_origins, or explicitly adjust allowed_origins if that document is intended, then retry.",
});