Bug 1495043 - Ensure background frecency updates have had a chance to run when checking the database in test_origins.js. r=adw
authorMark Banner <standard8@mozilla.com>
Tue, 02 Oct 2018 23:00:15 +0000
changeset 439364 b6664d437a230a0e1722124b01e95d777e057958
parent 439363 852fad92ec6cda02a9ef6003842c6b5ac7c5625e
child 439365 9bdbc378f0371982a76400c02c19d68f90d828ee
push id70302
push usermbanner@mozilla.com
push dateWed, 03 Oct 2018 06:49:20 +0000
treeherderautoland@b6664d437a23 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1495043
milestone64.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 1495043 - Ensure background frecency updates have had a chance to run when checking the database in test_origins.js. r=adw Differential Revision: https://phabricator.services.mozilla.com/D7531
toolkit/components/places/tests/unit/test_origins.js
--- a/toolkit/components/places/tests/unit/test_origins.js
+++ b/toolkit/components/places/tests/unit/test_origins.js
@@ -1238,16 +1238,20 @@ function expectedOriginFrecency(urls) {
  *        An array of expected origins.  Each origin in the array is itself an
  *        array that looks like this:
  *          [prefix, host, [url1, url2, ..., urln]]
  *        The element at index 2 is an array of all the URLs with the origin.
  *        If you don't care about checking frecencies and origin frecency stats,
  *        this element can be `undefined`.
  */
 async function checkDB(expectedOrigins) {
+  // Frencencies for bookmarks are generated asynchronously but not within the
+  // await cycle for bookmarks.insert() etc, so wait for them to happen.
+  await PlacesTestUtils.promiseAsyncUpdates();
+
   let db = await PlacesUtils.promiseDBConnection();
   let rows = await db.execute(`
     SELECT prefix, host, frecency
     FROM moz_origins
     ORDER BY id ASC
   `);
   let checkFrecencies = !expectedOrigins.length || expectedOrigins[0][2] !== undefined;
   let actualOrigins = rows.map(row => {