зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1686727 - [devtools] Migrate browser_storage_cookies-duplicate-names to ResourceCommand. r=ladybenko
We should stop using StorageActor.listStores in favor of ResourceCommand. listStores still forces to involve message manager in the server codebase. This breaks when we enable JSWindowActor based targets. Differential Revision: https://phabricator.services.mozilla.com/D116482
This commit is contained in:
Родитель
6ae68db282
Коммит
68dc58276a
|
@ -45,11 +45,38 @@ const TESTDATA = {
|
|||
};
|
||||
|
||||
add_task(async function() {
|
||||
const { target, front } = await openTabAndSetupStorage(
|
||||
const { commands } = await openTabAndSetupStorage(
|
||||
MAIN_DOMAIN + "storage-cookies-same-name.html"
|
||||
);
|
||||
|
||||
const data = await front.listStores();
|
||||
const { resourceCommand } = commands;
|
||||
const { TYPES } = resourceCommand;
|
||||
const data = {};
|
||||
await resourceCommand.watchResources(
|
||||
[TYPES.COOKIE, TYPES.LOCAL_STORAGE, TYPES.SESSION_STORAGE],
|
||||
{
|
||||
async onAvailable(resources) {
|
||||
for (const resource of resources) {
|
||||
const { resourceType } = resource;
|
||||
if (!data[resourceType]) {
|
||||
data[resourceType] = { hosts: {}, dataByHost: {} };
|
||||
}
|
||||
|
||||
for (const host in resource.hosts) {
|
||||
if (!data[resourceType].hosts[host]) {
|
||||
data[resourceType].hosts[host] = [];
|
||||
}
|
||||
// For indexed DB, we have some values, the database names. Other are empty arrays.
|
||||
const hostValues = resource.hosts[host];
|
||||
data[resourceType].hosts[host].push(...hostValues);
|
||||
data[resourceType].dataByHost[
|
||||
host
|
||||
] = await resource.getStoreObjects(host);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
ok(data.cookies, "Cookies storage actor is present");
|
||||
|
||||
|
@ -58,21 +85,19 @@ add_task(async function() {
|
|||
|
||||
// Forcing GC/CC to get rid of docshells and windows created by this test.
|
||||
forceCollections();
|
||||
await target.destroy();
|
||||
forceCollections();
|
||||
DevToolsServer.destroy();
|
||||
await commands.destroy();
|
||||
forceCollections();
|
||||
});
|
||||
|
||||
function testCookies(cookiesActor) {
|
||||
const numHosts = Object.keys(cookiesActor.hosts).length;
|
||||
function testCookies({ hosts, dataByHost }) {
|
||||
const numHosts = Object.keys(hosts).length;
|
||||
is(numHosts, 1, "Correct number of host entries for cookies");
|
||||
return testCookiesObjects(0, cookiesActor.hosts, cookiesActor);
|
||||
return testCookiesObjects(0, hosts, dataByHost);
|
||||
}
|
||||
|
||||
var testCookiesObjects = async function(index, hosts, cookiesActor) {
|
||||
var testCookiesObjects = async function(index, hosts, dataByHost) {
|
||||
const host = Object.keys(hosts)[index];
|
||||
const matchItems = data => {
|
||||
const data = dataByHost[host];
|
||||
is(
|
||||
data.total,
|
||||
TESTDATA[host].length,
|
||||
|
@ -99,12 +124,10 @@ var testCookiesObjects = async function(index, hosts, cookiesActor) {
|
|||
}
|
||||
ok(found, "cookie " + item.name + " should exist in response");
|
||||
}
|
||||
};
|
||||
|
||||
ok(!!TESTDATA[host], "Host is present in the list : " + host);
|
||||
matchItems(await cookiesActor.getStoreObjects(host));
|
||||
if (index == Object.keys(hosts).length - 1) {
|
||||
return;
|
||||
}
|
||||
await testCookiesObjects(++index, hosts, cookiesActor);
|
||||
await testCookiesObjects(++index, hosts, dataByHost);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче