mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1245891 - Changing Session Restore Talos tests to include the time to restore actual tabs;r=mconley
MozReview-Commit-ID: 3kjG6ixWNiO
This commit is contained in:
parent
d86d0d8933
commit
d574bd0c2c
@ -23,9 +23,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
|
||||
const COLLECT_RESULTS_AFTER_MS = 10000;
|
||||
|
||||
const TOPICS = ["sessionstore-restoring-on-startup", "sessionstore-initiating-manual-restore"];
|
||||
const OBSERVED_TOPICS = ["sessionstore-restoring-on-startup", "sessionstore-initiating-manual-restore"];
|
||||
|
||||
this.StartupPerformance = {
|
||||
/**
|
||||
* Once we have finished restoring initial tabs, we broadcast on this topic.
|
||||
*/
|
||||
RESTORED_TOPIC: "sessionstore-finished-restoring-initial-tabs",
|
||||
|
||||
// Instant at which we have started restoration (notification "sessionstore-restoring-on-startup")
|
||||
_startTimeStamp: null,
|
||||
|
||||
@ -50,16 +55,26 @@ this.StartupPerformance = {
|
||||
_totalNumberOfWindows: 0,
|
||||
|
||||
init: function() {
|
||||
for (let topic of TOPICS) {
|
||||
for (let topic of OBSERVED_TOPICS) {
|
||||
Services.obs.addObserver(this, topic, false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the timestamp at which we finished restoring the latest tab.
|
||||
*
|
||||
* This information is not really interesting until we have finished restoring
|
||||
* tabs.
|
||||
*/
|
||||
get latestRestoredTimeStamp() {
|
||||
return this._latestRestoredTimeStamp;
|
||||
},
|
||||
|
||||
// Called when restoration starts.
|
||||
// Record the start timestamp, setup the timer and `this._promiseFinished`.
|
||||
// Behavior is unspecified if there was already an ongoing measure.
|
||||
_onRestorationStarts: function(isAutoRestore) {
|
||||
this._startTimeStamp = Date.now();
|
||||
this._latestRestoredTimeStamp = this._startTimeStamp = Date.now();
|
||||
this._totalNumberOfEagerTabs = 0;
|
||||
this._totalNumberOfTabs = 0;
|
||||
this._totalNumberOfWindows = 0;
|
||||
@ -68,7 +83,7 @@ this.StartupPerformance = {
|
||||
// that's a very unusual case, and not really worth measuring, so let's
|
||||
// stop listening for further restorations.
|
||||
|
||||
for (let topic of TOPICS) {
|
||||
for (let topic of OBSERVED_TOPICS) {
|
||||
Services.obs.removeObserver(this, topic);
|
||||
}
|
||||
|
||||
@ -78,7 +93,9 @@ this.StartupPerformance = {
|
||||
});
|
||||
this._promiseFinished.then(() => {
|
||||
try {
|
||||
if (!this._latestRestoredTimeStamp) {
|
||||
Services.obs.notifyObservers(null, this.RESTORED_TOPIC, "");
|
||||
|
||||
if (this._latestRestoredTimeStamp == this._startTimeStamp) {
|
||||
// Apparently, we haven't restored any tab.
|
||||
return;
|
||||
}
|
||||
@ -95,7 +112,6 @@ this.StartupPerformance = {
|
||||
Services.telemetry.getHistogramById("FX_SESSION_RESTORE_NUMBER_OF_TABS_RESTORED").add(this._totalNumberOfTabs);
|
||||
Services.telemetry.getHistogramById("FX_SESSION_RESTORE_NUMBER_OF_WINDOWS_RESTORED").add(this._totalNumberOfWindows);
|
||||
|
||||
|
||||
// Reset
|
||||
this._startTimeStamp = null;
|
||||
} catch (ex) {
|
||||
|
@ -16,10 +16,11 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
|
||||
"resource://gre/modules/Timer.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "StartupPerformance",
|
||||
"resource://gre/modules/sessionstore/StartupPerformance.jsm");
|
||||
|
||||
// Observer Service topics.
|
||||
const STARTUP_TOPIC = "profile-after-change";
|
||||
const RESTORED_TOPIC = "sessionstore-windows-restored";
|
||||
|
||||
// Process Message Manager topics.
|
||||
const MSG_REQUEST = "session-restore-test?duration";
|
||||
@ -45,7 +46,7 @@ nsSessionRestoreTalosTest.prototype = {
|
||||
case STARTUP_TOPIC:
|
||||
this.init();
|
||||
break;
|
||||
case RESTORED_TOPIC:
|
||||
case StartupPerformance.RESTORED_TOPIC:
|
||||
this.onRestored();
|
||||
break;
|
||||
default:
|
||||
@ -57,7 +58,7 @@ nsSessionRestoreTalosTest.prototype = {
|
||||
* Perform initialization on profile-after-change.
|
||||
*/
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, RESTORED_TOPIC, false);
|
||||
Services.obs.addObserver(this, StartupPerformance.RESTORED_TOPIC, false);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -65,9 +66,9 @@ nsSessionRestoreTalosTest.prototype = {
|
||||
*/
|
||||
onRestored: function() {
|
||||
setTimeout(function() {
|
||||
// `sessionRestored` actually becomes available only on the next tick.
|
||||
// `StartupPerformance.latestRestoredTimeStamp` actually becomes available only on the next tick.
|
||||
let startup_info = Services.startup.getStartupInfo();
|
||||
let duration = startup_info.sessionRestored - startup_info.sessionRestoreInit;
|
||||
let duration = StartupPerformance.latestRestoredTimeStamp - startup_info.sessionRestoreInit;
|
||||
|
||||
// Broadcast startup duration information immediately, in case the talos
|
||||
// page is already loaded.
|
||||
|
Loading…
Reference in New Issue
Block a user