Bug 1372326 - record services initialized during startup, r=mconley.
authorFlorian Quèze <florian@queze.net>
Tue, 13 Jun 2017 08:39:39 +0200
changeset 363576 7dcddc1452deac146e58b32d5c2a8afe4bf2b903
parent 363575 2d3d1741941f1c1407500cb417ce38a1ade82b2e
child 363577 24549b6535ec3c7763d0030565682c6c809925df
push id91364
push userflorian@queze.net
push dateTue, 13 Jun 2017 06:40:02 +0000
treeherdermozilla-inbound@321e5a4f37b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1372326
milestone56.0a1
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
Bug 1372326 - record services initialized during startup, r=mconley.
browser/base/content/test/performance/browser_startup.js
browser/components/tests/startupRecorder.js
--- a/browser/base/content/test/performance/browser_startup.js
+++ b/browser/base/content/test/performance/browser_startup.js
@@ -51,16 +51,19 @@ const startupPhases = {
 
   // We reach this phase right after showing the first browser window.
   // This means that anything already loaded at this point has been loaded
   // before first paint and delayed it.
   "before first paint": {blacklist: {
     components: new Set([
       "nsSearchService.js",
       "UnifiedComplete.js",
+    ]),
+    services: new Set([
+      "@mozilla.org/browser/search-service;1",
     ])
   }},
 
   // We are at this phase once we are ready to handle user events.
   // Anything loaded at this phase or before gets in the way of the user
   // interacting with the first browser window.
   "before handling user events": {},
 };
@@ -97,17 +100,17 @@ function test() {
     }
     previous = phase;
   }
 
   for (let phase in startupPhases) {
     let loadedList = data[phase];
     let whitelist = startupPhases[phase].whitelist || null;
     if (whitelist) {
-      for (let scriptType in loadedList) {
+      for (let scriptType in whitelist) {
         loadedList[scriptType] = loadedList[scriptType].filter(c => {
           if (!whitelist[scriptType].has(c))
             return true;
           whitelist[scriptType].delete(c);
           return false;
         });
         is(loadedList[scriptType].length, 0,
            `should have no unexpected ${scriptType} loaded ${phase}`);
--- a/browser/components/tests/startupRecorder.js
+++ b/browser/components/tests/startupRecorder.js
@@ -1,13 +1,14 @@
 /* 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/. */
 
-const {classes: Cc, utils: Cu, interfaces: Ci} = Components;
+const {classes: Cc, utils: Cu, interfaces: Ci, manager: Cm} = Components;
+Cm.QueryInterface(Ci.nsIServiceManager);
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/AppConstants.jsm");
 
 let firstPaintNotification = "widget-first-paint";
 // widget-first-paint fires much later than expected on Linux.
 if (AppConstants.platform == "linux")
@@ -30,17 +31,25 @@ function startupRecorder() {
 startupRecorder.prototype = {
   classID: Components.ID("{11c095b2-e42e-4bdf-9dd0-aed87595f6a4}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
 
   record(name) {
     this.data[name] = {
       components: this.loader.loadedComponents(),
-      modules: this.loader.loadedModules()
+      modules: this.loader.loadedModules(),
+      services: Object.keys(Cc).filter(c => {
+        try {
+          Cm.isServiceInstantiatedByContractID(c, Ci.nsISupports);
+          return true;
+        } catch (e) {
+          return false;
+        }
+      })
     };
   },
 
   observe(subject, topic, data) {
 
     if (topic == "app-startup") {
       // We can't ensure our observer will be called first or last, so the list of
       // topics we observe here should avoid the topics used to trigger things