Let the login test page drive itself
Verifying the password flow needs a login to actually happen, and driving one by hand means a human at the keyboard. ?auto=1 fills the fields and logs in on load, with user, pass, succeed, rmdom and push as query parameters so each trigger and the failure case can be exercised without touching a real account. Values are written with the native setter followed by a real 'input' event, which is what a keystroke produces and what inject.js listens for. Worth being clear about the limit: this proves the trigger fires for a field that reached its value the way a browser reports it, not that physical typing works.
This commit is contained in:
@@ -93,5 +93,46 @@
|
||||
// Default is already prevented by onsubmit="return false" on the form.
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Automation hook, so the page can drive itself when there is no human at
|
||||
// the keyboard: ?auto=1&user=…&pass=…&succeed=1&rmdom=1&push=0
|
||||
//
|
||||
// Values are written with the native setter and followed by a real 'input'
|
||||
// event, which is what a keystroke produces and what inject.js listens for.
|
||||
// It does NOT prove that physical typing works — only that the trigger
|
||||
// fires for a field that reached its value the way a browser reports it.
|
||||
(function () {
|
||||
var q = new URLSearchParams(location.search);
|
||||
if (q.get('auto') !== '1') return;
|
||||
|
||||
function setNative(el, value) {
|
||||
var proto = Object.getPrototypeOf(el);
|
||||
var desc = Object.getOwnPropertyDescriptor(proto, 'value');
|
||||
desc.set.call(el, value);
|
||||
el.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
el.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
|
||||
function check(id, on) {
|
||||
var el = document.getElementById(id);
|
||||
if (el && el.checked !== on) el.click();
|
||||
}
|
||||
|
||||
window.addEventListener('load', function () {
|
||||
check('succeed', q.get('succeed') !== '0');
|
||||
check('removeDom', q.get('rmdom') !== '0');
|
||||
check('pushUrl', q.get('push') === '1');
|
||||
|
||||
var email = document.getElementById('email');
|
||||
var pw = document.getElementById('password');
|
||||
if (email) { email.focus(); setNative(email, q.get('user') || 'testuser@example.com'); }
|
||||
if (pw) { pw.focus(); setNative(pw, q.get('pass') || 'TestPassword123'); }
|
||||
|
||||
// Let the fields settle, then log in the way Google does: no submit event.
|
||||
setTimeout(doXhr, 800);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user