Bug 1681302 - Poll for identity-popup-geo-container to be populated to fix intermittent failures. r=nhnt11

Differential Revision: https://phabricator.services.mozilla.com/D99231
This commit is contained in:
Paul Zuehlcke 2020-12-15 15:52:02 +00:00
parent fe922a75e5
commit 1534629245

View file

@ -3,6 +3,8 @@
"use strict";
requestLongerTimeout(2);
ChromeUtils.import("resource:///modules/PermissionUI.jsm", this);
ChromeUtils.import("resource:///modules/SitePermissions.jsm", this);
const { PermissionTestUtils } = ChromeUtils.import(
@ -66,6 +68,12 @@ async function testIdentityPopupGeoContainer(
containerVisible,
timestampVisible
) {
// The container holds the timestamp element, therefore we can't have a
// visible timestamp without the container.
if (timestampVisible && !containerVisible) {
ok(false, "Can't have timestamp without container");
}
// Only call openIdentityPopup if popup is closed, otherwise it does not resolve
if (!gIdentityHandler._identityBox.hasAttribute("open")) {
await openIdentityPopup();
@ -74,11 +82,14 @@ async function testIdentityPopupGeoContainer(
let checkContainer = checkForDOMElement(
containerVisible,
"identity-popup-geo-container"
).then(container => {
);
if (containerVisible && timestampVisible) {
is(
container.childElementCount,
2,
// Wait for the geo container to be fully populated.
// The time label is computed async.
let container = await checkContainer;
await BrowserTestUtils.waitForCondition(
() => container.childElementCount == 2,
"identity-popup-geo-container should have two elements."
);
is(
@ -92,7 +103,6 @@ async function testIdentityPopupGeoContainer(
"Geo container should have indicator item."
);
}
});
let checkAccessIndicator = checkForDOMElement(
timestampVisible,
"geo-access-indicator-item"