Bug 1395082 - Intermittent toolkit/components/places/tests/browser/browser_visited_notfound.js. r=standard8 draft
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 30 Aug 2017 17:32:20 +0200
changeset 655933 18e79867846705ad5ab79588a9f97eaa3fd37324
parent 652924 b6b8e616de32af50c9a174006b3a7ed914130aa5
child 728956 6480294eb3cde5958d9345186d89a14f58f5fc12
push id77007
push usermak77@bonardo.net
push dateWed, 30 Aug 2017 15:33:32 +0000
reviewersstandard8
bugs1395082
milestone57.0a1
Bug 1395082 - Intermittent toolkit/components/places/tests/browser/browser_visited_notfound.js. r=standard8 MozReview-Commit-ID: GzAZXNIbBCN
toolkit/components/places/tests/PlacesTestUtils.jsm
--- a/toolkit/components/places/tests/PlacesTestUtils.jsm
+++ b/toolkit/components/places/tests/PlacesTestUtils.jsm
@@ -202,24 +202,25 @@ this.PlacesTestUtils = Object.freeze({
    * Asynchronously returns the required DB field for a specified page.
    * @param aURI
    *        nsIURI or address to look for.
    *
    * @return {Promise}
    * @resolves Returns the field value.
    * @rejects JavaScript exception.
    */
-  async fieldInDB(aURI, field) {
+  fieldInDB(aURI, field) {
     let url = aURI instanceof Ci.nsIURI ? new URL(aURI.spec) : new URL(aURI);
-    let db = await PlacesUtils.promiseDBConnection();
-    let rows = await db.executeCached(
-      `SELECT ${field} FROM moz_places
-       WHERE url_hash = hash(:url) AND url = :url`,
-      { url: url.href });
-    return rows[0].getResultByIndex(0);
+    return PlacesUtils.withConnectionWrapper("PlacesTestUtils.jsm: fieldInDb", async db => {
+      let rows = await db.executeCached(
+        `SELECT ${field} FROM moz_places
+        WHERE url_hash = hash(:url) AND url = :url`,
+        { url: url.href });
+      return rows[0].getResultByIndex(0);
+    });
   },
 
   /**
    * Marks all syncable bookmarks as synced by setting their sync statuses to
    * "NORMAL", resetting their change counters, and removing all tombstones.
    * Used by tests to avoid calling `PlacesSyncUtils.bookmarks.pullChanges`
    * and `PlacesSyncUtils.bookmarks.pushChanges`.
    *