Bug 1671137 - [2.0] Add Autofill crash test for the case of id='value'. r=geckoview-reviewers,agi

Depends on D93693

Differential Revision: https://phabricator.services.mozilla.com/D93856
This commit is contained in:
Eugen Sawin 2020-10-16 21:06:13 +00:00
Родитель 3eedce4842
Коммит b96c1aa35e
3 изменённых файлов: 63 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,12 @@
<html>
<head>
<meta charset="utf-8">
<title>Forms ID Value</title>
<meta name="viewport" content="minimum-scale=1,width=device-width">
</head>
<body>
<form id="form1">
<input type="password" id="value">
</form>
</body>
</html>

Просмотреть файл

@ -94,6 +94,56 @@ class AutofillDelegateTest : BaseSessionTest() {
})
}
@Test fun autofillCommitIdValue() {
sessionRule.setPrefsUntilTestEnd(mapOf(
"signon.rememberSignons" to true,
"signon.userInputRequiredToCapture.enabled" to false))
mainSession.loadTestPath(FORMS_ID_VALUE_HTML_PATH)
// Wait for the auto-fill nodes to populate.
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
@AssertCalled(count = 1)
override fun onAutofill(session: GeckoSession,
notification: Int,
node: Autofill.Node?) {
assertThat("Should be starting auto-fill",
notification,
equalTo(forEachCall(
Autofill.Notify.SESSION_STARTED,
Autofill.Notify.NODE_ADDED)))
}
})
// Assign node values.
mainSession.evaluateJS("document.querySelector('#value').value = 'pass1x'")
// Submit the session.
mainSession.evaluateJS("document.querySelector('#form1').submit()")
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
@AssertCalled(count = 2)
override fun onAutofill(session: GeckoSession,
notification: Int,
node: Autofill.Node?) {
val info = sessionRule.currentCall
if (info.counter < 2) {
assertThat("Should be an update notification",
notification,
equalTo(Autofill.Notify.NODE_UPDATED))
} else {
assertThat("Should be a commit notification",
notification,
equalTo(Autofill.Notify.SESSION_COMMITTED))
assertThat("Values should match",
countAutofillNodes({ it.value == "pass1x" }),
equalTo(1))
}
}
})
}
@Test fun autofill() {
// Test parts of the Oreo auto-fill API; there is another autofill test in
// SessionAccessibility for a11y auto-fill support.

Просмотреть файл

@ -41,6 +41,7 @@ open class BaseSessionTest(noErrorCollector: Boolean = false) {
const val FORMS3_HTML_PATH = "/assets/www/forms3.html"
const val FORMS4_HTML_PATH = "/assets/www/forms4.html"
const val FORMS_AUTOCOMPLETE_HTML_PATH = "/assets/www/forms_autocomplete.html"
const val FORMS_ID_VALUE_HTML_PATH = "/assets/www/forms_id_value.html"
const val HELLO_HTML_PATH = "/assets/www/hello.html"
const val HELLO2_HTML_PATH = "/assets/www/hello2.html"
const val HELLO_IFRAME_HTML_PATH = "/assets/www/iframe_hello.html"