aboutsummaryrefslogtreecommitdiff
path: root/src/cdp/window.ts
blob: f16838c236ae12b0248333a9a126c815580c7f5a (plain)
1
2
3
4
5
6
7
8
9
10
import { map, type Result } from "../util/result";
import type { CdpError } from "./errors";
import type { CdpSession } from "./session";

/** Browser.getWindowForTarget, unwrapped to the windowId. */
export const getWindowId = async (
  session: CdpSession,
  targetId: string,
): Promise<Result<number, CdpError>> =>
  map(await session.callBrowser("Browser.getWindowForTarget", { targetId }), (d) => d.windowId);