Bug 1387303 - fix test_places_guid_downgrade.js to work correctly in the new async-sync world. r?kitcambridge,eoger draft
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 04 Aug 2017 11:49:15 +1000
changeset 620865 de6c033aec4d36366b871616f542d28b1a9d385b
parent 619442 fec8d72590053c3ad72cd3492d389213dfabc2ff
child 640831 372bc78cdbf63a7c64b44ac2f9b6ae3854b7c258
push id72179
push userbmo:markh@mozilla.com
push dateFri, 04 Aug 2017 01:50:34 +0000
reviewerskitcambridge, eoger
bugs1387303
milestone56.0a1
Bug 1387303 - fix test_places_guid_downgrade.js to work correctly in the new async-sync world. r?kitcambridge,eoger MozReview-Commit-ID: 4bmu45qUmFA
services/sync/tests/unit/test_places_guid_downgrade.js
--- a/services/sync/tests/unit/test_places_guid_downgrade.js
+++ b/services/sync/tests/unit/test_places_guid_downgrade.js
@@ -104,27 +104,20 @@ add_task(async function test_history_gui
       uri: tburi,
       title: "Get Thunderbird!",
       visits: [{
         visitDate: Date.now() * 1000,
         transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
       }]
     }
   ];
-  PlacesUtils.asyncHistory.updatePlaces(places, {
-    handleError: function handleError() {
-      do_throw("Unexpected error in adding visit.");
-    },
-    handleResult: function handleResult() {},
-    handleCompletion: onVisitAdded
-  });
 
-  function onVisitAdded() {
-    let fxguid = store.GUIDForUri(fxuri, true);
-    let tbguid = store.GUIDForUri(tburi, true);
+  async function onVisitAdded() {
+    let fxguid = await store.GUIDForUri(fxuri, true);
+    let tbguid = await store.GUIDForUri(tburi, true);
     dump("fxguid: " + fxguid + "\n");
     dump("tbguid: " + tbguid + "\n");
 
     _("History: Verify GUIDs are added to the guid column.");
     let connection = PlacesUtils.history
                                 .QueryInterface(Ci.nsPIPlacesDatabase)
                                 .DBConnection;
     let stmt = connection.createAsyncStatement(
@@ -146,19 +139,27 @@ add_task(async function test_history_gui
     stmt.params.guid = fxguid;
     result = Async.querySpinningly(stmt, ["guid"]);
     do_check_eq(result.length, 0);
 
     stmt.params.guid = tbguid;
     result = Async.querySpinningly(stmt, ["guid"]);
     do_check_eq(result.length, 0);
     stmt.finalize();
+  }
 
-    run_next_test();
-  }
+  await new Promise((resolve, reject) => {
+    PlacesUtils.asyncHistory.updatePlaces(places, {
+      handleError: function handleError() {
+        do_throw("Unexpected error in adding visit.");
+      },
+      handleResult: function handleResult() {},
+      handleCompletion: () => {onVisitAdded().then(resolve, reject)},
+    });
+  });
 });
 
 add_task(async function test_bookmark_guids() {
   let engine = new BookmarksEngine(Service);
   let store = engine._store;
 
   let fxid = PlacesUtils.bookmarks.insertBookmark(
     PlacesUtils.bookmarks.toolbarFolder,