Bug 1342940 - Add a test for login exception dialog interaction in about:preferences. r=standard8
authorJohann Hofmann <jhofmann@mozilla.com>
Tue, 14 Mar 2017 08:40:44 +0100
changeset 410979 b9658a599512b6ab7ba24766bab946c4370f9979
parent 410978 2e5cb33a39c074ec18663c1b2c96808429ad0854
child 410980 d218a8cbd8f7d2b8882b52e111a82646cbf999df
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1342940
milestone55.0a1
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
Bug 1342940 - Add a test for login exception dialog interaction in about:preferences. r=standard8 This is primarily to test removing items via the back or delete button, which has proven unreliable in the past. MozReview-Commit-ID: B9I9ZPrGWuq
browser/components/preferences/in-content-new/tests/browser.ini
browser/components/preferences/in-content-new/tests/browser_site_login_exceptions.js
browser/components/preferences/in-content/tests/browser.ini
browser/components/preferences/in-content/tests/browser_site_login_exceptions.js
--- a/browser/components/preferences/in-content-new/tests/browser.ini
+++ b/browser/components/preferences/in-content-new/tests/browser.ini
@@ -46,15 +46,16 @@ skip-if = true || !healthreport # Bug 11
 [browser_privacypane_4.js]
 [browser_privacypane_5.js]
 [browser_privacypane_8.js]
 [browser_sanitizeOnShutdown_prefLocked.js]
 [browser_searchsuggestions.js]
 [browser_security.js]
 [browser_siteData.js]
 [browser_siteData2.js]
+[browser_site_login_exceptions.js]
 [browser_subdialogs.js]
 support-files =
   subdialog.xul
   subdialog2.xul
 [browser_telemetry.js]
 # Skip this test on Android as FHR and Telemetry are separate systems there.
 skip-if = !healthreport || !telemetry || (os == 'linux' && debug) || (os == 'android')
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content-new/tests/browser_site_login_exceptions.js
@@ -0,0 +1,76 @@
+"use strict";
+const PERMISSIONS_URL = "chrome://browser/content/preferences/permissions.xul";
+
+var exceptionsDialog;
+
+add_task(async function openLoginExceptionsSubDialog() {
+  // Undo the save password change.
+  registerCleanupFunction(async function() {
+    await ContentTask.spawn(gBrowser.selectedBrowser, null, 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 ContentTask.spawn(gBrowser.selectedBrowser, null, 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 tree = doc.getElementById("permissionsTree");
+  Assert.equal(tree.view.rowCount, 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 waitForCondition(() => tree.view.rowCount == 1);
+
+  Assert.equal(tree.view.getCellText(0, tree.treeBoxObject.columns.getColumnAt(0)),
+               "http://www.example.com");
+});
+
+add_task(async function deleteALoginException() {
+  let doc = exceptionsDialog.document;
+
+  let tree = doc.getElementById("permissionsTree");
+  Assert.equal(tree.view.rowCount, 1, "Row count should initially be 1");
+  tree.focus();
+  tree.view.selection.select(0);
+
+  if (AppConstants.platform == "macosx") {
+    EventUtils.synthesizeKey("VK_BACK_SPACE", {});
+  } else {
+    EventUtils.synthesizeKey("VK_DELETE", {});
+  }
+
+  await waitForCondition(() => tree.view.rowCount == 0);
+
+  is_element_visible(content.gSubDialog._dialogs[0]._box,
+    "Subdialog is visible after deleting an element");
+});
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -36,15 +36,16 @@ skip-if = true || !healthreport # Bug 11
 [browser_privacypane_1.js]
 [browser_privacypane_3.js]
 [browser_privacypane_4.js]
 [browser_privacypane_5.js]
 [browser_privacypane_8.js]
 [browser_sanitizeOnShutdown_prefLocked.js]
 [browser_searchsuggestions.js]
 [browser_security.js]
+[browser_site_login_exceptions.js]
 [browser_subdialogs.js]
 support-files =
   subdialog.xul
   subdialog2.xul
 [browser_telemetry.js]
 # Skip this test on Android as FHR and Telemetry are separate systems there.
 skip-if = !healthreport || !telemetry || (os == 'linux' && debug) || (os == 'android')
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_site_login_exceptions.js
@@ -0,0 +1,76 @@
+"use strict";
+const PERMISSIONS_URL = "chrome://browser/content/preferences/permissions.xul";
+
+var exceptionsDialog;
+
+add_task(async function openLoginExceptionsSubDialog() {
+  // Undo the save password change.
+  registerCleanupFunction(async function() {
+    await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
+      let doc = content.document;
+      let savePasswordCheckBox = doc.getElementById("savePasswords");
+      if (savePasswordCheckBox.checked) {
+        savePasswordCheckBox.click();
+      }
+    });
+
+    gBrowser.removeCurrentTab();
+  });
+
+  await openPreferencesViaOpenPreferencesAPI("security", null, {leaveOpen: true});
+
+  let dialogOpened = promiseLoadSubDialog(PERMISSIONS_URL);
+
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, 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 tree = doc.getElementById("permissionsTree");
+  Assert.equal(tree.view.rowCount, 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 waitForCondition(() => tree.view.rowCount == 1);
+
+  Assert.equal(tree.view.getCellText(0, tree.treeBoxObject.columns.getColumnAt(0)),
+               "http://www.example.com");
+});
+
+add_task(async function deleteALoginException() {
+  let doc = exceptionsDialog.document;
+
+  let tree = doc.getElementById("permissionsTree");
+  Assert.equal(tree.view.rowCount, 1, "Row count should initially be 1");
+  tree.focus();
+  tree.view.selection.select(0);
+
+  if (AppConstants.platform == "macosx") {
+    EventUtils.synthesizeKey("VK_BACK_SPACE", {});
+  } else {
+    EventUtils.synthesizeKey("VK_DELETE", {});
+  }
+
+  await waitForCondition(() => tree.view.rowCount == 0);
+
+  is_element_visible(content.gSubDialog._dialogs[0]._box,
+    "Subdialog is visible after deleting an element");
+});