summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js')
-rw-r--r--dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js b/dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js
new file mode 100644
index 0000000000..096cf2be70
--- /dev/null
+++ b/dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js
@@ -0,0 +1,58 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+async function testSteps() {
+ const baseRelativePath = "storage/default";
+ const userContextForRemoval = 2;
+
+ const origins = [
+ {
+ userContextId: 1,
+ baseDirName: "https+++example.com",
+ },
+
+ {
+ userContextId: userContextForRemoval,
+ baseDirName: "https+++example.com",
+ },
+
+ // TODO: Uncomment this once bug 1638831 is fixed.
+ /*
+ {
+ userContextId: userContextForRemoval,
+ baseDirName: "https+++example.org",
+ },
+ */
+ ];
+
+ function getOriginDirectory(origin) {
+ return getRelativeFile(
+ `${baseRelativePath}/${origin.baseDirName}^userContextId=` +
+ `${origin.userContextId}`
+ );
+ }
+
+ let request = init();
+ await requestFinished(request);
+
+ for (const origin of origins) {
+ const directory = getOriginDirectory(origin);
+ directory.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0755", 8));
+ }
+
+ request = Services.qms.clearStoragesForOriginAttributesPattern(
+ `{ "userContextId": ${userContextForRemoval} }`
+ );
+ await requestFinished(request);
+
+ for (const origin of origins) {
+ const directory = getOriginDirectory(origin);
+ if (origin.userContextId === userContextForRemoval) {
+ ok(!directory.exists(), "Origin directory should have been removed");
+ } else {
+ ok(directory.exists(), "Origin directory shouldn't have been removed");
+ }
+ }
+}