Skip to content

Commit

Permalink
Add test for verifyBrowserAutofillInput
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterKale committed Oct 6, 2024
1 parent 3b61ec1 commit 31d66a2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/browser/src/methods/startAuthentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,32 @@ test('should throw error if no acceptable <input> is found', async () => {
rejected.toThrow(/no <input>/i);
});

test('should not throw error when autofill input verification flag is false', async () => {
// No suitable <input> is present in the "light DOM", which would normally raise...
document.body.innerHTML = '<swan-autofill></swan-autofill>';

// ...But a suitable <input> IS inside of a web component's "shadow DOM" and we know it
const swanAutofill = document.querySelector('swan-autofill');
const shadowRoot = swanAutofill!.attachShadow({ mode: 'open' });
shadowRoot.innerHTML = `
<label for="username">Username</label>
<input
type="text"
name="username"
autocomplete="username webauthn"
autofocus
/>
`;

await expect(
startAuthentication({
optionsJSON: goodOpts1,
useBrowserAutofill: true,
verifyBrowserAutofillInput: false,
}),
).resolves;
});

test('should throw error if "webauthn" is not final autocomplete token', async () => {
/**
* According to WHATWG "webauthn" must be the final token in the autocomplete attribute when
Expand Down

0 comments on commit 31d66a2

Please sign in to comment.