Bug 1429083 - Lazily load uuid-generator in proxy module. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Tue, 09 Jan 2018 15:37:57 +0000
changeset 717795 95a7f83c21a106144929bf50ed6ba258dca84782
parent 717738 6f5fac320fcb6625603fa8a744ffa8523f8b3d71
child 745344 ae1044f0049ddcda556d6629c468e2df8f88c2e3
push id94777
push userbmo:ato@sny.no
push dateTue, 09 Jan 2018 16:08:04 +0000
reviewerswhimboo
bugs1429083
milestone59.0a1
Bug 1429083 - Lazily load uuid-generator in proxy module. r?whimboo The uuid-generator is not always used when the proxy module is imported. This changes it to be lazily loaded so we do not always initialise it. MozReview-Commit-ID: In0oAGDFjWy
testing/marionette/proxy.js
--- a/testing/marionette/proxy.js
+++ b/testing/marionette/proxy.js
@@ -1,30 +1,31 @@
 /* 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/. */
 
 "use strict";
 
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+const {utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const {
   error,
   WebDriverError,
 } = Cu.import("chrome://marionette/content/error.js", {});
 Cu.import("chrome://marionette/content/evaluate.js");
 Cu.import("chrome://marionette/content/modal.js");
 
 this.EXPORTED_SYMBOLS = ["proxy"];
 
-const uuidgen = Cc["@mozilla.org/uuid-generator;1"]
-    .getService(Ci.nsIUUIDGenerator);
+XPCOMUtils.defineLazyServiceGetter(
+    this, "uuidgen", "@mozilla.org/uuid-generator;1", "nsIUUIDGenerator");
 
 const logger = Log.repository.getLogger("Marionette");
 
 // Proxy handler that traps requests to get a property.  Will prioritise
 // properties that exist on the object's own prototype.
 const ownPriorityGetterTrap = {
   get: (obj, prop) => {
     if (obj.hasOwnProperty(prop)) {