Bug 1332610 - Don't eagerly create Intl.DateTimeFormat in LoginManagerContextMenu.jsm. r=johannh, a=jcristau
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Mon, 23 Jan 2017 11:27:10 -0800
changeset 376273 00ad109ba6a6999b1bb3e205cf3d1af807a4e7c1
parent 376272 d5486b5487e21e05de60ef5ea8ad91a0b067d838
child 376274 33d9f50b95c57b0470e5be4e01f33f6dc5f16c5f
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh, jcristau
bugs1332610
milestone53.0a2
Bug 1332610 - Don't eagerly create Intl.DateTimeFormat in LoginManagerContextMenu.jsm. r=johannh, a=jcristau MozReview-Commit-ID: IuXdWyy4C7b
toolkit/components/passwordmgr/LoginManagerContextMenu.jsm
--- a/toolkit/components/passwordmgr/LoginManagerContextMenu.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContextMenu.jsm
@@ -14,33 +14,30 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/LoginHelper.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerParent",
                                   "resource://gre/modules/LoginManagerParent.jsm");
 
 /*
  * Password manager object for the browser contextual menu.
  */
 var LoginManagerContextMenu = {
-  dateAndTimeFormatter: new Intl.DateTimeFormat(undefined,
-                        { day: "numeric", month: "short", year: "numeric" }),
   /**
    * Look for login items and add them to the contextual menu.
    *
    * @param {HTMLInputElement} inputElement
    *        The target input element of the context menu click.
    * @param {xul:browser} browser
    *        The browser for the document the context menu was open on.
    * @param {nsIURI} documentURI
    *        The URI of the document that the context menu was activated from.
    *        This isn't the same as the browser's top-level document URI
    *        when subframes are involved.
    * @returns {DocumentFragment} a document fragment with all the login items.
    */
   addLoginsToMenu(inputElement, browser, documentURI) {
-
     let foundLogins = this._findLogins(documentURI);
 
     if (!foundLogins.length) {
       return null;
     }
 
     let fragment = browser.ownerDocument.createDocumentFragment();
     let duplicateUsernames = this._findDuplicates(foundLogins);
@@ -187,8 +184,16 @@ var LoginManagerContextMenu = {
     return this._stringBundle.GetStringFromName(key);
   },
 };
 
 XPCOMUtils.defineLazyGetter(LoginManagerContextMenu, "_stringBundle", function() {
   return Services.strings.
          createBundle("chrome://passwordmgr/locale/passwordmgr.properties");
 });
+
+XPCOMUtils.defineLazyGetter(LoginManagerContextMenu, "dateAndTimeFormatter", function() {
+  return new Intl.DateTimeFormat(undefined, {
+    day: "numeric",
+    month: "short",
+    year: "numeric",
+  });
+});