Skip to content

Commit

Permalink
Bug 1752593 - Poll for TopSitesFeed in Talos getInfo shutdown routine…
Browse files Browse the repository at this point in the history
… instead of assuming it exists. r=perftest-reviewers,sparky

The TopSitesFeed instance might actually not exist yet, since Store initializes asynchronously.
There doesn't appear to be a great way to actually observe the creation of the TopSitesFeed
via observer notifications, events, or other exposed properties, so we'll poll for now.

Differential Revision: https://phabricator.services.mozilla.com/D137463
  • Loading branch information
mikeconley committed Feb 3, 2022
1 parent 0fdded6 commit 3dd7c27
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions testing/talos/talos/talos-powers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
OS: "resource://gre/modules/osfile.jsm",
PerTestCoverageUtils: "resource://testing-common/PerTestCoverageUtils.jsm",
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
setTimeout: "resource://gre/modules/Timer.jsm",
});

XPCOMUtils.defineLazyServiceGetter(
Expand Down Expand Up @@ -292,14 +294,27 @@ TalosPowersService.prototype = {
// about:home startup cache on shutdown, which causes that test
// to break periodically.
AboutNewTab.onBrowserReady();
let feed = AboutNewTab.activityStream.store.feeds.get(
"feeds.system.topsites"
);
// There aren't currently any easily observable notifications or
// events to let us know when the feed is ready, so we'll just poll
// for now.
let pollForFeed = async function() {
let foundFeed = AboutNewTab.activityStream.store.feeds.get(
"feeds.system.topsites"
);
if (!foundFeed) {
await new Promise(resolve => setTimeout(resolve, 500));
return pollForFeed();
}
return foundFeed;
};
let feed = await pollForFeed();
await feed._contile.refresh();
await feed.refresh({ broadcast: true });
await AboutHomeStartupCache.cacheNow();
}

await SessionStore.promiseAllWindowsRestored;

// Check to see if the top-most browser window still needs to fire its
// idle tasks notification. If so, we'll wait for it before shutting
// down, since some caching that can influence future runs in this profile
Expand Down

0 comments on commit 3dd7c27

Please sign in to comment.