Bug 1877545 - Add a probe for whether or not a pre-existing profile existed when initting FirstStartup. data-review=jhirsch, r=rhelmer
Differential Revision: https://phabricator.services.mozilla.com/D201286
This commit is contained in:
@@ -692,9 +692,7 @@ nsBrowserContentHandler.prototype = {
|
||||
// tell needHomepageOverride to leave the milestone prefs alone when doing
|
||||
// this check.
|
||||
let override = needHomepageOverride(false /* updateMilestones */);
|
||||
if (override == OVERRIDE_NEW_PROFILE) {
|
||||
lazy.FirstStartup.init();
|
||||
}
|
||||
lazy.FirstStartup.init(override == OVERRIDE_NEW_PROFILE /* newProfile */);
|
||||
}
|
||||
|
||||
var fileParam = cmdLine.handleFlagWithParam("file", false);
|
||||
|
||||
@@ -36,8 +36,25 @@ export var FirstStartup = {
|
||||
* completed, or until a timeout is reached.
|
||||
*
|
||||
* In the latter case, services are expected to run post-UI instead as usual.
|
||||
*
|
||||
* @param {boolean} newProfile
|
||||
* True if a new profile was just created, false otherwise.
|
||||
*/
|
||||
init() {
|
||||
init(newProfile) {
|
||||
if (!newProfile) {
|
||||
// In this case, we actually don't want to do any FirstStartup work,
|
||||
// since a pre-existing profile was detected (presumably, we entered here
|
||||
// because a user re-installed via the stub installer when there existed
|
||||
// previous user profiles on the file system). We do, however, want to
|
||||
// measure how often this occurs.
|
||||
Glean.firstStartup.statusCode.set(this.NOT_STARTED);
|
||||
Glean.firstStartup.newProfile.set(false);
|
||||
GleanPings.firstStartup.submit();
|
||||
return;
|
||||
}
|
||||
|
||||
Glean.firstStartup.newProfile.set(true);
|
||||
|
||||
this._state = this.IN_PROGRESS;
|
||||
const timeout = Services.prefs.getIntPref(PREF_TIMEOUT, 30000); // default to 30 seconds
|
||||
let startingTime = Cu.now();
|
||||
@@ -106,4 +123,11 @@ export var FirstStartup = {
|
||||
get state() {
|
||||
return this._state;
|
||||
},
|
||||
|
||||
/**
|
||||
* For testing only. This puts us back into the initial NOT_STARTED state.
|
||||
*/
|
||||
resetForTesting() {
|
||||
this._state = this.NOT_STARTED;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -83,3 +83,23 @@ first_startup:
|
||||
expires: never
|
||||
send_in_pings:
|
||||
- first-startup
|
||||
|
||||
new_profile:
|
||||
type: boolean
|
||||
description: >
|
||||
True if FirstStartup was initted after a new profile was just created. If
|
||||
false, this means that FirstStartup was initted with a pre-existing
|
||||
profile, which is a no-op.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1877545
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1749345
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1877545
|
||||
data_sensitivity:
|
||||
- technical
|
||||
notification_emails:
|
||||
- rhelmer@mozilla.com
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
send_in_pings:
|
||||
- first-startup
|
||||
|
||||
@@ -24,11 +24,13 @@ add_task(async function test_success() {
|
||||
updateAppInfo();
|
||||
|
||||
let submissionPromise;
|
||||
FirstStartup.resetForTesting();
|
||||
|
||||
if (AppConstants.MOZ_NORMANDY || AppConstants.MOZ_UPDATE_AGENT) {
|
||||
submissionPromise = new Promise(resolve => {
|
||||
GleanPings.firstStartup.testBeforeNextSubmit(() => {
|
||||
Assert.equal(FirstStartup.state, FirstStartup.SUCCESS);
|
||||
Assert.ok(Glean.firstStartup.newProfile.testGetValue());
|
||||
Assert.equal(
|
||||
Glean.firstStartup.statusCode.testGetValue(),
|
||||
FirstStartup.SUCCESS
|
||||
@@ -49,6 +51,7 @@ add_task(async function test_success() {
|
||||
submissionPromise = new Promise(resolve => {
|
||||
GleanPings.firstStartup.testBeforeNextSubmit(() => {
|
||||
Assert.equal(FirstStartup.state, FirstStartup.UNSUPPORTED);
|
||||
Assert.ok(Glean.firstStartup.newProfile.testGetValue());
|
||||
Assert.equal(
|
||||
Glean.firstStartup.statusCode.testGetValue(),
|
||||
FirstStartup.UNSUPPORTED
|
||||
@@ -58,13 +61,14 @@ add_task(async function test_success() {
|
||||
});
|
||||
}
|
||||
|
||||
FirstStartup.init();
|
||||
FirstStartup.init(true /* newProfile */);
|
||||
await submissionPromise;
|
||||
});
|
||||
|
||||
add_task(async function test_timeout() {
|
||||
updateAppInfo();
|
||||
Services.prefs.setIntPref(PREF_TIMEOUT, 0);
|
||||
FirstStartup.resetForTesting();
|
||||
|
||||
let submissionPromise;
|
||||
|
||||
@@ -73,6 +77,7 @@ add_task(async function test_timeout() {
|
||||
GleanPings.firstStartup.testBeforeNextSubmit(() => {
|
||||
Assert.equal(FirstStartup.state, FirstStartup.TIMED_OUT);
|
||||
Assert.ok(Glean.firstStartup.elapsed.testGetValue() > 0);
|
||||
Assert.ok(Glean.firstStartup.newProfile.testGetValue());
|
||||
|
||||
if (AppConstants.MOZ_NORMANDY) {
|
||||
Assert.ok(Glean.firstStartup.normandyInitTime.testGetValue() > 0);
|
||||
@@ -90,11 +95,27 @@ add_task(async function test_timeout() {
|
||||
GleanPings.firstStartup.testBeforeNextSubmit(() => {
|
||||
Assert.equal(FirstStartup.state, FirstStartup.UNSUPPORTED);
|
||||
Assert.equal(Glean.firstStartup.elapsed.testGetValue(), 0);
|
||||
Assert.ok(Glean.firstStartup.newProfile.testGetValue());
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
FirstStartup.init();
|
||||
FirstStartup.init(true /* newProfile */);
|
||||
await submissionPromise;
|
||||
});
|
||||
|
||||
add_task(async function test_existing_profile() {
|
||||
FirstStartup.resetForTesting();
|
||||
|
||||
let submissionPromise = new Promise(resolve => {
|
||||
GleanPings.firstStartup.testBeforeNextSubmit(() => {
|
||||
Assert.equal(FirstStartup.state, FirstStartup.NOT_STARTED);
|
||||
Assert.ok(!Glean.firstStartup.newProfile.testGetValue());
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
FirstStartup.init(false /* newProfile */);
|
||||
await submissionPromise;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user