From a1c60a65c2de0c8213c11f6fa7da1afea11b27eb Mon Sep 17 00:00:00 2001 From: "Johannes J. Schmidt" <joschmidt@mozilla.com> Date: Mon, 5 Jun 2023 14:15:04 +0000 Subject: [PATCH] Bug 1800296 - fix test_autocomplete_tab_between_fields.html intermittent - r=credential-management-reviewers,sgalich,dimi a=test-only and enable the test again Differential Revision: https://phabricator.services.mozilla.com/D179798 --- .../passwordmgr/test/mochitest/mochitest.ini | 1 - .../test_autocomplete_tab_between_fields.html | 21 ++++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/toolkit/components/passwordmgr/test/mochitest/mochitest.ini b/toolkit/components/passwordmgr/test/mochitest/mochitest.ini index 960111f4d8923..feb825d4122d0 100644 --- a/toolkit/components/passwordmgr/test/mochitest/mochitest.ini +++ b/toolkit/components/passwordmgr/test/mochitest/mochitest.ini @@ -106,7 +106,6 @@ skip-if = toolkit == 'android' # autocomplete scheme = https skip-if = xorigin || toolkit == 'android' # autocomplete - os == "linux" # Bug 1800296 [test_autofill_autocomplete_types.html] scheme = https skip-if = toolkit == 'android' # bug 1533965 diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_tab_between_fields.html b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_tab_between_fields.html index 3770c967fd5c7..9df34676210d6 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_tab_between_fields.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_tab_between_fields.html @@ -114,10 +114,9 @@ async function testResultOfTabInteractions(testData) { info("Placing focus in the password field"); form.pword.focus(); await synthesizeKey("KEY_Tab", { shiftKey: true }); // blur pw, focus un - await new Promise(resolve => SimpleTest.executeSoon(resolve)); // moving focus shouldn't change anything - checkForm(1, "", ""); + await ensureLoginFormStaysFilledWith(form.uname, "", form.pword, ""); info("waiting for AC results"); const results = await popupByArrowDown(); @@ -137,18 +136,20 @@ async function testResultOfTabInteractions(testData) { }, "AutoComplete popup should have closed"); await synthesizeKey("KEY_Tab"); - // Filling password is performed asynchronously. So, let's wait the value - // change instead of just waiting next event loop. + + // wait until username and password are automatically filled in with the + // expected values... + await TestUtils.waitForCondition(() => { + return form.uname.value === testData.expectedTabbedUsername & form.pword.value === testData.expectedTabbedPassword; + }, "Username and password field should be filled"); + + // ...and if the value is not different from the original value in the form, + // make sure that the form keeps its values if (testData.expectedTabbedPassword === "") { - await new Promise(resolve => SimpleTest.executeSoon(resolve)); - } else { - await TestUtils.waitForCondition(() => { - return form.pword.value === testData.expectedTabbedPassword; - }, "Password field should be filled"); + await ensureLoginFormStaysFilledWith(form.uname, testData.expectedTabbedUsername, form.pword, testData.expectedTabbedPassword); } ok(form.pword.matches("input:focus"), "pword field is focused"); - checkForm(1, testData.expectedTabbedUsername, testData.expectedTabbedPassword); } for (const testData of tests) { -- GitLab