diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/preferences/tests/browser_site_login_exceptions.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/components/preferences/tests/browser_site_login_exceptions.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_site_login_exceptions.js b/browser/components/preferences/tests/browser_site_login_exceptions.js new file mode 100644 index 0000000000..508232b234 --- /dev/null +++ b/browser/components/preferences/tests/browser_site_login_exceptions.js @@ -0,0 +1,101 @@ +"use strict"; +const PERMISSIONS_URL = + "chrome://browser/content/preferences/dialogs/permissions.xhtml"; + +var exceptionsDialog; + +add_task(async function openLoginExceptionsSubDialog() { + // ensure rememberSignons is off for this test; + ok( + !Services.prefs.getBoolPref("signon.rememberSignons"), + "Check initial value of signon.rememberSignons pref" + ); + + // Undo the save password change. + registerCleanupFunction(async function () { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { + let doc = content.document; + let savePasswordCheckBox = doc.getElementById("savePasswords"); + if (savePasswordCheckBox.checked) { + savePasswordCheckBox.click(); + } + }); + + gBrowser.removeCurrentTab(); + }); + + await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true }); + + let dialogOpened = promiseLoadSubDialog(PERMISSIONS_URL); + + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { + let doc = content.document; + let savePasswordCheckBox = doc.getElementById("savePasswords"); + Assert.ok( + !savePasswordCheckBox.checked, + "Save Password CheckBox should be unchecked by default" + ); + savePasswordCheckBox.click(); + + let loginExceptionsButton = doc.getElementById("passwordExceptions"); + loginExceptionsButton.click(); + }); + + exceptionsDialog = await dialogOpened; +}); + +add_task(async function addALoginException() { + let doc = exceptionsDialog.document; + + let richlistbox = doc.getElementById("permissionsBox"); + Assert.equal(richlistbox.itemCount, 0, "Row count should initially be 0"); + + let inputBox = doc.getElementById("url"); + inputBox.focus(); + + EventUtils.sendString("www.example.com", exceptionsDialog); + + let btnBlock = doc.getElementById("btnBlock"); + btnBlock.click(); + + await TestUtils.waitForCondition(() => richlistbox.itemCount == 2); + + let expectedResult = ["http://www.example.com", "https://www.example.com"]; + for (let website of expectedResult) { + let elements = richlistbox.getElementsByAttribute("origin", website); + is(elements.length, 1, "It should find only one coincidence"); + } +}); + +add_task(async function deleteALoginException() { + let doc = exceptionsDialog.document; + + let richlistbox = doc.getElementById("permissionsBox"); + let currentItems = 2; + Assert.equal( + richlistbox.itemCount, + currentItems, + `Row count should initially be ${currentItems}` + ); + richlistbox.focus(); + + while (richlistbox.itemCount) { + richlistbox.selectedIndex = 0; + + if (AppConstants.platform == "macosx") { + EventUtils.synthesizeKey("KEY_Backspace"); + } else { + EventUtils.synthesizeKey("KEY_Delete"); + } + + currentItems -= 1; + + await TestUtils.waitForCondition( + () => richlistbox.itemCount == currentItems + ); + is_element_visible( + content.gSubDialog._dialogs[0]._box, + "Subdialog is visible after deleting an element" + ); + } +}); |