aboutsummaryrefslogtreecommitdiff
path: root/src/cdp/window.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/cdp/window.ts')
-rw-r--r--src/cdp/window.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cdp/window.ts b/src/cdp/window.ts
new file mode 100644
index 0000000..f16838c
--- /dev/null
+++ b/src/cdp/window.ts
@@ -0,0 +1,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);