Bug 1365957 - Pressing backspace on the cookies dialog to delete a cookie no longer removes the dialog. r?johannh draft
authorPrathiksha <prathikshaprasadsuman@gmail.com>
Mon, 17 Jul 2017 17:01:36 +0530
changeset 617276 02ad7f41dea9256c1ab41f6e10d28c3ac7728a51
parent 616724 658cba6a971257e2ba39715ec938256dfc414776
child 639778 82f9e16e5f22c75faf0b74d8a91fb4017a29d1f6
push id71013
push userbmo:prathikshaprasadsuman@gmail.com
push dateFri, 28 Jul 2017 09:23:26 +0000
reviewersjohannh
bugs1365957
milestone56.0a1
Bug 1365957 - Pressing backspace on the cookies dialog to delete a cookie no longer removes the dialog. r?johannh MozReview-Commit-ID: LDwIljC7Ji7
browser/components/preferences/cookies.js
browser/components/preferences/in-content-new/tests/browser.ini
browser/components/preferences/in-content-new/tests/browser_cookies_dialog.js
browser/components/preferences/in-content/tests/browser.ini
browser/components/preferences/in-content/tests/browser_cookies_dialog.js
--- a/browser/components/preferences/cookies.js
+++ b/browser/components/preferences/cookies.js
@@ -724,21 +724,21 @@ var gCookiesWindow = {
     } else {
       this._cm.removeAll();
     }
     this._updateRemoveAllButton();
     this.focusFilterBox();
   },
 
   onCookieKeyPress(aEvent) {
-    if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE) {
+    if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE ||
+        (AppConstants.platform == "macosx" &&
+        aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE)) {
       this.deleteCookie();
-    } else if (AppConstants.platform == "macosx" &&
-               aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE) {
-      this.deleteCookie();
+      aEvent.preventDefault();
     }
   },
 
   _lastSortProperty: "",
   _lastSortAscending: false,
   sort(aProperty) {
     var ascending = (aProperty == this._lastSortProperty) ? !this._lastSortAscending : true;
     // Sort the Non-Filtered Host Collections
--- a/browser/components/preferences/in-content-new/tests/browser.ini
+++ b/browser/components/preferences/in-content-new/tests/browser.ini
@@ -55,15 +55,16 @@ skip-if = e10s
 [browser_privacypane_8.js]
 [browser_sanitizeOnShutdown_prefLocked.js]
 [browser_searchsuggestions.js]
 [browser_security-1.js]
 [browser_security-2.js]
 [browser_siteData.js]
 [browser_siteData2.js]
 [browser_site_login_exceptions.js]
+[browser_cookies_dialog.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_cookies_dialog.js
@@ -0,0 +1,50 @@
+"use strict";
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+const COOKIES_URL = "chrome://browser/content/preferences/cookies.xul";
+
+const URI = Services.io.newURI("http://www.example.com");
+var cookiesDialog;
+
+add_task(async function openCookiesSubDialog() {
+  await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
+
+  let dialogOpened = promiseLoadSubDialog(COOKIES_URL);
+
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
+    let doc = content.document;
+    let cookiesButton = doc.getElementById("historyRememberCookies");
+    cookiesButton.click();
+  });
+
+  cookiesDialog = await dialogOpened;
+});
+
+add_task(async function testDeleteCookie() {
+  let doc = cookiesDialog.document;
+
+  // Add a cookie.
+  Services.cookies.add(URI.host, URI.path, "", "", false, false, true, Date.now());
+
+  let tree = doc.getElementById("cookiesList");
+  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");
+
+});
+
+add_task(async function removeTab() {
+  gBrowser.removeCurrentTab();
+});
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -42,15 +42,16 @@ skip-if = e10s
 [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_cookies_dialog.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_cookies_dialog.js
@@ -0,0 +1,50 @@
+"use strict";
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+const COOKIES_URL = "chrome://browser/content/preferences/cookies.xul";
+
+const URI = Services.io.newURI("http://www.example.com");
+var cookiesDialog;
+
+add_task(async function openCookiesSubDialog() {
+  await openPreferencesViaOpenPreferencesAPI("panePrivacy", null, {leaveOpen: true});
+
+  let dialogOpened = promiseLoadSubDialog(COOKIES_URL);
+
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
+    let doc = content.document;
+    let cookiesButton = doc.getElementById("historyRememberCookies");
+    cookiesButton.click();
+  });
+
+  cookiesDialog = await dialogOpened;
+});
+
+add_task(async function testDeleteCookie() {
+  let doc = cookiesDialog.document;
+
+  // Add a cookie.
+  Services.cookies.add(URI.host, URI.path, "", "", false, false, true, Date.now());
+
+  let tree = doc.getElementById("cookiesList");
+  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");
+
+});
+
+add_task(async function removeTab() {
+  gBrowser.removeCurrentTab();
+});