summaryrefslogtreecommitdiffstats
path: root/devtools/client/storage/test/browser_storage_cache_navigation.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_cache_navigation.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_cache_navigation.js')
-rw-r--r--devtools/client/storage/test/browser_storage_cache_navigation.js84
1 files changed, 84 insertions, 0 deletions
diff --git a/devtools/client/storage/test/browser_storage_cache_navigation.js b/devtools/client/storage/test/browser_storage_cache_navigation.js
new file mode 100644
index 0000000000..5421b85028
--- /dev/null
+++ b/devtools/client/storage/test/browser_storage_cache_navigation.js
@@ -0,0 +1,84 @@
+/* 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/. */
+
+"use strict";
+
+add_task(async function () {
+ const URL1 = buildURLWithContent(
+ "example.com",
+ `<h1>example.com</h1>` +
+ `<script>
+ caches.open("lorem").then(cache => {
+ cache.add("${URL_ROOT_COM_SSL}storage-blank.html");
+ });
+ function clear() {
+ caches.delete("lorem");
+ }
+ </script>`
+ );
+ const URL2 = buildURLWithContent(
+ "example.net",
+ `<h1>example.net</h1>` +
+ `<script>
+ caches.open("foo").then(cache => {
+ cache.add("${URL_ROOT_NET_SSL}storage-blank.html");
+ });
+ function clear() {
+ caches.delete("foo");
+ }
+ </script>`
+ );
+
+ // open tab
+ await openTabAndSetupStorage(URL1);
+ const doc = gPanelWindow.document;
+
+ // Check first domain
+ // check that host appears in the storage tree
+ checkTree(doc, ["Cache", "https://example.com", "lorem"]);
+ // check the table for values
+ await selectTreeItem(["Cache", "https://example.com", "lorem"]);
+ checkCacheData(URL_ROOT_COM_SSL + "storage-blank.html", "OK");
+
+ // clear up the cache before navigating
+ info("Cleaning up cache…");
+ await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
+ const win = content.wrappedJSObject;
+ await win.clear();
+ });
+
+ // Check second domain
+ await navigateTo(URL2);
+
+ // Select the Cache view in order to force updating it
+ await selectTreeItem(["Cache", "https://example.net"]);
+
+ // wait for storage tree refresh, and check host
+ info("Waiting for storage tree to update…");
+ await waitUntil(() => isInTree(doc, ["Cache", "https://example.net", "foo"]));
+
+ ok(
+ !isInTree(doc, ["Cache", "https://example.com"]),
+ "example.com item is not in the tree anymore"
+ );
+
+ // check the table for values
+ await selectTreeItem(["Cache", "https://example.net", "foo"]);
+ checkCacheData(URL_ROOT_NET_SSL + "storage-blank.html", "OK");
+
+ info("Check that the Cache node still has the expected label");
+ is(
+ getTreeNodeLabel(doc, ["Cache"]),
+ "Cache Storage",
+ "Cache item is properly displayed"
+ );
+});
+
+function checkCacheData(url, status) {
+ is(
+ gUI.table.items.get(url)?.status,
+ status,
+ `Table row has an entry for: ${url} with status: ${status}`
+ );
+}