Bug 1319328 - Wait for pending statements before checking annos in test_mobile_query. a=testonly
authorKit Cambridge <kit@yakshaving.ninja>
Tue, 29 Nov 2016 13:13:20 -0700
changeset 324948 a5a5b7e56cba2f5e641943c2c9a6a6239c807be5
parent 324887 69bdb4f40c1e4d66c4bc17280b119b157cc77c0e
child 324949 22f11c60991cdd765baf5767c5066dfcc9990186
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerstestonly
bugs1319328
milestone53.0a1
Bug 1319328 - Wait for pending statements before checking annos in test_mobile_query. a=testonly MozReview-Commit-ID: BW5b0FgvwMD
services/sync/tests/unit/test_bookmark_tracker.js
--- a/services/sync/tests/unit/test_bookmark_tracker.js
+++ b/services/sync/tests/unit/test_bookmark_tracker.js
@@ -1556,43 +1556,49 @@ add_task(async function test_onItemDelet
     await verifyTrackedItems([fx_guid, tb_guid, folder1_guid, folder2_guid]);
     do_check_eq(tracker.score, SCORE_INCREMENT_XLARGE * 3);
   } finally {
     _("Clean up.");
     await cleanup();
   }
 });
 
+async function ensureMobileQuery() {
+  tracker._ensureMobileQuery();
+  await PlacesTestUtils.promiseAsyncUpdates();
+}
+
 add_task(async function test_mobile_query() {
   _("Ensure we correctly create the mobile query");
 
   try {
     await startTracking();
 
     // Creates the organizer queries as a side effect.
     let leftPaneId = PlacesUIUtils.leftPaneFolderId;
     _(`Left pane root ID: ${leftPaneId}`);
+    await PlacesTestUtils.promiseAsyncUpdates();
 
     let allBookmarksGuids = await fetchGuidsWithAnno("PlacesOrganizer/OrganizerQuery",
                                                      "AllBookmarks");
     equal(allBookmarksGuids.length, 1, "Should create folder with all bookmarks queries");
     let allBookmarkGuid = allBookmarksGuids[0];
 
     _("Try creating query after organizer is ready");
-    tracker._ensureMobileQuery();
+    await ensureMobileQuery();
     let queryGuids = await fetchGuidsWithAnno("PlacesOrganizer/OrganizerQuery",
                                               "MobileBookmarks");
     equal(queryGuids.length, 0, "Should not create query without any mobile bookmarks");
 
     _("Insert mobile bookmark, then create query");
     let mozBmk = await PlacesUtils.bookmarks.insert({
       parentGuid: PlacesUtils.bookmarks.mobileGuid,
       url: "https://mozilla.org",
     });
-    tracker._ensureMobileQuery();
+    await ensureMobileQuery();
     queryGuids = await fetchGuidsWithAnno("PlacesOrganizer/OrganizerQuery",
                                           "MobileBookmarks");
     equal(queryGuids.length, 1, "Should create query once mobile bookmarks exist");
 
     let queryGuid = queryGuids[0];
 
     let queryInfo = await PlacesUtils.bookmarks.fetch(queryGuid);
     equal(queryInfo.url, `place:folder=${PlacesUtils.mobileFolderId}`, "Query should point to mobile root");
@@ -1603,28 +1609,28 @@ add_task(async function test_mobile_quer
     await PlacesUtils.bookmarks.update({
       guid: PlacesUtils.bookmarks.mobileGuid,
       title: "renamed root",
     });
     await PlacesUtils.bookmarks.update({
       guid: queryGuid,
       title: "renamed query",
     });
-    tracker._ensureMobileQuery();
+    await ensureMobileQuery();
     let rootInfo = await PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.mobileGuid);
     equal(rootInfo.title, "Mobile Bookmarks", "Should fix root title");
     queryInfo = await PlacesUtils.bookmarks.fetch(queryGuid);
     equal(queryInfo.title, "Mobile Bookmarks", "Should fix query title");
 
     _("Point query to different folder");
     await PlacesUtils.bookmarks.update({
       guid: queryGuid,
       url: "place:folder=BOOKMARKS_MENU",
     });
-    tracker._ensureMobileQuery();
+    await ensureMobileQuery();
     queryInfo = await PlacesUtils.bookmarks.fetch(queryGuid);
     equal(queryInfo.url.href, `place:folder=${PlacesUtils.mobileFolderId}`,
       "Should fix query URL to point to mobile root");
 
     _("We shouldn't track the query or the left pane root");
     await verifyTrackedItems([mozBmk.guid, "mobile"]);
     do_check_eq(tracker.score, SCORE_INCREMENT_XLARGE * 5);
   } finally {