-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a bunch of test cases for autofill autoprompt (#89)
- Loading branch information
1 parent
be15482
commit 939b9a0
Showing
7 changed files
with
364 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Autofill autoprompt for signin forms</title> | ||
<link rel="stylesheet" href="../style.css" /> | ||
</head> | ||
|
||
<body> | ||
<p><a href="../index.html">[Home]</a></p> | ||
<nav> | ||
<ul class="nav"> | ||
<li><a href="./case-1.html">Case 1</a></li> | ||
<li><a href="./case-2.html">Case 2</a></li> | ||
<li><a href="./case-3.html">Case 3</a></li> | ||
<li><a href="./case-4.html">Case 4</a></li> | ||
<li><a href="./case-5.html">Case 5</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<p id="demo"></p> | ||
|
||
<div class=""> | ||
<p>Sign in form present on pageload (<b>should prompt automatically</b>).</p> | ||
|
||
<div class="dialog"> | ||
<form id="click-form" novalidate> | ||
<h3>Sign in form</h3> | ||
<fieldset> | ||
<label for="email">Email</label> | ||
<input id="email" type="email"> | ||
<label for="password">Password</label> | ||
<input id="password" type="password"> | ||
<button type="submit">Sign in</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
<script> | ||
const clickForm = document.getElementById('click-form'); | ||
const button = clickForm?.querySelector('button'); | ||
const handler = (e) => { | ||
e.preventDefault(); | ||
e.stopImmediatePropagation(); | ||
clickForm.outerHTML = '<h1>Submitted!</h1>'; | ||
} | ||
button?.addEventListener('click', handler, true); | ||
</script> | ||
</div> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Autofill autoprompt for signin forms</title> | ||
<link rel="stylesheet" href="../style.css" /> | ||
</head> | ||
|
||
<body> | ||
<p><a href="../index.html">[Home]</a></p> | ||
<nav> | ||
<ul class="nav"> | ||
<li><a href="./case-1.html">Case 1</a></li> | ||
<li><a href="./case-2.html">Case 2</a></li> | ||
<li><a href="./case-3.html">Case 3</a></li> | ||
<li><a href="./case-4.html">Case 4</a></li> | ||
<li><a href="./case-5.html">Case 5</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<p id="demo"></p> | ||
|
||
<div class=""> | ||
<p>Form created in modal after click (<b>should not prompt automatically</b>).</p> | ||
|
||
<div class="dialog"> | ||
<p><button type="button">Click here to login</button></p> | ||
</div> | ||
<script> | ||
const initialButton = document.querySelector('button'); | ||
initialButton.addEventListener('click', () => { | ||
const formEl = `<form id="click-form" novalidate action="./case-3.html"> | ||
<h3>Sign in form dia</h3> | ||
<fieldset> | ||
<label for="email">Email</label> | ||
<input id="email" type="email"> | ||
<label for="password">Password</label> | ||
<input id="password" type="password"> | ||
<button type="submit">Sign in</button> | ||
</fieldset> | ||
</form>` | ||
initialButton.outerHTML = formEl; | ||
const clickForm = document.getElementById('click-form'); | ||
const button = clickForm?.querySelector('button'); | ||
const handler = (e) => { | ||
e.preventDefault(); | ||
e.stopImmediatePropagation(); | ||
window.location.href = './case-3.html' | ||
} | ||
button?.addEventListener('click', handler, true); | ||
}) | ||
</script> | ||
</div> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Autofill autoprompt for signin forms</title> | ||
<link rel="stylesheet" href="../style.css" /> | ||
</head> | ||
|
||
<body> | ||
<p><a href="../index.html">[Home]</a></p> | ||
<nav> | ||
<ul class="nav"> | ||
<li><a href="./case-1.html">Case 1</a></li> | ||
<li><a href="./case-2.html">Case 2</a></li> | ||
<li><a href="./case-3.html">Case 3</a></li> | ||
<li><a href="./case-4.html">Case 4</a></li> | ||
<li><a href="./case-5.html">Case 5</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<p id="demo"></p> | ||
|
||
<div class="dialog"> | ||
<p>Login form with a multistep flow. It should prompt automatically on first load, then the second field triggers the prompt on tap/click.</p> | ||
<form action="/login" id="login"> | ||
<h2>Log in</h2> | ||
<fieldset> | ||
<label for="email">Email</label> | ||
<input id="email" type="email" required> | ||
<button type="button">Continue</button> | ||
</fieldset> | ||
<fieldset class="password-container" hidden> | ||
<label for="password">Password</label> | ||
<input id="password" type="password" required> | ||
<button type="submit">Log in</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
|
||
<script type="module"> | ||
const continueButton = document.querySelector('button[type=button]'); | ||
const submitButton = document.querySelector('button[type=submit]'); | ||
const passwordContainer = document.querySelector('.password-container'); | ||
|
||
continueButton.addEventListener('click', () => { | ||
if (form.email.validity.valid) { | ||
passwordContainer.removeAttribute('hidden'); | ||
continueButton.setAttribute('hidden', ''); | ||
} | ||
}); | ||
|
||
const form = document.forms.login; | ||
form.addEventListener('submit', (e) => { | ||
e.preventDefault(); | ||
if (form.checkValidity()) { | ||
setTimeout(() => { | ||
form.outerHTML = '<h1>Submitted!</h1>'; | ||
}, 100); | ||
} | ||
}); | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Autofill autoprompt for signin forms</title> | ||
<link rel="stylesheet" href="../style.css" /> | ||
</head> | ||
|
||
<body> | ||
<p><a href="../index.html">[Home]</a></p> | ||
<nav> | ||
<ul class="nav"> | ||
<li><a href="./case-1.html">Case 1</a></li> | ||
<li><a href="./case-2.html">Case 2</a></li> | ||
<li><a href="./case-3.html">Case 3</a></li> | ||
<li><a href="./case-4.html">Case 4</a></li> | ||
<li><a href="./case-5.html">Case 5</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<p id="demo">The cookie dialog will prevent autoprompt. You should not see an autoprompt on this page. Once dismissing the cookie dialog, you can use the form as usual.</p> | ||
|
||
<div class="dialog"> | ||
<form action="/login" id="login"> | ||
<h2>Log in</h2> | ||
<fieldset> | ||
<label for="email">Email</label> | ||
<input id="email" type="email"> | ||
<label for="password">Password</label> | ||
<input id="password" type="password"> | ||
<button type="submit">Log in</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
|
||
<div class="dialog dialog--cookie-dialog" hidden> | ||
<h2>Annoying cookie prompt</h2> | ||
<h3>This cookie prompt will appear with a slight delay after page load. It will cover our beloved login form thus preventing autoprompt.</h3> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p> | ||
<p><button type="button" class="close-cookie-dialog">Accept all cookies, you have no choice</button></p> | ||
</div> | ||
<script type="module"> | ||
const cookieDialog = document.querySelector('.dialog--cookie-dialog'); | ||
const closeCookieDialogBtn = document.querySelector('.close-cookie-dialog'); | ||
closeCookieDialogBtn.addEventListener('click', () => cookieDialog.setAttribute('hidden', '')); | ||
|
||
// show the cookie prompt after page load | ||
setTimeout(() => cookieDialog.removeAttribute('hidden'), 100); | ||
|
||
const form = document.forms.login; | ||
form.addEventListener('submit', (e) => { | ||
e.preventDefault(); | ||
if (form.checkValidity()) { | ||
setTimeout(() => { | ||
form.outerHTML = '<h1>Submitted!</h1>'; | ||
}, 100); | ||
} | ||
}); | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Autofill autoprompt for signin forms</title> | ||
<link rel="stylesheet" href="../style.css" /> | ||
</head> | ||
|
||
<body> | ||
<p><a href="../index.html">[Home]</a></p> | ||
<nav> | ||
<ul class="nav"> | ||
<li><a href="./case-1.html">Case 1</a></li> | ||
<li><a href="./case-2.html">Case 2</a></li> | ||
<li><a href="./case-3.html">Case 3</a></li> | ||
<li><a href="./case-4.html">Case 4</a></li> | ||
<li><a href="./case-5.html">Case 5</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<p id="demo"></p> | ||
<p>Sign in form present below the fold on mobile, but in a sidebar on larger screens (<strong>should prompt automatically only when visible, i.e. on desktop</strong>).</p> | ||
|
||
<div class="container"> | ||
<div class="main"> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p> | ||
|
||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p> | ||
</div> | ||
|
||
<div class="sidebar"> | ||
<form id="click-form" novalidate> | ||
<h3>Sign in form</h3> | ||
<fieldset> | ||
<label for="email">Email</label> | ||
<input id="email" type="email"> | ||
<label for="password">Password</label> | ||
<input id="password" type="password"> | ||
<button type="submit">Sign in</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
|
||
<script> | ||
const clickForm = document.getElementById('click-form'); | ||
const button = clickForm?.querySelector('button'); | ||
const handler = (e) => { | ||
e.preventDefault(); | ||
e.stopImmediatePropagation(); | ||
clickForm.outerHTML = '<h1>Submitted!</h1>'; | ||
} | ||
button?.addEventListener('click', handler, true); | ||
</script> | ||
</div> | ||
|
||
</body> | ||
|
||
</html> |
Oops, something went wrong.