From bb40d6bc77cf91583e8c007bf7f4653a29a90d62 Mon Sep 17 00:00:00 2001 From: Sebastian Zartner Date: Sun, 27 Aug 2017 00:33:33 +0200 Subject: [PATCH] Bug 1336934 - Added option to remove all session cookies for a specific domain r=miker MozReview-Commit-ID: Anm6aHQOlkO --HG-- extra : rebase_source : aba29ba0173e0176f8e9676aa0a6e17b70b0eae9 --- devtools/client/locales/en-US/storage.dtd | 3 + devtools/client/storage/storage.xul | 4 + .../storage/test/browser_storage_basic.js | 11 ++- .../browser_storage_basic_usercontextid_1.js | 11 ++- .../browser_storage_basic_with_fragment.js | 9 ++- .../browser_storage_cookies_delete_all.js | 73 +++++++++++++++---- .../test/browser_storage_delete_tree.js | 4 +- .../browser_storage_delete_usercontextid.js | 11 ++- .../client/storage/test/storage-listings.html | 5 +- .../storage/test/storage-secured-iframe.html | 3 + .../test/storage-unsecured-iframe.html | 3 + devtools/client/storage/ui.js | 41 +++++++++++ devtools/server/actors/storage.js | 23 +++++- devtools/shared/specs/storage.js | 8 ++ 14 files changed, 185 insertions(+), 24 deletions(-) diff --git a/devtools/client/locales/en-US/storage.dtd b/devtools/client/locales/en-US/storage.dtd index 211c794369f4..adfc03183356 100644 --- a/devtools/client/locales/en-US/storage.dtd +++ b/devtools/client/locales/en-US/storage.dtd @@ -9,3 +9,6 @@ + + + diff --git a/devtools/client/storage/storage.xul b/devtools/client/storage/storage.xul index 5e92d2d2ddd2..afbeb4443741 100644 --- a/devtools/client/storage/storage.xul +++ b/devtools/client/storage/storage.xul @@ -27,6 +27,8 @@ + @@ -35,6 +37,8 @@ + diff --git a/devtools/client/storage/test/browser_storage_basic.js b/devtools/client/storage/test/browser_storage_basic.js index 2865ce790538..0a309bb4edc9 100644 --- a/devtools/client/storage/test/browser_storage_basic.js +++ b/devtools/client/storage/test/browser_storage_basic.js @@ -29,15 +29,22 @@ const testCases = [ getCookieId("c1", "test1.example.org", "/browser"), getCookieId("cs2", ".example.org", "/"), getCookieId("c3", "test1.example.org", "/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("c4", ".example.org", "/"), + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], [ ["cookies", "https://sectest1.example.org"], [ getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/"), getCookieId("cs2", ".example.org", "/"), - getCookieId("sc1", "sectest1.example.org", "/browser/devtools/client/storage/test/") + getCookieId("c4", ".example.org", "/"), + getCookieId("sc1", "sectest1.example.org", + "/browser/devtools/client/storage/test/"), + getCookieId("sc2", "sectest1.example.org", + "/browser/devtools/client/storage/test/") ] ], [["localStorage", "http://test1.example.org"], diff --git a/devtools/client/storage/test/browser_storage_basic_usercontextid_1.js b/devtools/client/storage/test/browser_storage_basic_usercontextid_1.js index 0c24be26bc35..06dff6360cd7 100644 --- a/devtools/client/storage/test/browser_storage_basic_usercontextid_1.js +++ b/devtools/client/storage/test/browser_storage_basic_usercontextid_1.js @@ -14,15 +14,22 @@ const testCases = [ getCookieId("c1", "test1.example.org", "/browser"), getCookieId("cs2", ".example.org", "/"), getCookieId("c3", "test1.example.org", "/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("c4", ".example.org", "/"), + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], [ ["cookies", "https://sectest1.example.org"], [ getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/"), getCookieId("cs2", ".example.org", "/"), - getCookieId("sc1", "sectest1.example.org", "/browser/devtools/client/storage/test/") + getCookieId("c4", ".example.org", "/"), + getCookieId("sc1", "sectest1.example.org", + "/browser/devtools/client/storage/test/"), + getCookieId("sc2", "sectest1.example.org", + "/browser/devtools/client/storage/test/") ] ], [["localStorage", "http://test1.example.org"], diff --git a/devtools/client/storage/test/browser_storage_basic_with_fragment.js b/devtools/client/storage/test/browser_storage_basic_with_fragment.js index 7769781c07b4..2353b4384711 100644 --- a/devtools/client/storage/test/browser_storage_basic_with_fragment.js +++ b/devtools/client/storage/test/browser_storage_basic_with_fragment.js @@ -34,15 +34,20 @@ const testCases = [ getCookieId("c1", "test1.example.org", "/browser"), getCookieId("cs2", ".example.org", "/"), getCookieId("c3", "test1.example.org", "/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], [ ["cookies", "https://sectest1.example.org"], [ getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/"), getCookieId("cs2", ".example.org", "/"), - getCookieId("sc1", "sectest1.example.org", "/browser/devtools/client/storage/test/") + getCookieId("sc1", "sectest1.example.org", + "/browser/devtools/client/storage/test/"), + getCookieId("sc2", "sectest1.example.org", + "/browser/devtools/client/storage/test/") ] ], [["localStorage", "http://test1.example.org"], diff --git a/devtools/client/storage/test/browser_storage_cookies_delete_all.js b/devtools/client/storage/test/browser_storage_cookies_delete_all.js index 3de9fdb36b5a..8afd12b5e961 100644 --- a/devtools/client/storage/test/browser_storage_cookies_delete_all.js +++ b/devtools/client/storage/test/browser_storage_cookies_delete_all.js @@ -8,11 +8,13 @@ // Test deleting all cookies -function* performDelete(store, rowName, deleteAll) { +function* performDelete(store, rowName, action) { let contextMenu = gPanelWindow.document.getElementById( "storage-table-popup"); let menuDeleteAllItem = contextMenu.querySelector( "#storage-table-popup-delete-all"); + let menuDeleteAllSessionCookiesItem = contextMenu.querySelector( + "#storage-table-popup-delete-all-session-cookies"); let menuDeleteAllFromItem = contextMenu.querySelector( "#storage-table-popup-delete-all-from"); @@ -25,13 +27,19 @@ function* performDelete(store, rowName, deleteAll) { yield waitForContextMenu(contextMenu, cells.name, () => { info(`Opened context menu in ${storeName}, row '${rowName}'`); - if (deleteAll) { - menuDeleteAllItem.click(); - } else { - menuDeleteAllFromItem.click(); - let hostName = cells.host.value; - ok(menuDeleteAllFromItem.getAttribute("label").includes(hostName), + switch (action) { + case "deleteAll": + menuDeleteAllItem.click(); + break; + case "deleteAllSessionCookies": + menuDeleteAllSessionCookiesItem.click(); + break; + case "deleteAllFrom": + menuDeleteAllFromItem.click(); + let hostName = cells.host.value; + ok(menuDeleteAllFromItem.getAttribute("label").includes(hostName), `Context menu item label contains '${hostName}'`); + break; } }); @@ -48,15 +56,21 @@ add_task(function* () { getCookieId("c1", "test1.example.org", "/browser"), getCookieId("c3", "test1.example.org", "/"), getCookieId("cs2", ".example.org", "/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("c4", ".example.org", "/"), + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], [ ["cookies", "https://sectest1.example.org"], [ getCookieId("cs2", ".example.org", "/"), + getCookieId("c4", ".example.org", "/"), getCookieId("sc1", "sectest1.example.org", "/browser/devtools/client/storage/test/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("sc2", "sectest1.example.org", + "/browser/devtools/client/storage/test/"), + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], ]); @@ -64,7 +78,7 @@ add_task(function* () { info("delete all from domain"); // delete only cookies that match the host exactly let id = getCookieId("c1", "test1.example.org", "/browser"); - yield performDelete(["cookies", "http://test1.example.org"], id, false); + yield performDelete(["cookies", "http://test1.example.org"], id, "deleteAllFrom"); info("test state after delete all from domain"); yield checkState([ @@ -73,24 +87,57 @@ add_task(function* () { ["cookies", "http://test1.example.org"], [ getCookieId("cs2", ".example.org", "/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("c4", ".example.org", "/"), + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], [ ["cookies", "https://sectest1.example.org"], [ getCookieId("cs2", ".example.org", "/"), + getCookieId("c4", ".example.org", "/"), getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/"), getCookieId("sc1", "sectest1.example.org", "/browser/devtools/client/storage/test/"), + getCookieId("sc2", "sectest1.example.org", + "/browser/devtools/client/storage/test/") + ] + ], + ]); + + info("delete all session cookies"); + // delete only session cookies + id = getCookieId("cs2", ".example.org", "/"); + yield performDelete(["cookies", "http://sectest1.example.org"], id, + "deleteAllSessionCookies"); + + info("test state after delete all session cookies"); + yield checkState([ + // Cookies with expiry date must not be deleted. + [ + ["cookies", "http://test1.example.org"], + [ + getCookieId("c4", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") + ] + ], + [ + ["cookies", "https://sectest1.example.org"], + [ + getCookieId("c4", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/"), + getCookieId("sc2", "sectest1.example.org", + "/browser/devtools/client/storage/test/") ] ], ]); info("delete all"); // delete all cookies for host, including domain cookies - id = getCookieId("uc1", ".example.org", "/"); - yield performDelete(["cookies", "http://sectest1.example.org"], id, true); + id = getCookieId("uc2", ".example.org", "/"); + yield performDelete(["cookies", "http://sectest1.example.org"], id, "deleteAll"); info("test state after delete all"); yield checkState([ diff --git a/devtools/client/storage/test/browser_storage_delete_tree.js b/devtools/client/storage/test/browser_storage_delete_tree.js index bc501ede9470..6705dba8a426 100644 --- a/devtools/client/storage/test/browser_storage_delete_tree.js +++ b/devtools/client/storage/test/browser_storage_delete_tree.js @@ -23,7 +23,9 @@ add_task(function* () { getCookieId("c1", "test1.example.org", "/browser"), getCookieId("cs2", ".example.org", "/"), getCookieId("c3", "test1.example.org", "/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("c4", ".example.org", "/"), + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], [["localStorage", "http://test1.example.org"], ["ls1", "ls2"]], diff --git a/devtools/client/storage/test/browser_storage_delete_usercontextid.js b/devtools/client/storage/test/browser_storage_delete_usercontextid.js index 2fce3341d567..b2d05d7b49dc 100644 --- a/devtools/client/storage/test/browser_storage_delete_usercontextid.js +++ b/devtools/client/storage/test/browser_storage_delete_usercontextid.js @@ -32,15 +32,22 @@ const storageItemsForDefault = [ getCookieId("c1", "test1.example.org", "/browser"), getCookieId("cs2", ".example.org", "/"), getCookieId("c3", "test1.example.org", "/"), - getCookieId("uc1", ".example.org", "/") + getCookieId("c4", ".example.org", "/"), + getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/") ] ], [ ["cookies", "https://sectest1.example.org"], [ getCookieId("uc1", ".example.org", "/"), + getCookieId("uc2", ".example.org", "/"), getCookieId("cs2", ".example.org", "/"), - getCookieId("sc1", "sectest1.example.org", "/browser/devtools/client/storage/test/") + getCookieId("c4", ".example.org", "/"), + getCookieId("sc1", "sectest1.example.org", + "/browser/devtools/client/storage/test/"), + getCookieId("sc2", "sectest1.example.org", + "/browser/devtools/client/storage/test/") ] ], [["localStorage", "http://test1.example.org"], diff --git a/devtools/client/storage/test/storage-listings.html b/devtools/client/storage/test/storage-listings.html index 991ab22d922d..d50c9b5514ab 100644 --- a/devtools/client/storage/test/storage-listings.html +++ b/devtools/client/storage/test/storage-listings.html @@ -20,7 +20,10 @@ document.cookie = "c1=foobar; expires=" + new Date(cookieExpiresTime1).toGMTString() + "; path=/browser"; document.cookie = "cs2=sessionCookie; path=/; domain=" + partialHostname; document.cookie = "c3=foobar-2; expires=" + - new Date(cookieExpiresTime2).toGMTString() + "; path=/"; + new Date(cookieExpiresTime1).toGMTString() + "; path=/"; +document.cookie = "c4=foobar-3; expires=" + + new Date(cookieExpiresTime2).toGMTString() + "; path=/; domain=" + + partialHostname; // ... and some local storage items .. localStorage.setItem("ls1", "foobar"); localStorage.setItem("ls2", "foobar-2"); diff --git a/devtools/client/storage/test/storage-secured-iframe.html b/devtools/client/storage/test/storage-secured-iframe.html index f2c8c59413ab..ea830847ab37 100644 --- a/devtools/client/storage/test/storage-secured-iframe.html +++ b/devtools/client/storage/test/storage-secured-iframe.html @@ -9,7 +9,10 @@ Iframe for testing multiple host detetion in storage actor