diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js')
-rw-r--r-- | dom/quota/test/xpcshell/test_clearStoragesForOriginAttributesPattern.js | 58 |
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"); + } + } +} |