Bug 1395082 - Intermittent toolkit/components/places/tests/browser/browser_visited_notfound.js. r=standard8
MozReview-Commit-ID: GzAZXNIbBCN
--- 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`.
*