Documentation

Chrome Passkey "Page Does Not Have Focus" Error After Bitwarden Fallback

Fix WebAuthn NotAllowedError "page does not have focus" when a password manager hands a passkey request back to Chrome, by retrying with the native API.

A
Adam Birds
Published 3 December 20263 min read0 views

Adding or using a passkey fails in Chrome when a password manager extension (such as Bitwarden) shows its passkey popup first and the user picks the option to use their device instead.

NotAllowedError: The operation is not allowed at this time because the page does not have focus.

Cause

Password manager extensions replace navigator.credentials.create and navigator.credentials.get in the page so they can offer their own passkeys. When the user chooses “Use your device or hardware key” (Bitwarden), the extension calls the browser’s original function again as soon as the page reports document.hasFocus().

Chrome’s WebAuthn “focus” check is really a visibility check: the request is refused unless the tab’s contents are VISIBLE. Straight after the extension’s popup window closes, Chrome can still treat the tab as covered, so the handed-back request fails with the focus error. Whether it happens depends on timing, so one site can hit it while another with similar code does not.

Fix

Catch the focus error in the page’s own passkey code, wait until the tab is visible and focused, then retry. Retry with the browser’s native function rather than navigator.credentials.create, because the extension only overrides the methods on the navigator.credentials object: the originals are still on CredentialsContainer.prototype. The retry therefore goes straight to the browser’s prompt (which the user already chose) instead of reopening the extension’s popup.

Add a helper that detects the error and waits for the page:

function isFocusError(error: unknown): boolean {
    return error instanceof Error && error.name === "NotAllowedError" && /focus/i.test(error.message);
}

function pageReady(limitMs = 10_000): Promise<void> {
    return new Promise((resolve) => {
        const started = Date.now();
        const check = () => {
            if ((document.visibilityState === "visible" && document.hasFocus()) || Date.now() - started > limitMs) {
                setTimeout(resolve, 300); // a moment more for the browser to see the window uncovered
                return;
            }
            setTimeout(check, 100);
        };
        check();
    });
}

const nativeCredentials = {
    create: (options: CredentialCreationOptions) =>
        CredentialsContainer.prototype.create.call(navigator.credentials, options),
    get: (options: CredentialRequestOptions) =>
        CredentialsContainer.prototype.get.call(navigator.credentials, options),
};

Then wrap the call: the first attempt goes through navigator.credentials (so the password manager can still offer its own passkeys), and retries use the native functions:

async function createPasskey(publicKey: PublicKeyCredentialCreationOptions): Promise<Credential | null> {
    const controller = new AbortController();
    for (let attempt = 0; ; attempt += 1) {
        const request = { publicKey, signal: controller.signal };
        try {
            return attempt === 0
                ? await navigator.credentials.create(request)
                : await nativeCredentials.create(request);
        } catch (error) {
            if (!isFocusError(error) || attempt >= 3) {
                throw error;
            }
            await pageReady();
        }
    }
}

Do the same for navigator.credentials.get when signing in with a passkey.

If a library such as @simplewebauthn/browser makes the browser call for you, call navigator.credentials directly for this step instead (encoding the response to the JSON the server library expects), so the retry can be added.

Verify

Click the button that adds a passkey, and choose the “use your device” option in the password manager’s popup. The browser’s own passkey prompt (for example iCloud Keychain on macOS) should now appear. Logging inside the retry branch confirms it was needed:

The page wasn't focused yet; retrying with the browser's own prompt.

Notes

  • Nothing a site sends (such as WebAuthn hints or authenticatorAttachment) stops an extension intercepting the request. The only global way to get the browser’s prompt first is to turn off the extension’s passkey feature, e.g. Bitwarden → Settings → Notifications → “Ask to save and use passkeys”, or to add the site to its excluded domains.
  • In Bitwarden, the Close button inside the popup cancels the request (plain NotAllowedError, no fallback). Only “Use your device or hardware key” or closing the popup window hands it back to the browser.
  • Tested with Chrome on macOS and the Bitwarden browser extension.
  • This is not specific to Bitwarden. Any password manager extension that shows its passkey prompt in its own window and then hands the request back to the browser can trigger the same error, because the browser may still see the tab as covered when the request arrives. The retry above works the same way for them.
Last updated: 3 December 2026v2