E. // // Consumers should be aware that: // // * This blocks first startup window opening for new installs on Windows // ONLY for the first created default profile // * If PREF_TIMEOUT elapses before all of these promises complete, the // registered category entries might not have all had a chance to // successfully complete before the first browser window appears. const CATEGORY_TASKS_ENABLED = Services.prefs.getBoolPref( PREF_CATEGORY_TASKS, false ); let categoryTasksEndTime = null; if (CATEGORY_TASKS_ENABLED && AppConstants.MOZ_NORMANDY) { promises.push( normandyInitPromise.finally(() => { return lazy.BrowserUtils.callModulesFromCategory({ categoryName: CATEGORY_NAME, profileMarker: "first-startup-new-profile-tasks", idleDispatch: false, }).finally(() => { categoryTasksEndTime = ChromeUtils.now(); }); }) ); } if (promises.length) { Promise.allSettled(promises).then(() => (initialized = true)); this.elapsed = 0; Services.tm.spinEventLoopUntil("FirstStartup.sys.mjs:init", () => { this.elapsed = Math.ceil(ChromeUtils.now() - startingTime); if (this.elapsed >= timeout) { this._state = this.TIMED_OUT; return true; } else if (initialized) { this._state = this.SUCCESS; return true; } return false; }); } else { this._state = this.UNSUPPORTED; } if (AppConstants.MOZ_NORMANDY) { Glean.firstStartup.normandyInitTime.set( Math.ceil(normandyInitEndTime || ChromeUtils.now() - startingTime) ); } if (AppConstants.MOZ_UPDATE_AGENT) { Glean.firstStartup.deleteTasksTime.set( Math.ceil(deleteTasksEndTime || ChromeUtils.now() - startingTime) ); } if (CATEGORY_TASKS_ENABLED) { Glean.firstStartup.categoryTasksTime.set( Math.ceil(categoryTasksEndTime || ChromeUtils.now() - startingTime) ); } Glean.firstStartup.statusCode.set(this._state); Glean.firstStartup.elapsed.set(this.elapsed); GleanPings.firstStartup.submit(); }, get state() { return this._state; }, /** * For testing only. This puts us back into the initial NOT_STARTED state. */ resetForTesting() { this._state = this.NOT_STARTED; }, }; PK