Bug 1365957 - Pressing backspace on the cookies dialog to delete a cookie no longer removes the dialog. r=johannh
authorPrathiksha <prathikshaprasadsuman@gmail.com>
Mon, 17 Jul 2017 17:01:36 +0530
changeset 420329 e1f21848af1a83a3082cbca79e8657c7e42002bf
parent 420328 24d786a6e756ffc3d3f5ddadd5b367ce733ee211
child 420330 88f729384a4517c6cd2db1f3b03f92291d558151
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1365957
milestone56.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 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();
+});