<!-- A page that is used to test that a dynamic form fill feature works properly.
Two nameless forms whose fields have identical names, and the name field goes
invalid when the country is changed.-->
<body>
<form>
Name: <input type="text" name="firstname" id="firstname_1" autocomplete="given-name"><br>
<input type="text" name="firstname" id="firstname_2" autocomplete="given-name" style="display: none"><br>
Address: <input type="text" name="address1" id="address1_3"><br>
Country: <select name="country" id="country_4" onchange="CountryChanged()">
<option value="CA">Canada</option>
<option value="US">United States</option>
</select>
<input type="reset" value="Reset">
<input type="submit" value="Submit" id="profile_submit">
</form>
<form>
Name: <input type="text" name="firstname" id="firstname_5" autocomplete="given-name"><br>
<input type="text" name="firstname" id="firstname_6" autocomplete="given-name" style="display: none"><br>
Address: <input type="text" name="address1" id="address1_7"><br>
Country: <select name="country" id="country_8" onchange="CountryChanged()">
<option value="CA">Canada</option>
<option value="US">United States</option>
</select>
<input type="reset" value="Reset">
<input type="submit" value="Submit" id="profile_submit">
</form>
</body>
<script>
function CountryChanged() {
// Reset the value of the address field.
var address1 = document.getElementById('address1_7');
address1.value = '';
window['refill'] = true;
console.log('An event happened that should trigger a refill.');
// Change the element that triggered the autofill. Remove it, and make another
// field visible. This is to test if the autofill can handle the case where
// the clicked on element is no longer valid.
var first_name_input = document.getElementById("firstname_5");
first_name_input.parentNode.removeChild(first_name_input);
var name_later = document.getElementById("firstname_6");
name_later.removeAttribute('style');
}
</script>