2 const PERMISSIONS_URL =
3 "chrome://browser/content/preferences/dialogs/permissions.xhtml";
7 add_task(async function openLoginExceptionsSubDialog() {
8 // ensure rememberSignons is off for this test;
10 !Services.prefs.getBoolPref("signon.rememberSignons"),
11 "Check initial value of signon.rememberSignons pref"
14 // Undo the save password change.
15 registerCleanupFunction(async function () {
16 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
17 let doc = content.document;
18 let savePasswordCheckBox = doc.getElementById("savePasswords");
19 if (savePasswordCheckBox.checked) {
20 savePasswordCheckBox.click();
24 gBrowser.removeCurrentTab();
27 await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
29 let dialogOpened = promiseLoadSubDialog(PERMISSIONS_URL);
31 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
32 let doc = content.document;
33 let savePasswordCheckBox = doc.getElementById("savePasswords");
35 !savePasswordCheckBox.checked,
36 "Save Password CheckBox should be unchecked by default"
38 savePasswordCheckBox.click();
40 let loginExceptionsButton = doc.getElementById("passwordExceptions");
41 loginExceptionsButton.click();
44 exceptionsDialog = await dialogOpened;
47 add_task(async function addALoginException() {
48 let doc = exceptionsDialog.document;
50 let richlistbox = doc.getElementById("permissionsBox");
51 Assert.equal(richlistbox.itemCount, 0, "Row count should initially be 0");
53 let inputBox = doc.getElementById("url");
56 EventUtils.sendString("www.example.com", exceptionsDialog);
58 let btnBlock = doc.getElementById("btnBlock");
61 await TestUtils.waitForCondition(() => richlistbox.itemCount == 2);
63 let expectedResult = ["http://www.example.com", "https://www.example.com"];
64 for (let website of expectedResult) {
65 let elements = richlistbox.getElementsByAttribute("origin", website);
66 is(elements.length, 1, "It should find only one coincidence");
70 add_task(async function deleteALoginException() {
71 let doc = exceptionsDialog.document;
73 let richlistbox = doc.getElementById("permissionsBox");
76 richlistbox.itemCount,
78 `Row count should initially be ${currentItems}`
82 while (richlistbox.itemCount) {
83 richlistbox.selectedIndex = 0;
85 if (AppConstants.platform == "macosx") {
86 EventUtils.synthesizeKey("KEY_Backspace");
88 EventUtils.synthesizeKey("KEY_Delete");
93 await TestUtils.waitForCondition(
94 () => richlistbox.itemCount == currentItems
97 content.gSubDialog._dialogs[0]._box,
98 "Subdialog is visible after deleting an element"