Bug 1466929 - Fix intermittent issues in browser_bookmarkProperties_remember_folders.js.
MozReview-Commit-ID: 3QhatMWMDvQ
--- a/browser/components/places/tests/browser/browser_bookmarkProperties_remember_folders.js
+++ b/browser/components/places/tests/browser/browser_bookmarkProperties_remember_folders.js
@@ -27,21 +27,26 @@ async function hideBookmarksPanel() {
async function openPopupAndSelectFolder(guid) {
await clickBookmarkStar();
// Expand the folder tree.
document.getElementById("editBMPanel_foldersExpander").click();
document.getElementById("editBMPanel_folderTree").selectItems([guid]);
await hideBookmarksPanel();
- // Ensure the meta data has had chance to be written to disk.
- await PlacesTestUtils.promiseAsyncUpdates();
}
async function assertRecentFolders(expectedGuids, msg) {
+ // Give the metadata chance to be written to the database before we attempt
+ // to open the dialog again.
+ await TestUtils.waitForCondition(async () => {
+ let guids = await PlacesUtils.metadata.get(PlacesUIUtils.LAST_USED_FOLDERS_META_KEY, []);
+ return guids.length == expectedGuids.length;
+ }, msg);
+
await clickBookmarkStar();
let actualGuids = [];
function getGuids() {
const folderMenuPopup = document.getElementById("editBMPanel_folderMenuList").children[0];
let separatorFound = false;
// The list of folders goes from editBMPanel_foldersSeparator to the end.
@@ -49,16 +54,18 @@ async function assertRecentFolders(expec
if (separatorFound) {
actualGuids.push(child.folderGuid);
} else if (child.id == "editBMPanel_foldersSeparator") {
separatorFound = true;
}
}
}
+ // The dialog fills in the folder list asnychronously, so we might need to wait
+ // for that to complete.
await TestUtils.waitForCondition(() => {
getGuids();
return actualGuids.length == expectedGuids.length;
}, msg);
Assert.deepEqual(actualGuids, expectedGuids, msg);
await hideBookmarksPanel();