Bug 1655016 - Do not assume any resource order in browser_resources_stylesheets.js r=daisuke

Differential Revision: https://phabricator.services.mozilla.com/D86254
This commit is contained in:
Julian Descottes 2020-08-07 06:08:27 +00:00
Родитель fa78c8a983
Коммит e57c2589f9
1 изменённых файлов: 13 добавлений и 2 удалений

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

@ -80,9 +80,12 @@ add_task(async function() {
EXISTING_RESOURCES.length,
"Length of existing resources is correct"
);
for (let i = 0; i < EXISTING_RESOURCES.length; i++) {
for (let i = 0; i < availableResources.length; i++) {
const availableResource = availableResources[i];
const expectedResource = EXISTING_RESOURCES[i];
// We can not expect the resources to always be forwarded in the same order.
// See intermittent Bug 1655016.
const expectedResource = findMatchingExpectedResource(availableResource);
ok(expectedResource, "Found a matching expected resource for the resource");
await assertResource(availableResource, expectedResource);
}
@ -132,6 +135,14 @@ add_task(async function() {
await client.close();
});
function findMatchingExpectedResource(resource) {
return EXISTING_RESOURCES.find(
expected =>
resource.styleSheet.href === expected.href &&
resource.styleSheet.nodeHref === expected.nodeHref
);
}
async function assertResource(resource, expected) {
const { resourceType, styleSheet, isNew } = resource;
is(