зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1638831 - Clean up the test for clearStoragesForOriginAttributesPattern(); r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D75786
This commit is contained in:
Родитель
da52584dcb
Коммит
99503e97e8
|
@ -1,53 +0,0 @@
|
|||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
const origins = [
|
||||
{
|
||||
origin: "https://example.com",
|
||||
attribute: { userContextId: 1 },
|
||||
path: "https+++example.com^userContextId=1",
|
||||
},
|
||||
{
|
||||
origin: "https://example.com",
|
||||
attribute: { userContextId: 2 },
|
||||
path: "https+++example.com^userContextId=2",
|
||||
},
|
||||
];
|
||||
|
||||
let request;
|
||||
for (let origin of origins) {
|
||||
request = initStorageAndOrigin(
|
||||
getPrincipal(origin.origin, origin.attribute),
|
||||
"default"
|
||||
);
|
||||
await requestFinished(request);
|
||||
}
|
||||
|
||||
const path = "storage/default/";
|
||||
for (let origin of origins) {
|
||||
let originDir = getRelativeFile(path + origin.path);
|
||||
ok(originDir.exists(), "Origin directory should have been created");
|
||||
}
|
||||
|
||||
const removingId = 2;
|
||||
await new Promise(function(aResolve) {
|
||||
Services.clearData.deleteDataFromOriginAttributesPattern(
|
||||
{
|
||||
userContextId: removingId,
|
||||
},
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
for (let origin of origins) {
|
||||
let originDir = getRelativeFile(path + origin.path);
|
||||
if (origin.attribute.userContextId === removingId) {
|
||||
ok(!originDir.exists(), "Origin directory should have been removed");
|
||||
} else {
|
||||
ok(originDir.exists(), "Origin directory shouldn't have been removed");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,9 +25,9 @@ support-files =
|
|||
[test_basics.js]
|
||||
[test_bad_origin_directory.js]
|
||||
[test_caching_groupMismatch.js]
|
||||
[test_clearOriginAttributesData.js]
|
||||
[test_createLocalStorage.js]
|
||||
[test_clearStorageForPrincipal.js]
|
||||
[test_clearStoragesForOriginAttributesPattern.js]
|
||||
[test_getUsage.js]
|
||||
[test_groupMismatch.js]
|
||||
[test_initTemporaryStorage.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче