summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/xpcshell/test_clearStoragesForOriginPrefix.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/quota/test/xpcshell/test_clearStoragesForOriginPrefix.js')
-rw-r--r--dom/quota/test/xpcshell/test_clearStoragesForOriginPrefix.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/dom/quota/test/xpcshell/test_clearStoragesForOriginPrefix.js b/dom/quota/test/xpcshell/test_clearStoragesForOriginPrefix.js
new file mode 100644
index 0000000000..161dd9722c
--- /dev/null
+++ b/dom/quota/test/xpcshell/test_clearStoragesForOriginPrefix.js
@@ -0,0 +1,72 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/**
+ * This test is mainly to verify clearing by origin prefix.
+ */
+
+async function testSteps() {
+ const packages = [
+ "clearStoragesForOriginPrefix_profile",
+ "defaultStorageDirectory_shared",
+ ];
+
+ const testData = [
+ {
+ origin: "http://example.com",
+ persistence: null,
+ key: "afterClearByOriginPrefix",
+ },
+ {
+ origin: "http://example.com",
+ persistence: "default",
+ key: "afterClearByOriginPrefix_default",
+ },
+ {
+ origin: "http://example.com",
+ persistence: "persistent",
+ key: "afterClearByOriginPrefix_persistent",
+ },
+ {
+ origin: "http://example.com",
+ persistence: "temporary",
+ key: "afterClearByOriginPrefix_temporary",
+ },
+ ];
+
+ for (const item of testData) {
+ info("Clearing");
+
+ let request = clear();
+ await requestFinished(request);
+
+ info("Verifying storage");
+
+ verifyStorage(packages, "beforeInstall");
+
+ info("Installing package");
+
+ installPackages(packages);
+
+ info("Verifying storage");
+
+ verifyStorage(packages, "afterInstall");
+
+ // TODO: Remove this block once origin clearing is able to ignore unknown
+ // directories.
+ getRelativeFile("storage/default/invalid+++example.com").remove(false);
+ getRelativeFile("storage/permanent/invalid+++example.com").remove(false);
+ getRelativeFile("storage/temporary/invalid+++example.com").remove(false);
+
+ info("Clearing origin by prefix");
+
+ request = clearOriginsByPrefix(getPrincipal(item.origin), item.persistence);
+ await requestFinished(request);
+
+ info("Verifying storage");
+
+ verifyStorage(packages, item.key, "afterClearByOriginPrefix");
+ }
+}