commit c646e9ada6003586e1db02452f6918c5b18c7297
parent 2dab79985c54f7fe8fc908a2f2f0e903200b48aa
Author: Andrea Marchesini <amarchesini@mozilla.com>
Date: Sat, 1 Nov 2025 10:02:52 +0000
Bug 1995748 - Add cookie update time column in the storage devtool view, r=devtools-reviewers,fluent-reviewers,devtools-backward-compat-reviewers,nchevobbe,bolsson
Differential Revision: https://phabricator.services.mozilla.com/D270830
Diffstat:
6 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/devtools/client/locales/en-US/storage.ftl b/devtools/client/locales/en-US/storage.ftl
@@ -87,6 +87,7 @@ storage-table-headers-cookies-expires = Expires / Max-Age
storage-table-headers-cookies-size = Size
storage-table-headers-cookies-last-accessed = Last Accessed
storage-table-headers-cookies-creation-time = Created
+storage-table-headers-cookies-update-time = Updated
storage-table-headers-cache-status = Status
storage-table-headers-extension-storage-area = Storage Area
diff --git a/devtools/client/storage/test/browser_storage_cookies_add.js b/devtools/client/storage/test/browser_storage_cookies_add.js
@@ -44,13 +44,30 @@ function checkCookieData(rowId) {
new Date(getCellValue(rowId, "expires")) / 1000
);
const ONE_DAY_IN_SECONDS = 60 * 60 * 24;
- const time = Math.floor(new Date(getCellValue(rowId, "creationTime")) / 1000);
- const expectedExpiry = time + ONE_DAY_IN_SECONDS;
+
+ const creationTime = Math.floor(
+ new Date(getCellValue(rowId, "creationTime")) / 1000
+ );
+ Assert.lessOrEqual(
+ actualExpiry - (creationTime + ONE_DAY_IN_SECONDS),
+ 2,
+ "expiry is in expected range"
+ );
+
+ const updateTime = Math.floor(
+ new Date(getCellValue(rowId, "updateTime")) / 1000
+ );
+ Assert.equal(
+ creationTime,
+ updateTime,
+ "Update time matches the creation time"
+ );
Assert.lessOrEqual(
- actualExpiry - expectedExpiry,
+ actualExpiry - (updateTime + ONE_DAY_IN_SECONDS),
2,
"expiry is in expected range"
);
+
is(getCellValue(rowId, "size"), "43", "size is correct");
is(getCellValue(rowId, "isHttpOnly"), "false", "httpOnly is not set");
is(getCellValue(rowId, "isSecure"), "false", "secure is not set");
diff --git a/devtools/client/storage/ui.js b/devtools/client/storage/ui.js
@@ -69,6 +69,7 @@ const HEADERS_L10N_IDS = {
},
cookies: {
creationTime: "storage-table-headers-cookies-creation-time",
+ updateTime: "storage-table-headers-cookies-update-time",
expires: "storage-table-headers-cookies-expires",
lastAccessed: "storage-table-headers-cookies-last-accessed",
name: "storage-table-headers-cookies-name",
@@ -350,6 +351,7 @@ class StorageUI {
"storage-table-headers-cookies-size",
"storage-table-headers-cookies-last-accessed",
"storage-table-headers-cookies-creation-time",
+ "storage-table-headers-cookies-update-time",
"storage-table-headers-cache-status",
"storage-table-headers-extension-storage-area",
"storage-tree-labels-cookies",
@@ -1388,6 +1390,9 @@ class StorageUI {
if (item.creationTime != null) {
item.creationTime = new Date(item.creationTime).toUTCString();
}
+ if (item.updateTime != null) {
+ item.updateTime = new Date(item.updateTime).toUTCString();
+ }
if (item.lastAccessed != null) {
item.lastAccessed = new Date(item.lastAccessed).toUTCString();
}
diff --git a/devtools/client/themes/storage.css b/devtools/client/themes/storage.css
@@ -85,6 +85,7 @@ a {
#expires,
#lastAccessed,
+#updateTime,
#creationTime {
min-width: 115px;
}
diff --git a/devtools/server/actors/resources/storage/cookies.js b/devtools/server/actors/resources/storage/cookies.js
@@ -230,6 +230,9 @@ class CookiesStorageActor extends BaseStorageActor {
// because creationTime is in micro seconds
creationTime: cookie.creationTime / 1000,
+ // because updateTime is in micro seconds
+ updateTime: cookie.updateTime / 1000,
+
size: cookie.name.length + (cookie.value || "").length,
// - do -
@@ -362,6 +365,7 @@ class CookiesStorageActor extends BaseStorageActor {
{ name: "sameSite", editable: false, hidden: false },
{ name: "lastAccessed", editable: false, hidden: false },
{ name: "creationTime", editable: false, hidden: true },
+ { name: "updateTime", editable: false, hidden: true },
{ name: "hostOnly", editable: false, hidden: true },
];
@@ -474,6 +478,7 @@ class CookiesStorageActor extends BaseStorageActor {
* host: ".mozilla.org",
* expires: "Mon, 02 Jun 2025 12:37:37 GMT",
* creationTime: "Tue, 18 Nov 2014 16:21:18 GMT",
+ * updateTime: "Tue, 18 Nov 2014 16:21:18 GMT",
* lastAccessed: "Wed, 17 Feb 2016 10:06:23 GMT",
* value: "%7BHelloo%7D",
* isDomain: "true",
diff --git a/devtools/shared/specs/storage.js b/devtools/shared/specs/storage.js
@@ -59,6 +59,7 @@ types.addDictType("cookieobject", {
isSecure: "boolean",
isHttpOnly: "boolean",
creationTime: "number",
+ updateTime: "number",
lastAccessed: "number",
expires: "number",
});