summaryrefslogtreecommitdiffstats
path: root/devtools/client/storage/test/browser_storage_cookies_sort.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /devtools/client/storage/test/browser_storage_cookies_sort.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/storage/test/browser_storage_cookies_sort.js')
-rw-r--r--devtools/client/storage/test/browser_storage_cookies_sort.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/devtools/client/storage/test/browser_storage_cookies_sort.js b/devtools/client/storage/test/browser_storage_cookies_sort.js
new file mode 100644
index 0000000000..2b4316af53
--- /dev/null
+++ b/devtools/client/storage/test/browser_storage_cookies_sort.js
@@ -0,0 +1,64 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Test column sorting works and sorts dates correctly (including "session"
+// cookies).
+
+"use strict";
+
+add_task(async function () {
+ const TEST_URL = MAIN_DOMAIN + "storage-cookies-sort.html";
+ await openTabAndSetupStorage(TEST_URL);
+ showAllColumns(true);
+
+ info("Sort on the expires column, ascending order");
+ clickColumnHeader("expires");
+
+ // Note that here we only specify `test_session` for `test_session1` and
+ // `test_session2`. Since we sort on the "expires" column, there is no point
+ // in asserting the order between those 2 items.
+ checkCells([
+ "test_session",
+ "test_session",
+ "test_hour",
+ "test_day",
+ "test_year",
+ ]);
+
+ info("Sort on the expires column, descending order");
+ clickColumnHeader("expires");
+
+ // Again, only assert `test_session` for `test_session1` and `test_session2`.
+ checkCells([
+ "test_year",
+ "test_day",
+ "test_hour",
+ "test_session",
+ "test_session",
+ ]);
+
+ info("Sort on the name column, ascending order");
+ clickColumnHeader("name");
+ checkCells([
+ "test_day",
+ "test_hour",
+ "test_session1",
+ "test_session2",
+ "test_year",
+ ]);
+});
+
+function checkCells(expected) {
+ const cells = [
+ ...gPanelWindow.document.querySelectorAll("#name .table-widget-cell"),
+ ];
+ cells.forEach(function (cell, i, arr) {
+ // We use startsWith in order to avoid asserting the relative order of
+ // "session" cookies when sorting on the "expires" column.
+ ok(
+ cell.value.startsWith(expected[i]),
+ `Cell value starts with "${expected[i]}".`
+ );
+ });
+}