Wirebrowser Automation Script API Referece
    Preparing search index...

    Interface HookHandlers

    Handlers run against the current call frame and have direct access to the local JavaScript scope, including locals, arguments, and closures.

    Inline JavaScript executes immediately and follows standard JS semantics.

    The ctx methods, instead, do not execute immediately: they schedule actions that are applied after the handler returns.

    Key differences:

    • Use inline JavaScript to read or modify writable bindings immediately.
    • Use ctx.setVariable(...) to modify bindings that cannot be changed via normal JS semantics (e.g. const).
    • Use ctx.eval(...) to evaluate expressions in the frame and access this.

    Scope resolution for ctx.setVariable follows the CDP scope chain and only supports local, closure, and catch scopes.

    interface HookHandlers {
        at?: { location: string; onHit?(ctx: HitHookContext): void }[];
        onEnter?(ctx: EnterHookContext): void;
        onLeave?(ctx: LeaveHookContext): void;
        onReturnFollowed?(
            ctx: ReturnFollowedHookContext,
            previousStep: HookPreviousStep,
        ): void;
        onStep?(ctx: StepFollowedHookContext, previousStep: HookPreviousStep): void;
    }
    Index

    Properties

    at?: { location: string; onHit?(ctx: HitHookContext): void }[]

    Location-level hooks (precise instrumentation points)

    Allows attaching handlers to specific script locations.

    Type Declaration

    • location: string

      Location in the form "line:column" Example: "164894:2"

    • onHit?: function
      • Called when the breakpoint at this location is hit.

        Runs in the current call frame (local scope access; use ctx.eval for this). See "Execution model" for full details.

        Must be declared as an object method, for example: onHit(ctx) { ... } Do not use arrow functions here.

        Parameters

        Returns void

    Methods

    • Called at function entry.

      Runs in the current call frame (local scope access; use ctx.eval for this). See "Execution model" for full details.

      Must be declared as an object method, for example: onEnter(ctx) { ... } Do not use arrow functions here.

      Parameters

      Returns void

    • Called at function leave / return breakpoint.

      Runs in the current call frame (local scope access; use ctx.eval for this). See "Execution model" for full details.

      Must be declared as an object method, for example: onLeave(ctx) { ... } Do not use arrow functions here.

      Parameters

      Returns void

    • Called when a step is executed.

      previousStep contains data captured from the leave step that requested the follow. Runs in the current call frame (local scope access; use ctx.eval for this). See "Execution model" for full details.

      Must be declared as an object method, for example: onReturnFollowed(ctx, previousStep) { ... } Do not use arrow functions here.

      Parameters

      Returns void

    • Called after followReturn() when a continuation is found.

      previousStep contains data captured from the leave step that requested the follow.

      Runs in the current call frame (local scope access; use ctx.eval for this). See "Execution model" for full details.

      Must be declared as an object method, for example: onStep(ctx, previousStep) { ... } Do not use arrow functions here.

      Parameters

      Returns void