diff --git a/browser/extensions/formautofill/test/browser/browser.toml b/browser/extensions/formautofill/test/browser/browser.toml index 67167bfc8f40..6bb963febf3d 100644 --- a/browser/extensions/formautofill/test/browser/browser.toml +++ b/browser/extensions/formautofill/test/browser/browser.toml @@ -137,6 +137,13 @@ js ] [ " +browser_confirmation_popup +. +js +" +] +[ +" browser_dropdown_layout . js diff --git a/browser/extensions/formautofill/test/browser/browser_confirmation_popup.js b/browser/extensions/formautofill/test/browser/browser_confirmation_popup.js new file mode 100644 index 000000000000..b1ec390b7eee --- /dev/null +++ b/browser/extensions/formautofill/test/browser/browser_confirmation_popup.js @@ -0,0 +1,603 @@ +" +use +strict +" +; +async +function +expectSavedAddresses +( +expectedCount +) +{ +const +addresses += +await +getAddresses +( +) +; +is +( +addresses +. +length +expectedCount +{ +addresses +. +length +} +address +in +the +storage +) +; +return +addresses +; +} +add_setup +( +async +function +( +) +{ +await +SpecialPowers +. +pushPrefEnv +( +{ +set +: +[ +[ +" +extensions +. +formautofill +. +addresses +. +capture +. +v2 +. +enabled +" +true +] +[ +" +extensions +. +formautofill +. +addresses +. +supported +" +" +on +" +] +[ +" +extensions +. +formautofill +. +loglevel +" +" +debug +" +] +] +} +) +; +} +) +; +add_task +( +async +function +test_save_doorhanger_show_confirmation +( +) +{ +await +expectSavedAddresses +( +0 +) +; +await +BrowserTestUtils +. +withNewTab +( +{ +gBrowser +url +: +ADDRESS_FORM_URL +} +async +function +( +browser +) +{ +const +onSavePopupShown += +waitForPopupShown +( +) +; +await +focusUpdateSubmitForm +( +browser +{ +focusSelector +: +" +# +given +- +name +" +newValues +: +{ +" +# +given +- +name +" +: +" +Test +User +" +" +# +organization +" +: +" +Sesame +Street +" +" +# +street +- +address +" +: +" +123 +Sesame +Street +" +" +# +tel +" +: +" +1 +- +345 +- +345 +- +3456 +" +} +} +) +; +await +onSavePopupShown +; +const +hintShownAndVerified += +verifyConfirmationHint +( +browser +false +) +; +await +clickDoorhangerButton +( +MAIN_BUTTON +0 +) +; +info +( +" +waiting +for +verifyConfirmationHint +" +) +; +await +hintShownAndVerified +; +info +( +" +waiting +for +verifyConfirmationHint +< +< +" +) +; +} +) +; +await +expectSavedAddresses +( +1 +) +; +await +removeAllRecords +( +) +; +} +) +; +add_task +( +async +function +test_update_doorhanger_show_confirmation +( +) +{ +await +setStorage +( +TEST_ADDRESS_3 +) +; +await +expectSavedAddresses +( +1 +) +; +await +BrowserTestUtils +. +withNewTab +( +{ +gBrowser +url +: +ADDRESS_FORM_URL +} +async +function +( +browser +) +{ +const +onUpdatePopupShown += +waitForPopupShown +( +) +; +await +focusUpdateSubmitForm +( +browser +{ +focusSelector +: +" +# +given +- +name +" +newValues +: +{ +" +# +given +- +name +" +: +TEST_ADDRESS_3 +[ +" +given +- +name +" +] +" +# +street +- +address +" +: +{ +TEST_ADDRESS_3 +[ +" +street +- +address +" +] +} +4F +" +# +postal +- +code +" +: +TEST_ADDRESS_3 +[ +" +postal +- +code +" +] +} +} +) +; +await +onUpdatePopupShown +; +await +sleep +( +5000 +) +; +const +hintShownAndVerified += +verifyConfirmationHint +( +browser +false +) +; +await +clickDoorhangerButton +( +MAIN_BUTTON +0 +) +; +info +( +" +waiting +for +verifyConfirmationHint +" +) +; +await +hintShownAndVerified +; +} +) +; +await +expectSavedAddresses +( +1 +) +; +await +removeAllRecords +( +) +; +} +) +; +add_task +( +async +function +test_edit_doorhanger_show_confirmation +( +) +{ +await +expectSavedAddresses +( +0 +) +; +await +BrowserTestUtils +. +withNewTab +( +{ +gBrowser +url +: +ADDRESS_FORM_URL +} +async +function +( +browser +) +{ +const +onSavePopupShown += +waitForPopupShown +( +) +; +await +focusUpdateSubmitForm +( +browser +{ +focusSelector +: +" +# +given +- +name +" +newValues +: +{ +" +# +given +- +name +" +: +" +Test +User +" +" +# +organization +" +: +" +Sesame +Street +" +" +# +street +- +address +" +: +" +123 +Sesame +Street +" +" +# +tel +" +: +" +1 +- +345 +- +345 +- +3456 +" +} +} +) +; +await +onSavePopupShown +; +const +onEditPopupShown += +waitForPopupShown +( +) +; +await +clickAddressDoorhangerButton +( +EDIT_ADDRESS_BUTTON +) +; +await +onEditPopupShown +; +const +hintShownAndVerified += +verifyConfirmationHint +( +browser +false +) +; +await +clickDoorhangerButton +( +MAIN_BUTTON +0 +) +; +info +( +" +waiting +for +verifyConfirmationHint +" +) +; +await +hintShownAndVerified +; +} +) +; +await +expectSavedAddresses +( +1 +) +; +await +removeAllRecords +( +) +; +} +) +; diff --git a/browser/extensions/formautofill/test/browser/head.js b/browser/extensions/formautofill/test/browser/head.js index c4ca99da5513..964f351144c0 100644 --- a/browser/extensions/formautofill/test/browser/head.js +++ b/browser/extensions/formautofill/test/browser/head.js @@ -5654,6 +5654,207 @@ return normalized ; } +async +function +verifyConfirmationHint +( +browser +forceClose +anchorID += +" +identity +- +icon +" +) +{ +let +hintElem += +browser +. +ownerGlobal +. +ConfirmationHint +. +_panel +; +await +BrowserTestUtils +. +waitForPopupEvent +( +hintElem +" +shown +" +) +; +try +{ +Assert +. +equal +( +hintElem +. +state +" +open +" +" +hint +popup +is +open +" +) +; +Assert +. +ok +( +BrowserTestUtils +. +is_visible +( +hintElem +. +anchorNode +) +" +hint +anchorNode +is +visible +" +) +; +Assert +. +equal +( +hintElem +. +anchorNode +. +id +anchorID +" +Hint +should +be +anchored +on +the +expected +notification +icon +" +) +; +info +( +" +verifyConfirmationHint +hint +is +shown +and +has +its +anchorNode +" +) +; +if +( +forceClose +) +{ +await +closePopup +( +hintElem +) +; +} +else +{ +info +( +" +verifyConfirmationHint +assertion +ok +wait +for +poopuphidden +" +) +; +await +BrowserTestUtils +. +waitForPopupEvent +( +hintElem +" +hidden +" +) +; +info +( +" +verifyConfirmationHint +hintElem +popup +is +hidden +" +) +; +} +} +catch +( +ex +) +{ +Assert +. +ok +( +false +" +Confirmation +hint +not +shown +: +" ++ +ex +. +message +) +; +} +finally +{ +info +( +" +verifyConfirmationHint +promise +finalized +" +) +; +} +} add_setup ( function diff --git a/toolkit/components/formautofill/default/FormAutofillPrompter.sys.mjs b/toolkit/components/formautofill/default/FormAutofillPrompter.sys.mjs index d6eafd5b180c..d7d0be656c40 100644 --- a/toolkit/components/formautofill/default/FormAutofillPrompter.sys.mjs +++ b/toolkit/components/formautofill/default/FormAutofillPrompter.sys.mjs @@ -3699,9 +3699,12 @@ DEFAULT_REGION Address edit doorhanger -has -different +changes layout +according +to +the +country # layout = @@ -8176,12 +8179,18 @@ flowId isCapture ) ; +if +( +confirmationHintId +) +{ showConfirmation ( browser confirmationHintId ) ; +} return state ; @@ -8659,6 +8668,9 @@ resolve = > { +let +doorhanger +; const editAddressCb = @@ -8749,25 +8761,32 @@ resolve { state : -isSave -? -" -create -" -: -" -update -" -confimationHintId +doorhanger +. +ui +. +footer +. +mainAction +. +callbackState +confirmationHintId : -null +doorhanger +. +ui +. +footer +. +mainAction +. +confirmationHintId } ) ; } } ; -const doorhanger = isSave @@ -8847,12 +8866,18 @@ flowId isSave ) ; +if +( +confirmationHintId +) +{ showConfirmation ( browser confirmationHintId ) ; +} return { state