moebius#337: Added option to remove all session cookies for a specific domain

Issue #31
https://github.com/MoonchildProductions/moebius/pull/337
This commit is contained in:
janekptacijarabaci 2018-03-02 16:38:25 +01:00 committed by Roy Tam
commit e688e88257
11 changed files with 186 additions and 34 deletions

View file

@ -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", "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"],

View file

@ -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", "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,6 +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", "test1.example.org"], id, "deleteAllFrom");
yield performDelete(["cookies", "test1.example.org"], id, false);
info("test state after delete all from domain");
@ -73,24 +88,57 @@ add_task(function* () {
["cookies", "test1.example.org"],
[
getCookieId("cs2", ".example.org", "/"),
getCookieId("uc1", ".example.org", "/")
getCookieId("c4", ".example.org", "/"),
getCookieId("uc1", ".example.org", "/"),
getCookieId("uc2", ".example.org", "/")
]
],
[
["cookies", "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", "sectest1.example.org"], id,
"deleteAllSessionCookies");
info("test state after delete all session cookies");
yield checkState([
// Cookies with expiry date must not be deleted.
[
["cookies", "test1.example.org"],
[
getCookieId("c4", ".example.org", "/"),
getCookieId("uc2", ".example.org", "/")
]
],
[
["cookies", "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", "sectest1.example.org"], id, true);
id = getCookieId("uc2", ".example.org", "/");
yield performDelete(["cookies", "sectest1.example.org"], id, "deleteAll");
info("test state after delete all");
yield checkState([

View file

@ -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"]],

View file

@ -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");

View file

@ -1,4 +1,4 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
Iframe for testing multiple host detetion in storage actor
@ -9,7 +9,10 @@ Iframe for testing multiple host detetion in storage actor
<body>
<script type="application/javascript;version=1.7">
"use strict";
let cookieExpiresTime = 2000000000000;
document.cookie = "sc1=foobar;";
document.cookie = "sc2=foobar-2; expires=" +
new Date(cookieExpiresTime).toGMTString() + ";";
localStorage.setItem("iframe-s-ls1", "foobar");
sessionStorage.setItem("iframe-s-ss1", "foobar-2");
dump("added cookies and storage from secured iframe\n");

View file

@ -9,7 +9,10 @@ Iframe for testing multiple host detetion in storage actor
<body>
<script>
"use strict";
let cookieExpiresTime = 2000000000000;
document.cookie = "uc1=foobar; domain=.example.org; path=/";
document.cookie = "uc2=foobar-2; expires=" +
new Date(cookieExpiresTime).toGMTString() + "; path=/; domain=.example.org";
localStorage.setItem("iframe-u-ls1", "foobar");
sessionStorage.setItem("iframe-u-ss1", "foobar1");
sessionStorage.setItem("iframe-u-ss2", "foobar2");