Commit 0ab8faf7 authored by Parastoo Geranmayeh's avatar Parastoo Geranmayeh Committed by Commit Bot

[AF] more autofill interactive tests

for dynamic forms.

Change-Id: I9a93913f9b0b6548d05c148a7b8de2b5f671abf4
Reviewed-on: https://chromium-review.googlesource.com/c/1340830Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Commit-Queue: Parastoo Geranmayeh <parastoog@google.com>
Cr-Commit-Position: refs/heads/master@{#609324}
parent 6ea6f251
......@@ -2960,6 +2960,70 @@ IN_PROC_BROWSER_TEST_P(AutofillDynamicFormInteractiveTest,
ExpectFieldValue("phone", "15125551234");
}
// Test that we can autofill forms that dynamically change the element that
// has been clicked on, even though there are multiple forms with identical
// names.
IN_PROC_BROWSER_TEST_P(
AutofillDynamicFormInteractiveTest,
DynamicFormFill_FirstElementDisappearsMultipleBadNameForms) {
CreateTestProfile();
GURL url = embedded_test_server()->GetURL(
"a.com",
"/autofill/dynamic_form_element_invalid_multiple_badname_forms.html");
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url));
TriggerFormFill("firstname_5");
// Wait for the re-fill to happen.
bool has_refilled = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
GetWebContents(), "hasRefilled()", &has_refilled));
ASSERT_TRUE(has_refilled);
// Make sure the second form was filled correctly, and the first form was left
// unfilled.
ExpectFieldValue("firstname_1", "");
ExpectFieldValue("firstname_2", "");
ExpectFieldValue("address1_3", "");
ExpectFieldValue("country_4", "CA"); // default
ExpectFieldValue("firstname_6", "Milton");
ExpectFieldValue("address1_7", "4120 Freidrich Lane");
ExpectFieldValue("country_8", "US");
}
// Test that we can autofill forms that dynamically change the element that
// has been clicked on, even though there are multiple forms with identical
// names.
IN_PROC_BROWSER_TEST_P(AutofillDynamicFormInteractiveTest,
DynamicFormFill_FirstElementDisappearsBadnameUnowned) {
CreateTestProfile();
GURL url = embedded_test_server()->GetURL(
"a.com", "/autofill/dynamic_form_element_invalid_unowned_badnames.html");
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url));
TriggerFormFill("firstname_5");
// Wait for the re-fill to happen.
bool has_refilled = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
GetWebContents(), "hasRefilled()", &has_refilled));
ASSERT_TRUE(has_refilled);
// Make sure the second form was filled correctly, and the first form was left
// unfilled.
ExpectFieldValue("firstname_1", "");
ExpectFieldValue("firstname_2", "");
ExpectFieldValue("address1_3", "");
ExpectFieldValue("country_4", "CA"); // default
ExpectFieldValue("firstname_6", "Milton");
ExpectFieldValue("address1_7", "4120 Freidrich Lane");
ExpectFieldValue("country_8", "US");
}
// Test that we can autofill forms that dynamically change the element that
// has been clicked on, even though the elements are unowned.
IN_PROC_BROWSER_TEST_P(AutofillDynamicFormInteractiveTest,
......
<!-- A page that is used to test that a dynamic form fill feature works properly. -->
<body>
<form name="one" action="https://example.com/" method="post">
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>
<br><br>
<form name="one" action="https://example.com/" method="post">
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>
var notify_on_address_input_change = false;
var address_input_changed = false;
function CountryChanged() {
// Reset the value of the address field.
var address1 = document.getElementById('address1_7');
address1.value = '';
address1.onchange = function() {
if (notify_on_address_input_change)
window.domAutomationController.send(address1.value != '');
else
address_input_changed = true;
}
// 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.setAttribute("style", "display: none");
var name_later = document.getElementById("firstname_6");
name_later.removeAttribute('style');
}
function hasRefilled() {
var address1 = document.getElementById('address1_7');
if (address1 && address_input_changed) {
window.domAutomationController.send(address1.value != '');
} else {
notify_on_address_input_change = true;
}
}
</script>
<!-- A page that is used to test that a dynamic form fill feature works properly. -->
<body>
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">
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">
</body>
<script>
var notify_on_address_input_change = false;
var address_input_changed = false;
function CountryChanged() {
// Reset the value of the address field.
var address1 = document.getElementById('address1_7');
address1.value = '';
address1.onchange = function() {
if (notify_on_address_input_change)
window.domAutomationController.send(address1.value != '');
else
address_input_changed = true;
}
// 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');
}
function hasRefilled() {
var address1 = document.getElementById('address1_7');
if (address1 && address_input_changed) {
window.domAutomationController.send(address1.value != '');
} else {
notify_on_address_input_change = true;
}
}
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment