Backed out 4 changesets (bug 1576507) for causing xpcshell failures on test_firstStartup.js
authorarthur.iakab <aiakab@mozilla.com>
Sat, 31 Aug 2019 03:52:51 +0300
changeset 490977 2da8982d97aa34a90b0bd871dc32ac8aa65e40a7
parent 490976 7d029a9d6c0de272be77e49114555e493b480a05
child 490978 724755d6ff65b56b065aeff5f41ecadb3f15899a
push id114010
push userdluca@mozilla.com
push dateSat, 31 Aug 2019 09:58:00 +0000
treeherdermozilla-inbound@b3cc8963e871 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1576507
milestone70.0a1
backs outefca0164a7621c926a4661314d2120c67754ed0d
2238ba5cec98f76011ba7b53a019124b7d048e70
f16714d49101f2e80daeacbe4f38d74fa0a5cf7d
2d621070f778e4998b7efab944e4e9fb45e84862
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 4 changesets (bug 1576507) for causing xpcshell failures on test_firstStartup.js Backed out changeset efca0164a762 (bug 1576507) Backed out changeset 2238ba5cec98 (bug 1576507) Backed out changeset f16714d49101 (bug 1576507) Backed out changeset 2d621070f778 (bug 1576507)
browser/components/BrowserContentHandler.jsm
toolkit/components/normandy/Normandy.jsm
toolkit/components/telemetry/Scalars.yaml
toolkit/components/utils/ClientEnvironment.jsm
toolkit/modules/FirstStartup.jsm
toolkit/modules/docs/FirstStartup.rst
toolkit/modules/docs/index.rst
toolkit/modules/moz.build
toolkit/modules/tests/xpcshell/test_firstStartup.js
toolkit/modules/tests/xpcshell/xpcshell.ini
--- a/browser/components/BrowserContentHandler.jsm
+++ b/browser/components/BrowserContentHandler.jsm
@@ -14,17 +14,16 @@ const { Services } = ChromeUtils.import(
 const { AppConstants } = ChromeUtils.import(
   "resource://gre/modules/AppConstants.jsm"
 );
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
   HeadlessShell: "resource:///modules/HeadlessShell.jsm",
   HomePage: "resource:///modules/HomePage.jsm",
-  FirstStartup: "resource://gre/modules/FirstStartup.jsm",
   LaterRun: "resource:///modules/LaterRun.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
   ShellService: "resource:///modules/ShellService.jsm",
   UpdatePing: "resource://gre/modules/UpdatePing.jsm",
   RemotePages:
     "resource://gre/modules/remotepagemanager/RemotePageManagerParent.jsm",
 });
@@ -554,20 +553,16 @@ nsBrowserContentHandler.prototype = {
           ).usePrivateBrowsing = true;
         }
       }
     }
     if (cmdLine.handleFlag("setDefaultBrowser", false)) {
       ShellService.setDefaultBrowser(true, true);
     }
 
-    if (cmdLine.handleFlag("first-startup", false)) {
-      FirstStartup.init();
-    }
-
     var fileParam = cmdLine.handleFlagWithParam("file", false);
     if (fileParam) {
       var file = cmdLine.resolveFile(fileParam);
       var fileURI = Services.io.newFileURI(file);
       openBrowserWindow(cmdLine, gSystemPrincipal, fileURI.spec);
       cmdLine.preventDefault = true;
     }
 
@@ -599,18 +594,16 @@ nsBrowserContentHandler.prototype = {
     }
     info +=
       "  --screenshot [<path>] Save screenshot to <path> or in working directory.\n";
     info +=
       "  --window-size width[,height] Width and optionally height of screenshot.\n";
     info +=
       "  --search <term>    Search <term> with your default search engine.\n";
     info += "  --setDefaultBrowser Set this app as the default browser.\n";
-    info +=
-      "  --first-startup    Run post-install actions before opening a new window.\n";
     return info;
   },
 
   /* nsIBrowserHandler */
 
   get defaultArgs() {
     return this.getArgs();
   },
