Skip to content

Commit

Permalink
Bug 1790105 - Fix test_permmanager_getAllByTypes.js intermittent fail…
Browse files Browse the repository at this point in the history
…ures. r=pbz.

It seems that getAllByTypes results aren't in a stable order when
the test is run with --verify.

Differential Revision: https://phabricator.services.mozilla.com/D157120
  • Loading branch information
nchevobbe committed Sep 13, 2022
1 parent c3f891b commit e6e58c9
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions extensions/permissions/test/unit/test_permmanager_getAllByTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ function check_enumerator(permissionTypes, expectedPermissions) {
)}`
);

permissions.forEach((perm, i) => {
info(`Checking permission #${i}`);
const [
expectedPrincipal,
expectedType,
expectedCapability,
] = expectedPermissions[i];

for (const perm of permissions) {
Assert.ok(perm != null);
Assert.ok(perm.principal.equals(expectedPrincipal));
Assert.equal(perm.type, expectedType);
Assert.equal(perm.capability, expectedCapability);

// For some reason, the order in which we get the permissions doesn't seem to be
// stable when running the test with --verify. As a result, we need to retrieve the
// expected permission for the origin and type.
const expectedPermission = expectedPermissions.find(
([expectedPrincipal, expectedType]) =>
perm.principal.equals(expectedPrincipal) && perm.type === expectedType
);

Assert.ok(expectedPermission !== null, "Found the expected permission");
Assert.equal(perm.capability, expectedPermission[2]);
Assert.equal(perm.expireType, Services.perms.EXPIRE_NEVER);
});
}
}

function run_test() {
Expand Down

0 comments on commit e6e58c9

Please sign in to comment.