Backed out changeset 7cede79b33b2 (bug 1699794) for causing mochitest failures in browser_autocomplete_footer. CLOSED TREE
authorSandor Molnar <smolnar@mozilla.com>
Fri, 11 Jun 2021 00:10:21 +0300
changeset 582757 4f7b60d2d51e72e14b3bfb1c357b254a876d1640
parent 582756 01b9fd516f4d2e02197d9a714d76d3195076324b
child 582758 98cbc5855715a2fce3c4d638328e5ad1e29bad46
push id144771
push usersmolnar@mozilla.com
push dateThu, 10 Jun 2021 21:12:10 +0000
treeherderautoland@4f7b60d2d51e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1699794
milestone91.0a1
backs out7cede79b33b2a7fb92b10b9580f721e858bc8475
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 7cede79b33b2 (bug 1699794) for causing mochitest failures in browser_autocomplete_footer. CLOSED TREE
mobile/android/geckoview/src/androidTest/assets/www/address_form.html
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/AutocompleteTest.kt
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/BaseSessionTest.kt
toolkit/components/formautofill/FormAutofillContent.jsm
deleted file mode 100644
--- a/mobile/android/geckoview/src/androidTest/assets/www/address_form.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<html>
-    <head>
-        <meta charset="utf-8">
-        <title>Address form</title>
-    </head>
-    <body>
-        <form>
-            <input autocomplete="name" id="name">
-            <input autocomplete="given-name" id="givenName">
-            <input autocomplete="additional-name" id="additionalName">
-            <input autocomplete="family-name" id="familyName">
-            <input autocomplete="street-address" id="streetAddress">
-            <input autocomplete="country" id="country">
-            <input autocomplete="postal-code" id="postalCode">
-            <input autocomplete="organization" id="organization">
-            <input autocomplete="email" id="email">
-            <input autocomplete="tel" id="tel">
-            <input type="submit" value="Submit">
-        </form>
-    </body>
-</html>
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/AutocompleteTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/AutocompleteTest.kt
@@ -15,26 +15,24 @@ import org.hamcrest.Matchers.*
 
 import org.junit.Test
 import org.junit.runner.RunWith
 
 import org.mozilla.geckoview.GeckoResult
 import org.mozilla.geckoview.GeckoSession
 import org.mozilla.geckoview.GeckoSession.PromptDelegate
 import org.mozilla.geckoview.GeckoSession.PromptDelegate.AutocompleteRequest
-import org.mozilla.geckoview.Autocomplete.Address
-import org.mozilla.geckoview.Autocomplete.AddressSelectOption
+import org.mozilla.geckoview.Autocomplete
 import org.mozilla.geckoview.Autocomplete.CreditCard
 import org.mozilla.geckoview.Autocomplete.CreditCardSelectOption
 import org.mozilla.geckoview.Autocomplete.LoginEntry
 import org.mozilla.geckoview.Autocomplete.LoginSaveOption
 import org.mozilla.geckoview.Autocomplete.LoginSelectOption
 import org.mozilla.geckoview.Autocomplete.SelectOption
 import org.mozilla.geckoview.Autocomplete.StorageDelegate