--- a/toolkit/components/normandy/Normandy.jsm
+++ b/toolkit/components/normandy/Normandy.jsm
@@ -38,36 +38,28 @@ const PREF_LOGGING_LEVEL = `${PREF_PREFI
 const log = Log.repository.getLogger(BOOTSTRAP_LOGGER_NAME);
 log.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
 log.level = Services.prefs.getIntPref(PREF_LOGGING_LEVEL, Log.Level.Warn);
 
 var Normandy = {
   studyPrefsChanged: {},
   rolloutPrefsChanged: {},
 
-  async init({ runAsync = true } = {}) {
+  async init() {
     // Initialization that needs to happen before the first paint on startup.
     await NormandyMigrations.applyAll();
     this.rolloutPrefsChanged = this.applyStartupPrefs(
       STARTUP_ROLLOUT_PREFS_BRANCH
     );
     this.studyPrefsChanged = this.applyStartupPrefs(
       STARTUP_EXPERIMENT_PREFS_BRANCH
     );
 
-    if (runAsync) {
-      Services.obs.addObserver(this, UI_AVAILABLE_NOTIFICATION);
-    } else {
-      // Remove any observers, if present.
-      try {
-        Services.obs.removeObserver(this, UI_AVAILABLE_NOTIFICATION);
-      } catch (e) {}
-
-      await this.finishInit();
-    }
+    // Wait until the UI is available before finishing initialization.
+    Services.obs.addObserver(this, UI_AVAILABLE_NOTIFICATION);
   },
 
   observe(subject, topic, data) {
     if (topic === UI_AVAILABLE_NOTIFICATION) {
       Services.obs.removeObserver(this, UI_AVAILABLE_NOTIFICATION);
       this.finishInit();
     }
   },
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -4581,32 +4581,16 @@ blocklist:
       - lgreco@mozilla.com
       - awagner@mozilla.com
     products:
       - 'firefox'
       - 'fennec'
     record_in_processes:
       - main
 
-firstStartup:
-  statusCode:
-    bug_numbers:
-      - 1515712
-    description: >-
-      Status of the FirstRun service, which runs post-install/early-startup in Firefox.
-    expires: "75"
-    kind: uint
-    notification_emails:
-      - rhelmer@mozilla.com
-    release_channel_collection: opt-out
-    products:
-      - 'firefox'
-    record_in_processes:
-      - main
-
 # The following section is for probes testing the Telemetry system. They will not be
 # submitted in pings and are only used for testing.
 telemetry.test:
   unsigned_int_kind:
     bug_numbers:
       - 1276190
     description: >
       This is a test uint type with a really long description, maybe spanning even multiple
--- a/toolkit/components/utils/ClientEnvironment.jsm
+++ b/toolkit/components/utils/ClientEnvironment.jsm
@@ -31,21 +31,16 @@ ChromeUtils.defineModuleGetter(
   "UpdateUtils",
   "resource://gre/modules/UpdateUtils.jsm"
 );
 ChromeUtils.defineModuleGetter(
   this,
   "AppConstants",
   "resource://gre/modules/AppConstants.jsm"
 );
-ChromeUtils.defineModuleGetter(
-  this,
-  "FirstStartup",
-  "resource://gre/modules/FirstStartup.jsm"
-);
 
 var EXPORTED_SYMBOLS = ["ClientEnvironmentBase"];
 
 /**
  * Create an object that provides general information about the client application.
  *
  * Components like Normandy RecipeRunner use this as part of the context for filter expressions,
  * so avoid adding non-getter functions as attributes, as filter expressions
@@ -96,21 +91,16 @@ class ClientEnvironmentBase {
     return UpdateUtils.getUpdateChannel(false);
   }
 
   static get isDefaultBrowser() {
     return ShellService.isDefaultBrowser();
   }
 
   static get searchEngine() {
-    // Telemetry Environment is not available in early first-startup.
-    if (FirstStartup.state === FirstStartup.IN_PROGRESS) {
-      return undefined;
-    }
-
     return (async () => {
       await TelemetryEnvironment.onInitialized();
       return TelemetryEnvironment.currentEnvironment.settings
         .defaultSearchEngine;
     })();
   }
 
   static get syncSetup() {
@@ -169,21 +159,16 @@ class ClientEnvironmentBase {
   static get doNotTrack() {
     return Services.prefs.getBoolPref(
       "privacy.donottrackheader.enabled",
       false
     );
   }
 
   static get os() {
-    // Telemetry Environment is not available in early first-startup.
-    if (FirstStartup.state === FirstStartup.IN_PROGRESS) {
-      return undefined;
-    }
-
     function coerceToNumber(version) {
       const parts = version.split(".");
       return parseFloat(parts.slice(0, 2).join("."));
     }
 
     return (async () => {
       await TelemetryEnvironment.onInitialized();
 
deleted file mode 100644
--- a/toolkit/modules/FirstStartup.jsm
+++ /dev/null
@@ -1,75 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-var EXPORTED_SYMBOLS = ["FirstStartup"];
-
-const { AppConstants } = ChromeUtils.import(
-  "resource://gre/modules/AppConstants.jsm"
-);
-const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-const { XPCOMUtils } = ChromeUtils.import(
-  "resource://gre/modules/XPCOMUtils.jsm"
-);
-
-XPCOMUtils.defineLazyModuleGetters(this, {
-  Normandy: "resource://normandy/Normandy.jsm",
-});
-
-const PREF_TIMEOUT = "first-startup.timeout";
-const PROBE_NAME = "firstStartup.statusCode";
-
-/**
- * Service for blocking application startup, to be used on the first install. The intended
- * use case is for `FirstStartup` to be invoked when the application is called by an installer,
- * such as the Windows Stub Installer, to allow the application to do some first-install tasks
- * such as performance tuning and downloading critical data.
- *
- * In this scenario, the installer does not exit until the first application window appears,
- * which gives the user experience of the application starting up quickly on first install.
- */
-var FirstStartup = {
-  NOT_STARTED: 0,
-  IN_PROGRESS: 1,
-  TIMED_OUT: 2,
-  SUCCESS: 3,
-
-  _state: this.NOT_STARTED,
-  /**
-   * Initialize and run first-startup services. This will always run synchronously
-   * and spin the event loop until either all required services have
-   * completed, or until a timeout is reached.
-   *
-   * In the latter case, services are expected to run post-UI instead as usual.
-   */
-  init() {
-    this._state = this.IN_PROGRESS;
-    const timeout = Services.prefs.getIntPref(PREF_TIMEOUT, 5000); // default to 5 seconds
-    let expiredTime = Date.now() + timeout;
-
-    if (AppConstants.MOZ_NORMANDY) {
-      let normandyInitialized = false;
-
-      Normandy.init({ runAsync: false }).then(
-        () => (normandyInitialized = true)
-      );
-
-      Services.tm.spinEventLoopUntil(() => {
-        if (Date.now() >= expiredTime) {
-          this._state = this.TIMED_OUT;
-          return true;
-        } else if (normandyInitialized) {
-          this._state = this.SUCCESS;
-          return true;
-        }
-        return false;
-      });
-
-      Services.telemetry.scalarSet(PROBE_NAME, this._state);
-    }
-  },
-
-  get state() {
-    return this._state;
-  },
-};
deleted file mode 100644
--- a/toolkit/modules/docs/FirstStartup.rst
+++ /dev/null
@@ -1,74 +0,0 @@
-.. _FirstStartup:
-
-==============
-FirstStartup
-==============
-
-``FirstStartup`` is a module which is invoked on application startup by the Windows Installer,
-to initialize services before the first application window appears.
-
-This is useful for:
-
-- one-time performance tuning
-- downloading critical data (hotfixes, experiments, etc)
-
-Blocking until the first Application window appears is important because the Installer
-will show a progress bar until this happens. This gives a user experience of:
-
-1. User downloads and starts the Windows Stub Installer.
-2. Progress bar advances while the application is downloaded and installed.
-3. Installer invokes the application with ``--first-startup``.
-4. Application window appears, and the installer window closes.
-
-Overall, the user experiences a very fast first-startup, with critical tasks that normally
-would be deferred until after UI startup already complete.
-
-.. _FirstStartup Architecture:
-
-FirstStartup: Example use case
-==============================
-
-An example use of the ``FirstStartup`` module is to invoke the Normandy client to download an experiment
-that will be used to customize the first-run page that Firefox shows.
-
-In this example, the first-run page would be loaded experimentally based on an attribution code provided
-by the Installer. The flow for this looks like:
-
-1. User clicks on download link containing an attribution (UTM) code(s).
-2. The download page serves a custom Windows Stub Installer with the appropriate attribution code embedded.
-3. The installer invokes Firefox with the `--first-startup` flag, which blocks the first window.
-4. Normandy is run by ``FirstStartup`` and downloads a list of available experiments, or "recipes".
-5. Recipes are evaluated and filtered based on local information, such as the OS platform and the attribution codes.
-6. A recipe is found which matches the current attribution code, and appropriate data is made available to the first-run page.
-7. ``FirstStartup`` completes and unblocks, which causes Firefox to show the first window and load the appropriate first-run data.
-
-List of phases
-==============
-
-``FirstStartup.NOT_STARTED``
-
-  The ``FirstStartup`` module has not been initalized (the ``init()``
-  function has not been called). This is the default state.
-
-``FirstStartup.IN_PROGRESS``
-
-  ``FirstStartup.init()`` has been called, and the event loop is
-  spinning. This state will persist until either all startup tasks
-  have finished, or time-out has been reached.
-
-  The time-out defaults to 5 seconds, but is configurable via the
-  ``first-startup.timeout`` pref, which is specified in milliseconds.
-
-``FirstStartup.TIMED_OUT``
-
-  The time-out has been reached before startup tasks are complete.
-
-  This status code is reported to Telemetry via the ``firstStartup.statusCode``
-  scalar.
-
-``FirstStartup.SUCCESS``
-
-  All startup tasks have completed successfully, and application startup may resume.
-
-  This status code is reported to Telemetry via the ``firstStartup.statusCode``
-  scalar.
--- a/toolkit/modules/docs/index.rst
+++ b/toolkit/modules/docs/index.rst
@@ -3,9 +3,8 @@ Toolkit Modules
 ===============
 
 The ``/toolkit/modules`` directory contains a number of self-contained toolkit modules considered small enough that they do not deserve individual directories.
 
 .. toctree::
   :maxdepth: 1
 
   AsyncShutdown
-  FirstStartup
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -183,17 +183,16 @@ EXTRA_JS_MODULES += [
     'E10SUtils.jsm',
     'EventEmitter.jsm',
     'FileUtils.jsm',
     'FindBarContent.jsm',
     'Finder.jsm',
     'FinderHighlighter.jsm',
     'FinderIterator.jsm',
     'FinderParent.jsm',
-    'FirstStartup.jsm',
     'FormLikeFactory.jsm',
     'Geometry.jsm',
     'GMPExtractorWorker.js',
     'GMPInstallManager.jsm',
     'GMPUtils.jsm',
     'HiddenFrame.jsm',
     'Http.jsm',
     'IgnoreLists.jsm',
deleted file mode 100644
--- a/toolkit/modules/tests/xpcshell/test_firstStartup.js
+++ /dev/null
@@ -1,29 +0,0 @@
-"use strict";
-
-const { FirstStartup } = ChromeUtils.import(
-  "resource://gre/modules/FirstStartup.jsm"
-);
-
-const PREF_TIMEOUT = "first-startup.timeout";
-const PROBE_NAME = "firstStartup.statusCode";
-
-add_task(async function test_success() {
-  FirstStartup.init();
-  equal(FirstStartup.state, FirstStartup.SUCCESS);
-
-  const scalars = Services.telemetry.getSnapshotForScalars("main", false)
-    .parent;
-  ok(PROBE_NAME in scalars);
-  equal(scalars[PROBE_NAME], FirstStartup.SUCCESS);
-});
-
-add_task(async function test_timeout() {
-  Services.prefs.setIntPref(PREF_TIMEOUT, 0);
-  FirstStartup.init();
-  equal(FirstStartup.state, FirstStartup.TIMED_OUT);
-
-  const scalars = Services.telemetry.getSnapshotForScalars("main", false)
-    .parent;
-  ok(PROBE_NAME in scalars);
-  equal(scalars[PROBE_NAME], FirstStartup.TIMED_OUT);
-});
--- a/toolkit/modules/tests/xpcshell/xpcshell.ini
+++ b/toolkit/modules/tests/xpcshell/xpcshell.ini
@@ -67,9 +67,8 @@ reason = LOCALE is not defined without M
 [test_web_channel.js]
 [test_web_channel_broker.js]
 [test_ZipUtils.js]
 skip-if = toolkit == 'android'
 [test_Log_stackTrace.js]
 [test_servicerequest_xhr.js]
 [test_EventEmitter.js]
 [test_ProfileAge.js]
-[test_firstStartup.js]