blob: 18e57e368b9d81155459b701f74918eae9f6593d [file] [log] [blame]
<html>
<head>
<script>
var should_delete_testform = true;
var add_parameters_to_target_url = false;
function handleSubmitFormEvent(e) {
e.preventDefault();
if (should_delete_testform && e.currentTarget) {
var form_element = e.currentTarget;
form_element.parentNode.removeChild(form_element);
}
var target_url = "password_push_state.html";
if (add_parameters_to_target_url)
target_url += "?ref=1#a";
history.pushState({}, "", target_url);
}
window.onload = function() {
document.getElementById("testform")
.addEventListener("submit", handleSubmitFormEvent);
document.getElementById("chg_testform")
.addEventListener("submit", handleSubmitFormEvent);
document.getElementById("empty_action_login_form")
.addEventListener("submit", handleSubmitFormEvent);
document.getElementById("params_action_login_form")
.addEventListener("submit", handleSubmitFormEvent);
}
</script>
</head>
<body>
<form action="password_push_state1.html" id="testform">
<input type="text" id="username_field" name="username_field">
<input type="password" id="password_field" name="password_field">
<input type="submit" id="submit_button" name="submit_button">
</form>
<!-- Change password form with username. -->
<form action="password_push_state2.html" id="chg_testform">
<input type="text" id="chg_username_field" name="chg_not_username_field">
<input type="password" id="chg_password_field" name="chg_password_field">
<input type="password" id="chg_new_password_1" name="chg_new_password_1">
<input type="password" id="chg_new_password_2" name="chg_new_password_2">
<input type="submit" id="chg_submit_button" name="chg_submit_button">
</form>
<!-- Two forms with empty actions. The password manager should distinguish the
login form with empty action from other forms. -->
<form action="" id="empty_action_login_form">
<input type="text" id="ea_username_field" name="username_field">
<input type="password" id="ea_password_field" name="password_field">
<input type="submit" id="ea_submit_button" name="submit_button">
</form>
<form action="" id="empty_action_another_form">
<input type="text" id="ea_username_field2" name="username_field">
<input type="password" id="ea_password_field2" name="password_field">
<input type="submit" id="ea_submit_button2" name="submit_button">
</form>
<!-- Forms for testing that origin/action parameters and references are ignored
in form comparison, i.e. we use canonical origins and actions.
Here we also test that if an action coincides with frame url, all form data
should be used to compare forms. -->
<form action="password_push_state.html?ref=2#b" id="params_action_login_form">
<input type="text" id="pa_username_field" name="username_field">
<input type="password" id="pa_password_field" name="password_field">
<input type="submit" id="pa_submit_button" name="submit_button">
</form>
<form action="password_push_state.html?ref=1#a" id="params_action_another_form">
<input type="text" id="pa_username_field2" name="username_field">
<input type="password" id="pa_password_field2" name="password_field">
<input type="submit" id="pa_submit_button2" name="submit_button">
</form>
</body>
</html>
<html>