-import org.mozilla.geckoview.Autocomplete.UsedField
 import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
 import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
 import org.mozilla.geckoview.test.util.Callbacks
 
 
 @RunWith(AndroidJUnit4::class)
 @MediumTest
 class AutocompleteTest : BaseSessionTest() {
@@ -169,17 +167,17 @@ class AutocompleteTest : BaseSessionTest
             @AssertCalled(count = 1)
             override fun onCreditCardSelect(
                     session: GeckoSession,
                     prompt: AutocompleteRequest<CreditCardSelectOption>)
                     : GeckoResult<PromptDelegate.PromptResponse>? {
                 assertThat("Session should not be null", session, notNullValue())
 
                 assertThat(
-                    "There should be two options",
+                    "There should be one option",
                     prompt.options.size,
                     equalTo(2))
 
                 for (i in 0..1) {
                     val creditCard = prompt.options[i].value
 
                     assertThat("Credit card should not be null", creditCard, notNullValue())
                     assertThat(
@@ -217,228 +215,16 @@ class AutocompleteTest : BaseSessionTest
             equalTo(expMonth[0]))
         assertThat(
             "Filled expiration year should match",
             mainSession.evaluateJS("document.querySelector('#expYear').value") as String,
             equalTo(expYear[0]))
     }
 
     @Test
-    fun fetchAddresses() {
-        val runtime = sessionRule.runtime
-        val register = { delegate: StorageDelegate ->
-            runtime.autocompleteStorageDelegate = delegate
-        }
-        val unregister = { _: StorageDelegate ->
-            runtime.autocompleteStorageDelegate = null
-        }
-
-        val fetchHandled = GeckoResult<Void>()
-
-        sessionRule.addExternalDelegateUntilTestEnd(
-                StorageDelegate::class, register, unregister,
-                object : StorageDelegate {
-                    @AssertCalled(count = 1)
-                    override fun onAddressFetch()
-                            : GeckoResult<Array<Address>>? {
-                        Handler(Looper.getMainLooper()).postDelayed({
-                            fetchHandled.complete(null)
-                        }, acceptDelay)
-
-                        return null
-                    }
-                })
-
-        mainSession.loadTestPath(ADDRESS_FORM_HTML_PATH)
-        mainSession.waitForPageStop()
-        mainSession.evaluateJS("document.querySelector('#name').focus()")
-        sessionRule.waitForResult(fetchHandled)
-    }
-
-    fun checkAddressesForCorrectness(savedAddresses: Array<Address>, selectedAddress: Address) {
-        // Test:
-        // 1. Load an address form page.
-        // 2. Focus on the given name input field.
-        //    a. Ensure onAddressFetch is called.
-        //    b. Return the saved entries.
-        //    c. Ensure onAddressSelect is called.
-        //    d. Select and return one of the options.
-        //    e. Ensure the form is filled accordingly.
-
-        val runtime = sessionRule.runtime
-        val register = { delegate: StorageDelegate ->
-            runtime.autocompleteStorageDelegate = delegate
-        }
-        val unregister = { _: StorageDelegate ->
-            runtime.autocompleteStorageDelegate = null
-        }
-
-        val selectHandled = GeckoResult<Void>()
-
-        sessionRule.addExternalDelegateUntilTestEnd(
-                StorageDelegate::class, register, unregister,
-                object : StorageDelegate {
-                    @AssertCalled
-                    override fun onAddressFetch()
-                            : GeckoResult<Array<Address>>? {
-                        return GeckoResult.fromValue(savedAddresses)
-                    }
-
-                    @AssertCalled(false)
-                    override fun onAddressSave(address: Address) {}
-                })
-
-        mainSession.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
-            @AssertCalled(count = 1)
-            override fun onAddressSelect(
-                    session: GeckoSession,
-                    prompt: AutocompleteRequest<AddressSelectOption>)
-                    : GeckoResult<PromptDelegate.PromptResponse>? {
-                assertThat("Session should not be null", session, notNullValue())
-
-                assertThat(
-                        "There should be one option",
-                        prompt.options.size,
-                        equalTo(savedAddresses.size))
-
-                val addressOption = prompt.options.find { it.value.familyName == selectedAddress.familyName }
-                val address = addressOption?.value
-
-                assertThat("Address should not be null", address, notNullValue())
-                assertThat(
-                        "Given name should match",
-                        address?.givenName,
-                        equalTo(selectedAddress.givenName))
-                assertThat(
-                        "Family name should match",
-                        address?.familyName,
-                        equalTo(selectedAddress.familyName))
-                assertThat(
-                        "Street address should match",
-                        address?.streetAddress,
-                        equalTo(selectedAddress.streetAddress))
-
-                Handler(Looper.getMainLooper()).postDelayed({
-                    selectHandled.complete(null)
-                }, acceptDelay)
-
-                return GeckoResult.fromValue(prompt.confirm(addressOption!!))
-            }
-        })
-
-        mainSession.loadTestPath(ADDRESS_FORM_HTML_PATH)
-        mainSession.waitForPageStop()
-
-        // Focus on the given name input field.
-        mainSession.evaluateJS("document.querySelector('#givenName').focus()")
-        sessionRule.waitForResult(selectHandled)
-
-        assertThat(
-                "Filled given name should match",
-                mainSession.evaluateJS("document.querySelector('#givenName').value") as String,
-                equalTo(selectedAddress.givenName))
-        assertThat(
-                "Filled family name should match",
-                mainSession.evaluateJS("document.querySelector('#familyName').value") as String,
-                equalTo(selectedAddress.familyName))
-        assertThat(
-                "Filled street address should match",
-                mainSession.evaluateJS("document.querySelector('#streetAddress').value") as String,
-                equalTo(selectedAddress.streetAddress))
-        assertThat(
-                "Filled country should match",
-                mainSession.evaluateJS("document.querySelector('#country').value") as String,
-                equalTo(selectedAddress.country))
-        assertThat(
-                "Filled postal code should match",
-                mainSession.evaluateJS("document.querySelector('#postalCode').value") as String,
-                equalTo(selectedAddress.postalCode))
-        assertThat(
-                "Filled email should match",
-                mainSession.evaluateJS("document.querySelector('#email').value") as String,
-                equalTo(selectedAddress.email))
-        assertThat(
-                "Filled telephone number should match",
-                mainSession.evaluateJS("document.querySelector('#tel').value") as String,
-                equalTo(selectedAddress.tel))
-        assertThat(
-                "Filled organization should match",
-                mainSession.evaluateJS("document.querySelector('#organization').value") as String,
-                equalTo(selectedAddress.organization))
-    }
-
-    @Test
-    fun addressSelectAndFill() {
-        val givenName = "Peter"
-        val familyName = "Parker"
-        val streetAddress = "20 Ingram Street, Forest Hills Gardens, Queens"
-        val postalCode = "11375"
-        val country = "US"
-        val email = "spiderman@newyork.com"
-        val tel = "+1 180090021"
-        val organization = ""
-        val guid = "test-guid"
-        val savedAddress = Address.Builder()
-                .guid(guid)
-                .givenName(givenName)
-                .familyName(familyName)
-                .streetAddress(streetAddress)
-                .postalCode(postalCode)
-                .country(country)
-                .email(email)
-                .tel(tel)
-                .organization(organization)
-                .build()
-        val savedAddresses = mutableListOf<Address>(savedAddress)
-
-        checkAddressesForCorrectness(savedAddresses.toTypedArray(), savedAddress)
-    }
-
-
-    @Test
-    fun addressSelectAndFillMultipleAddresses() {
-        val givenNames = arrayOf("Peter", "Wade")
-        val familyNames = arrayOf("Parker", "Wilson")
-        val streetAddresses = arrayOf("20 Ingram Street, Forest Hills Gardens, Queens", "890 Fifth Avenue, Manhattan")
-        val postalCodes = arrayOf("11375", "10110")
-        val countries = arrayOf("US", "US")
-        val emails = arrayOf("spiderman@newyork.com", "deadpool@newyork.com")
-        val tels = arrayOf("+1 180090021", "+1 180055555")
-        val organizations = arrayOf("", "")
-        val guids = arrayOf("test-guid-1", "test-guid-2")
-        val selectedAddress = Address.Builder()
-                .guid(guids[1])
-                .givenName(givenNames[1])
-                .familyName(familyNames[1])
-                .streetAddress(streetAddresses[1])
-                .postalCode(postalCodes[1])
-                .country(countries[1])
-                .email(emails[1])
-                .tel(tels[1])
-                .organization(organizations[1])
-                .build()
-        val savedAddresses = mutableListOf<Address>(
-                Address.Builder()
-                        .guid(guids[0])
-                        .givenName(givenNames[0])
-                        .familyName(familyNames[0])
-                        .streetAddress(streetAddresses[0])
-                        .postalCode(postalCodes[0])
-                        .country(countries[0])
-                        .email(emails[0])
-                        .tel(tels[0])
-                        .organization(organizations[0])
-                        .build(),
-                selectedAddress
-        )
-
-        checkAddressesForCorrectness(savedAddresses.toTypedArray(), selectedAddress)
-    }
-
-    @Test
     fun loginSaveDismiss() {
         sessionRule.setPrefsUntilTestEnd(mapOf(
                 // Enable login management since it's disabled in automation.
                 "signon.rememberSignons" to true,
                 "signon.autofillForms.http" to true,
                 "signon.userInputRequiredToCapture.enabled" to false))
 
         val runtime = sessionRule.runtime
@@ -825,17 +611,17 @@ class AutocompleteTest : BaseSessionTest
                     return GeckoResult.fromValue(savedLogins.toTypedArray())
                 }
 
                 @AssertCalled(count = 1)
                 override fun onLoginUsed(login: LoginEntry, usedFields: Int) {
                     assertThat(
                         "Used fields should match",
                         usedFields,
-                        equalTo(UsedField.PASSWORD))
+                        equalTo(Autocomplete.UsedField.PASSWORD))
 
                     assertThat(
                         "Username should match",
                         login.username,
                         equalTo(user1))
 
                     assertThat(
                         "Password should match",
@@ -1092,17 +878,17 @@ class AutocompleteTest : BaseSessionTest
                 handle.complete(null)
             }
 
             @AssertCalled(count = 1)
             override fun onLoginUsed(login: LoginEntry, usedFields: Int) {
                 assertThat(
                     "Used fields should match",
                     usedFields,
-                    equalTo(UsedField.PASSWORD))
+                    equalTo(Autocomplete.UsedField.PASSWORD))
 
                 assertThat(
                     "Username should match",
                     login.username,
                     equalTo(user1))
 
                 assertThat(
                     "Password should match",
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/BaseSessionTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/BaseSessionTest.kt
@@ -36,17 +36,16 @@ open class BaseSessionTest(noErrorCollec
         const val CLICK_TO_RELOAD_HTML_PATH = "/assets/www/clickToReload.html"
         const val CONTENT_CRASH_URL = "about:crashcontent"
         const val DOWNLOAD_HTML_PATH = "/assets/www/download.html"
         const val FORM_BLANK_HTML_PATH = "/assets/www/form_blank.html"
         const val FORMS_HTML_PATH = "/assets/www/forms.html"
         const val FORMS2_HTML_PATH = "/assets/www/forms2.html"
         const val FORMS3_HTML_PATH = "/assets/www/forms3.html"
         const val FORMS4_HTML_PATH = "/assets/www/forms4.html"
-        const val ADDRESS_FORM_HTML_PATH = "/assets/www/address_form.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 CC_FORM_HTML_PATH = "/assets/www/cc_form.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"
         const val INPUTS_PATH = "/assets/www/inputs.html"
         const val INVALID_URI = "not a valid uri"
--- a/toolkit/components/formautofill/FormAutofillContent.jsm
+++ b/toolkit/components/formautofill/FormAutofillContent.jsm
@@ -691,25 +691,28 @@ var FormAutofillContent = {
         "updateActiveElement: Not opening popup because field is " +
           `not empty: element.value = "${element.value}"`
       );
     } else {
       this.debug(
         "updateActiveElement: checking if empty field is cc-*: ",
         this.activeFieldDetail?.fieldName
       );
-
-      if (Services.cpmm.sharedData.get("FormAutofill:enabled")) {
-        this.debug("updateActiveElement: opening pop up");
-        formFillController.showPopup();
-      } else {
-        this.debug(
-          "updateActiveElement: Deferring pop-up until Autofill is ready"
-        );
-        this._popupPending = true;
+      // This restricts popups to credit card fields and may need adjustment
+      // when enabling address support for the GeckoView backend.
+      if (this.activeFieldDetail?.fieldName?.startsWith("cc-")) {
+        if (Services.cpmm.sharedData.get("FormAutofill:enabled")) {
+          this.debug("updateActiveElement: opening pop up");
+          formFillController.showPopup();
+        } else {
+          this.debug(
+            "updateActiveElement: Deferring pop-up until Autofill is ready"
+          );
+          this._popupPending = true;
+        }
       }
     }
   },
 
   get activeInput() {
     let elementWeakRef = this._activeItems.elementWeakRef;
     return elementWeakRef ? elementWeakRef.get() : null;
   },