Bug 1365957 - Pressing backspace on the cookies dialog to delete a cookie no longer removes the dialog. r?johannh
MozReview-Commit-ID: LDwIljC7Ji7
--- 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();
+});