Skip to content

Commit

Permalink
Bug 1458375 - Make TalosPowersContent.goQuitApplication wait for brow…
Browse files Browse the repository at this point in the history
…ser-idle-startup-tasks-finished to fire before quitting. r=rwood

browser-idle-startup-tasks-finished will kick off some caching that can influence
future runs in the same profile. We want to make sure that we properly create
that cache when running Talos.

MozReview-Commit-ID: 9Ydt1ur3tsj

--HG--
extra : rebase_source : 322440d316b51a88e2b344bcee5239329af5510c
  • Loading branch information
mikeconley committed May 29, 2018
1 parent a202cc2 commit d0889af
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions testing/talos/talos/talos-powers/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ChromeUtils.defineModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
ChromeUtils.defineModuleGetter(this, "BrowserWindowTracker",
"resource:///modules/BrowserWindowTracker.jsm");

Cu.importGlobalProperties(["TextEncoder"]);

Expand Down Expand Up @@ -212,17 +214,35 @@ TalosPowersService.prototype = {
}
},

forceQuit(messageData) {
async forceQuit(messageData) {
if (messageData && messageData.waitForSafeBrowsing) {
let SafeBrowsing = ChromeUtils.import("resource://gre/modules/SafeBrowsing.jsm", {}).SafeBrowsing;

let whenDone = () => {
this.forceQuit();
};
SafeBrowsing.addMozEntriesFinishedPromise.then(whenDone, whenDone);
// Speed things up in case nobody else called this:
SafeBrowsing.init();
return;

try {
await SafeBrowsing.addMozEntriesFinishedPromise;
} catch (e) {
// We don't care if things go wrong here - let's just shut down.
}
}

// 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
// keys off of that notification.
let topWin = BrowserWindowTracker.getTopWindow();
if (topWin &&
topWin.gBrowserInit &&
!topWin.gBrowserInit.idleTasksFinished) {
await new Promise(resolve => {
let obs = (subject, topic, data) => {
Services.obs.removeObserver(obs, "browser-idle-startup-tasks-finished");
resolve();
};
Services.obs.addObserver(obs, "browser-idle-startup-tasks-finished");
});
}

let enumerator = Services.wm.getEnumerator(null);
Expand Down

0 comments on commit d0889af

Please sign in to comment.