mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
This implements the following AOs: - Create a PasswordCredential from PasswordCredentialData. - Create a PasswordCredential from an HTMLFormElement. Which corresponds to these PasswordCredential ctors: - constructor(PasswordCredentialData) - constructor(HTMLFormElement)
71 lines
3.2 KiB
HTML
71 lines
3.2 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<form id="loginForm">
|
|
<input type="text" name="username" autocomplete="username" value="staplemachine@example.org" required>
|
|
<input type="password" name="password" autocomplete="current-password" value="correctstaplehorsecinema" required>
|
|
<input type="text" name="name" autocomplete="name" value="Staple Machine" required>
|
|
<input type="text" name="photo" autocomplete="photo" value="https://example.org/images/horse.png" required>
|
|
</form>
|
|
<form id="changePasswordForm">
|
|
<input type="text" name="username" autocomplete="username" value="staplemachine@example.org" required>
|
|
<input type="password" name="password" autocomplete="new-password" value="correctstaplehorsecinema" required>
|
|
<input type="password" name="password" autocomplete="current-password" value="correcthorsebatterystaple" required>
|
|
</form>
|
|
<form id="loginFormWithNick">
|
|
<input type="text" name="username" autocomplete="username" value="staplemachine@example.org" required>
|
|
<input type="password" name="password" autocomplete="current-password" value="correcthorsebatterystaple" required>
|
|
<input type="text" name="name" autocomplete="nickname" value="StapleNick" required>
|
|
<input type="text" name="photo" autocomplete="photo" value="https://example.org/images/horse.png" required>
|
|
</form>
|
|
<script>
|
|
test(() => {
|
|
const data = {
|
|
id: 'staplemachine@example.org',
|
|
password: 'correcthorsebatterystaple',
|
|
name: 'Staple Machine',
|
|
iconURL: 'https://example.org/images/horse.png',
|
|
};
|
|
let credential = new PasswordCredential(data);
|
|
println(`credential instanceof PasswordCredential: ${credential instanceof PasswordCredential}`)
|
|
println(`id: ${credential.id}`);
|
|
println(`password: ${credential.password}`);
|
|
println(`name: ${credential.name}`);
|
|
println(`iconURL: ${credential.iconURL}`);
|
|
|
|
let form = document.getElementById('loginForm');
|
|
credential = new PasswordCredential(form);
|
|
println(`credential instanceof PasswordCredential: ${credential instanceof PasswordCredential}`)
|
|
println(`id: ${credential.id}`);
|
|
println(`password: ${credential.password}`);
|
|
println(`name: ${credential.name}`);
|
|
println(`iconURL: ${credential.iconURL}`);
|
|
|
|
form = document.getElementById('changePasswordForm');
|
|
credential = new PasswordCredential(form);
|
|
println(`credential instanceof PasswordCredential: ${credential instanceof PasswordCredential}`)
|
|
println(`id: ${credential.id}`);
|
|
println(`password: ${credential.password}`);
|
|
|
|
form = document.getElementById('loginFormWithNick');
|
|
credential = new PasswordCredential(form);
|
|
println(`credential instanceof PasswordCredential: ${credential instanceof PasswordCredential}`)
|
|
println(`id: ${credential.id}`);
|
|
println(`password: ${credential.password}`);
|
|
println(`name: ${credential.name}`);
|
|
println(`iconURL: ${credential.iconURL}`);
|
|
|
|
// 'id' must not be empty
|
|
try {
|
|
new PasswordCredential({ id: '', password: '' });
|
|
} catch (e) {
|
|
println(`${e.message}`);
|
|
}
|
|
// 'password' must not be empty
|
|
try {
|
|
new PasswordCredential({ id: 'staplemachine@example.org', password: '' });
|
|
} catch (e) {
|
|
println(`${e.message}`);
|
|
}
|
|
});
|
|
</script>
|