Bug 1589340 - Stop leaking LoginHelper into the global scope. r=MattN
authorDão Gottwald <dao@mozilla.com>
Thu, 17 Oct 2019 12:32:03 +0000
changeset 498391 66cd75467ce3492f3756863027008e90549cb0f8
parent 498390 49e3720bafb49406970c5b57dcde998a33d5a077
child 498392 96bb55419dcb5b8a31c3b65ddaaf07ef00b0eba0
push id36717
push usernbeleuzu@mozilla.com
push dateMon, 21 Oct 2019 21:51:55 +0000
treeherdermozilla-central@563f437f24b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1589340
milestone71.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 1589340 - Stop leaking LoginHelper into the global scope. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D49585
toolkit/content/widgets/autocomplete-richlistitem.js
--- a/toolkit/content/widgets/autocomplete-richlistitem.js
+++ b/toolkit/content/widgets/autocomplete-richlistitem.js
@@ -5,21 +5,16 @@
 "use strict";
 
 // This is loaded into all XUL windows. Wrap in a block to prevent
 // leaking to window scope.
 {
   const { Services } = ChromeUtils.import(
     "resource://gre/modules/Services.jsm"
   );
-  ChromeUtils.defineModuleGetter(
-    this,
-    "LoginHelper",
-    "resource://gre/modules/LoginHelper.jsm"
-  );
 
   MozElements.MozAutocompleteRichlistitem = class MozAutocompleteRichlistitem extends MozElements.MozRichlistitem {
     constructor() {
       super();
 
       /**
        * This overrides listitem's mousedown handler because we want to set the
        * selected item even when the shift or accel keys are pressed.
@@ -993,19 +988,24 @@
     constructor() {
       super();
 
       function handleEvent(event) {
         if (event.button != 0) {
           return;
         }
 
+        const { LoginHelper } = ChromeUtils.import(
+          "resource://gre/modules/LoginHelper.jsm"
+        );
+
         // ac-label gets populated from getCommentAt despite the attribute name.
         // The "comment" is used to populate additional visible text.
         let formHostname = this.getAttribute("ac-label");
+
         LoginHelper.openPasswordManager(this.ownerGlobal, {
           filterString: formHostname,
           entryPoint: "autocomplete",
         });
       }
 
       this.addEventListener("click", handleEvent);
     }