Bug 1466929 - Fix intermittent issues in browser_bookmarkProperties_remember_folders.js. draft
authorMark Banner <standard8@mozilla.com>
Wed, 06 Jun 2018 11:48:05 +0100
changeset 804659 604d1351f6ac3d83ac2331bc3ee8ca02d952e2b3
parent 804493 da28b92efe6f6acaf79545697415b82038143338
push id112425
push userbmo:standard8@mozilla.com
push dateWed, 06 Jun 2018 10:50:29 +0000
bugs1466929
milestone62.0a1
Bug 1466929 - Fix intermittent issues in browser_bookmarkProperties_remember_folders.js. MozReview-Commit-ID: 3QhatMWMDvQ
browser/components/places/tests/browser/browser_bookmarkProperties_remember_folders.js
--- 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();