Bug 1374686 - Don't import LoginManagerContextMenu.jsm during startup. r=florian draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 20 Jun 2017 14:33:39 -0700
changeset 597739 b14325f800e11d3c7d713658dec07f4315e6dd19
parent 597021 bc9e028dbdc5c2f989175e6816dc864159133aee
child 597740 f3c6cb632d8d4d6796841ca8524da33af779e649
push id65009
push usermozilla@noorenberghe.ca
push dateTue, 20 Jun 2017 21:34:40 +0000
reviewersflorian
bugs1374686
milestone56.0a1
Bug 1374686 - Don't import LoginManagerContextMenu.jsm during startup. r=florian MozReview-Commit-ID: KgCnds50n8j
browser/base/content/nsContextMenu.js
browser/base/content/test/performance/browser_startup.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1,24 +1,25 @@
 /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
 /* 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/. */
 
 Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
-Components.utils.import("resource://gre/modules/LoginManagerContextMenu.jsm");
 Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 
 XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper",
   "resource://gre/modules/LoginHelper.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerContextMenu",
+  "resource://gre/modules/LoginManagerContextMenu.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "WebNavigationFrames",
   "resource://gre/modules/WebNavigationFrames.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
   "resource://gre/modules/ContextualIdentityService.jsm");
 
 var gContextMenuContentData = null;
 
 function openContextMenu(aMessage) {
@@ -141,17 +142,19 @@ nsContextMenu.prototype = {
     this._checkTelemetryForMenu(aXulMenu);
   },
 
   hiding: function CM_hiding() {
     gContextMenuContentData = null;
     InlineSpellCheckerUI.clearSuggestionsFromMenu();
     InlineSpellCheckerUI.clearDictionaryListFromMenu();
     InlineSpellCheckerUI.uninit();
-    LoginManagerContextMenu.clearLoginsFromMenu(document);
+    if (Cu.isModuleLoaded("resource://gre/modules/LoginManagerContextMenu.jsm")) {
+      LoginManagerContextMenu.clearLoginsFromMenu(document);
+    }
 
     // This handler self-deletes, only run it if it is still there:
     if (this._onPopupHiding) {
       this._onPopupHiding();
     }
   },
 
   initItems: function CM_initItems() {
--- a/browser/base/content/test/performance/browser_startup.js
+++ b/browser/base/content/test/performance/browser_startup.js
@@ -85,17 +85,21 @@ const startupPhases = {
       "@mozilla.org/browser/nav-bookmarks-service;1",
       "@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": {},
+  "before handling user events": {blacklist: {
+    modules: new Set([
+      "resource://gre/modules/LoginManagerContextMenu.jsm",
+    ]),
+  }},
 };
 
 function test() {
   if (!AppConstants.NIGHTLY_BUILD && !AppConstants.DEBUG) {
     ok(!("@mozilla.org/test/startuprecorder;1" in Cc),
        "the startup recorder component shouldn't exist in this non-nightly non-debug build.");
     return;
   }