Bug 1425688 - Rework definitions of Cu/Cc/etc and inclusion of Services.jsm in pippki.js related files to reduce duplication. r=keeler
authorMark Banner <standard8@mozilla.com>
Sat, 16 Dec 2017 12:52:53 -0600
changeset 448927 bd2bf7b7fead94ac8483f811abd26c517c7989da
parent 448926 a618b142d9dceb8530128e7dbc48deb3d27a3e89
child 448928 f73324a4d03387924eccf434e56a8844e361823a
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler
bugs1425688
milestone59.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 1425688 - Rework definitions of Cu/Cc/etc and inclusion of Services.jsm in pippki.js related files to reduce duplication. r=keeler MozReview-Commit-ID: 1BN0Z5lOKYh
security/manager/pki/resources/content/certManager.js
security/manager/pki/resources/content/certViewer.js
security/manager/pki/resources/content/certViewer.xul
security/manager/pki/resources/content/clientauthask.js
security/manager/pki/resources/content/deletecert.js
security/manager/pki/resources/content/deletecert.xul
security/manager/pki/resources/content/downloadcert.js
security/manager/pki/resources/content/downloadcert.xul
security/manager/pki/resources/content/editcacert.js
security/manager/pki/resources/content/load_device.js
security/manager/pki/resources/content/pippki.js
--- a/security/manager/pki/resources/content/certManager.js
+++ b/security/manager/pki/resources/content/certManager.js
@@ -1,16 +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/. */
 /* import-globals-from pippki.js */
 "use strict";
 
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
 const nsIFilePicker = Components.interfaces.nsIFilePicker;
 const nsFilePicker = "@mozilla.org/filepicker;1";
 const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
 const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
 const nsIX509Cert = Components.interfaces.nsIX509Cert;
 const nsICertTree = Components.interfaces.nsICertTree;
 const nsCertTree = "@mozilla.org/security/nsCertTree;1";
 
--- a/security/manager/pki/resources/content/certViewer.js
+++ b/security/manager/pki/resources/content/certViewer.js
@@ -1,24 +1,23 @@
 /* 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/. */
+
+/* import-globals-from pippki.js */
 "use strict";
 
 /**
  * @file Implements functionality for certViewer.xul and its tabs certDump.xul
  *       and viewCertDetails.xul: a dialog that allows various attributes of a
  *       certificate to be viewed.
  * @argument {nsISupports} window.arguments[0]
  *           The cert to view, queryable to nsIX509Cert.
  */
 
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
-
 const nsIX509Cert = Ci.nsIX509Cert;
 const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
 const nsIX509CertDB = Ci.nsIX509CertDB;
 const nsPK11TokenDB = "@mozilla.org/security/pk11tokendb;1";
 const nsIPK11TokenDB = Ci.nsIPK11TokenDB;
 const nsIASN1Object = Ci.nsIASN1Object;
 const nsIASN1Sequence = Ci.nsIASN1Sequence;
 const nsIASN1PrintableItem = Ci.nsIASN1PrintableItem;
--- a/security/manager/pki/resources/content/certViewer.xul
+++ b/security/manager/pki/resources/content/certViewer.xul
@@ -15,19 +15,19 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   buttons="accept"
   buttonlabelaccept="&certmgr.close.label;"
   buttonaccesskeyaccept="&certmgr.close.accesskey;"
   onload="setWindowName();">
 
 <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 
+<script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
 <script type="application/javascript"
         src="chrome://pippki/content/certViewer.js"/>
-<script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
 
   <tabbox flex="1">
     <tabs>
       <tab id="general_tab" label="&certmgr.detail.general_tab.title;"
            accesskey="&certmgr.detail.general_tab.accesskey;"/>
       <tab id="prettyprint_tab" label="&certmgr.detail.prettyprint_tab.title;"
            accesskey="&certmgr.detail.prettyprint_tab.accesskey;"/>
     </tabs>
