Bug 1382291 - Intermittent browser/components/places/tests/browser/browser_markPageAsFollowedLink.js. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 26 Jul 2017 13:52:24 +0200
changeset 420114 452f3e6d539b68941487365917c437e66352401e
parent 419973 c1ed71da57073d0f5fdbd279c9ad6037f9ae2d06
child 420115 79c3b71475c7563d725da61dbd24d18ae73caf65
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1382291
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382291 - Intermittent browser/components/places/tests/browser/browser_markPageAsFollowedLink.js. r=adw MozReview-Commit-ID: KBukQFU9WPn
browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
toolkit/components/places/History.jsm
--- a/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
+++ b/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
@@ -45,23 +45,19 @@ add_task(async function test() {
 
   // Wait for the right frame visit to be registered.
   info("Waiting right frame visit");
   await deferredRightFrameVisit.promise;
 
   await BrowserTestUtils.removeTab(tab);
 });
 
-async function getTransitionForUrl(url) {
-  // Ensure all the transactions completed.
-  await PlacesTestUtils.promiseAsyncUpdates();
-  let db = await PlacesUtils.promiseDBConnection();
-  let rows = await db.execute(`
-    SELECT visit_type
-    FROM moz_historyvisits
-    JOIN moz_places h ON place_id = h.id
-    WHERE url_hash = hash(:url) AND url = :url`,
-    { url });
-  if (rows.length) {
-    return rows[0].getResultByName("visit_type");
-  }
-  return null;
+function getTransitionForUrl(url) {
+  return PlacesUtils.withConnectionWrapper("browser_markPageAsFollowedLink", async db => {
+    let rows = await db.execute(`
+      SELECT visit_type
+      FROM moz_historyvisits
+      JOIN moz_places h ON place_id = h.id
+      WHERE url_hash = hash(:url) AND url = :url
+      `, { url });
+    return rows.length ? rows[0].getResultByName("visit_type") : null;
+  });
 }
--- a/toolkit/components/places/History.jsm
+++ b/toolkit/components/places/History.jsm
@@ -541,20 +541,20 @@ this.History = Object.freeze({
     }
 
     guidOrURI = PlacesUtils.normalizeToURLOrGUID(guidOrURI);
     let isGuid = typeof guidOrURI == "string";
     let sqlFragment = isGuid ? "guid = :val"
                              : "url_hash = hash(:val) AND url = :val "
 
     return PlacesUtils.promiseDBConnection().then(async db => {
-      let rows = await db.execute(`SELECT 1 FROM moz_places
-                                    WHERE ${sqlFragment}
-                                      AND last_visit_date NOTNULL`,
-                                  { val: isGuid ? guidOrURI : guidOrURI.href });
+      let rows = await db.executeCached(`SELECT 1 FROM moz_places
+                                         WHERE ${sqlFragment}
+                                         AND last_visit_date NOTNULL`,
+                                        { val: isGuid ? guidOrURI : guidOrURI.href });
       return !!rows.length;
     });
   },
 
   /**
    * Clear all history.
    *
    * @return (Promise)