Bug 1746952 - [devtools] Acknowledge the distinct storage resource for each target in browser_storage_dynamic_windows.js. r=nchevobbe

This test was brittle as it was assuming that only one resource was notified per storage type.
But this wasn't the case since fission or EFT!
We were lucky that the assertion were correct only against the latest resource
and not against the aggregate of the many resource (one per target).

Differential Revision: https://phabricator.services.mozilla.com/D134376
This commit is contained in:
Alexandre Poirot 2021-12-22 09:59:08 +00:00
Родитель efbcfe5c99
Коммит 589bdcc457
1 изменённых файлов: 24 добавлений и 5 удалений

Просмотреть файл

@ -94,7 +94,12 @@ add_task(async function() {
const allResources = {};
const onAvailable = resources => {
for (const resource of resources) {
allResources[resource.resourceType] = resource;
// Because we have iframes, we have distinct targets, each spawning their own storage resource
if (allResources[resource.resourceType]) {
allResources[resource.resourceType].push(resource);
} else {
allResources[resource.resourceType] = [resource];
}
}
};
const parentProcessStorages = [TYPES.COOKIE, TYPES.INDEXED_DB];
@ -134,20 +139,31 @@ function testWindowsBeforeReload(resources) {
for (const storageType in beforeReload) {
ok(resources[storageType], `${storageType} storage actor is present`);
const hosts = {};
for (const resource of resources[storageType]) {
for (const [hostType, hostValues] of Object.entries(resource.hosts)) {
if (!hosts[hostType]) {
hosts[hostType] = [];
}
hosts[hostType].push(hostValues);
}
}
// If this test is run with chrome debugging enabled we get an extra
// key for "chrome". We don't want the test to fail in this case, so
// ignore it.
if (storageType == "indexedDB") {
delete resources[storageType].hosts.chrome;
delete hosts.chrome;
}
is(
Object.keys(resources[storageType].hosts).length,
Object.keys(hosts).length,
Object.keys(beforeReload[storageType]).length,
`Number of hosts for ${storageType} match`
);
for (const host in beforeReload[storageType]) {
ok(resources[storageType].hosts[host], `Host ${host} is present`);
ok(hosts[host], `Host ${host} is present`);
}
}
}
@ -206,7 +222,10 @@ function waitForResourceUpdates(resources, resourceTypes) {
const allUpdates = {};
const promises = [];
for (const type of resourceTypes) {
const promise = resources[type].once("single-store-update");
// Resolves once any of the many resources for the given storage type updates
const promise = Promise.any(
resources[type].map(resource => resource.once("single-store-update"))
);
promise.then(update => {
ok(true, `Got updates for ${type}`);
allUpdates[type] = update;