Files
emdash-patch-imageupload/e2e/fixtures/virtual-authenticator.ts
kunthawat 2d1be52177 Emdash source with visual editor image upload fix
Fixes:
1. media.ts: wrap placeholder generation in try-catch
2. toolbar.ts: check r.ok, display error message in popover
2026-05-03 10:44:54 +07:00

34 lines
911 B
TypeScript

/**
* Chrome DevTools virtual WebAuthn authenticator for passkey e2e.
* Chromium-only (CDP). See https://developer.chrome.com/docs/devtools/webauthn/
*/
import type { Page } from "@playwright/test";
export async function addVirtualWebAuthnAuthenticator(page: Page): Promise<() => Promise<void>> {
const session = await page.context().newCDPSession(page);
await session.send("WebAuthn.enable");
const { authenticatorId } = await session.send("WebAuthn.addVirtualAuthenticator", {
options: {
protocol: "ctap2",
transport: "internal",
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
automaticPresenceSimulation: true,
},
});
return async () => {
try {
await session.send("WebAuthn.removeVirtualAuthenticator", { authenticatorId });
} catch {
// session may already be closed
}
try {
await session.detach();
} catch {
// ignore
}
};
}