--- a/security/manager/pki/resources/content/clientauthask.js
+++ b/security/manager/pki/resources/content/clientauthask.js
@@ -34,20 +34,16 @@
  * @property {Boolean} rememberSelection
  *           Set to true if the user wanted their cert selection to be
  *           remembered, false otherwise.
  * @property {Number} selectedIndex
  *           The index the chosen cert is at for the given cert list. Undefined
  *           value if |certChosen| is not true.
  */
 
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
-
 /**
  * The pippki <stringbundle> element.
  * @type <stringbundle>
  */
 var bundle;
 /**
  * The array of certs the user can choose from.
  * @type nsIArray<nsIX509Cert>
--- a/security/manager/pki/resources/content/deletecert.js
+++ b/security/manager/pki/resources/content/deletecert.js
@@ -18,18 +18,16 @@
 /**
  * @typedef DeleteCertReturnValues
  * @type Object
  * @property {Boolean} deleteConfirmed
  *           Set to true if the user confirmed deletion of the given certs,
  *           false otherwise.
  */
 
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
 /**
  * Returns the most appropriate string to represent the given nsICertTreeItem.
  * @param {nsICertTreeItem} certTreeItem
  *        The item to represent.
  * @returns {String}
  *          A representative string.
  */
 function certTreeItemToString(certTreeItem) {
--- a/security/manager/pki/resources/content/deletecert.xul
+++ b/security/manager/pki/resources/content/deletecert.xul
@@ -12,17 +12,17 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   onload="onLoad();"
   buttons="accept,cancel"
   ondialogaccept="return onDialogAccept();"
   ondialogcancel="return onDialogCancel();">
 
   <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 
+  <script type="application/javascript" src="pippki.js" />
   <script type="application/javascript" src="chrome://pippki/content/deletecert.js"/>
-  <script type="application/javascript" src="pippki.js" />
 
   <description id="confirm" style="width: 400px;"/>
   <richlistbox id="certlist" class="box-padded" flex="1"
                style="min-height: 8em; height: 8em; min-width: 35em;"/>
   <description id="impact" style="width: 400px;"/>
 
 </dialog>
--- a/security/manager/pki/resources/content/downloadcert.js
+++ b/security/manager/pki/resources/content/downloadcert.js
@@ -24,18 +24,16 @@
  * @property {Boolean} trustForSSL
  *           Set to true if the cert should be trusted for SSL, false otherwise.
  *           Undefined value if |importConfirmed| is not true.
  * @property {Boolean} trustForEmail
  *           Set to true if the cert should be trusted for e-mail, false
  *           otherwise. Undefined value if |importConfirmed| is not true.
  */
 
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
 /**
  * The cert to potentially import.
  * @type nsIX509Cert
  */
 var gCert;
 
 /**
  * onload() handler.
--- a/security/manager/pki/resources/content/downloadcert.xul
+++ b/security/manager/pki/resources/content/downloadcert.xul
@@ -13,18 +13,18 @@
         style="width: 46em;"
         buttons="accept,cancel"
         ondialogaccept="return onDialogAccept();"
         ondialogcancel="return onDialogCancel();"
         onload="onLoad();">
 
 <stringbundle id="pippki_bundle" src="chrome://pippki/locale/pippki.properties"/>
 
+<script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
 <script type="application/javascript" src="chrome://pippki/content/downloadcert.js"/>
-<script type="application/javascript" src="chrome://pippki/content/pippki.js"/>
 
 
   <!--  Let 'em know what they're doing -->
   <vbox>
     <description>&downloadCert.message1;</description>
   </vbox>
 
   <separator/>
--- a/security/manager/pki/resources/content/editcacert.js
+++ b/security/manager/pki/resources/content/editcacert.js
@@ -1,16 +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/. */
 /* import-globals-from pippki.js */
 "use strict";
 
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
 var gCertDB = Cc["@mozilla.org/security/x509certdb;1"]
                 .getService(Ci.nsIX509CertDB);
 /**
  * Cert to edit the trust of.
  * @type nsIX509Cert
  */
 var gCert;
 
--- a/security/manager/pki/resources/content/load_device.js
+++ b/security/manager/pki/resources/content/load_device.js
@@ -4,20 +4,16 @@
 /* import-globals-from pippki.js */
 "use strict";
 
 /**
  * @file Implements the functionality of load_device.xul: a dialog that allows
  *       a PKCS #11 module to be loaded into Firefox.
  */
 
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
-
 function onBrowseBtnPress() {
   let bundle = document.getElementById("pippki_bundle");
   let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
   fp.init(window, bundle.getString("loadPK11ModuleFilePickerTitle"),
           Ci.nsIFilePicker.modeOpen);
   fp.appendFilters(Ci.nsIFilePicker.filterAll);
   fp.open(rv => {
     if (rv == Ci.nsIFilePicker.returnOK) {
--- a/security/manager/pki/resources/content/pippki.js
+++ b/security/manager/pki/resources/content/pippki.js
@@ -5,16 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 /*
  * These are helper functions to be included
  * pippki UI js files.
  */
 
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
+const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+
 function setText(id, value) {
   let element = document.getElementById(id);
   if (!element) {
     return;
   }
   if (element.hasChildNodes()) {
     element.firstChild.remove();
   }