Bug 1250191 - Load 3rd party lazily, r=MattN
MozReview-Commit-ID: 8s8U0hCyM8C
--- a/services/common/canonical-json.js
+++ b/services/common/canonical-json.js
@@ -1,17 +1,19 @@
/* 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/. */
-const {utils: Cu} = Components;
-
this.EXPORTED_SYMBOLS = ["CanonicalJSON"];
-Cu.import("resource://gre/modules/third_party/jsesc/jsesc.js");
+const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "jsesc",
+ "resource://gre/modules/third_party/jsesc/jsesc.js");
this.CanonicalJSON = {
/**
* Return the canonical JSON form of the passed source, sorting all the object
* keys recursively.
*
* @param source
* The elements to be serialized.
--- a/services/common/tests/unit/test_canonicaljson.js
+++ b/services/common/tests/unit/test_canonicaljson.js
@@ -1,11 +1,8 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
const { CanonicalJSON } = Cu.import("resource://services-common/canonical-json.js");
function stringRepresentation(obj) {
const clone = JSON.parse(JSON.stringify(obj));
return JSON.stringify(clone);
}
add_task(function* test_canonicalJSON_should_preserve_array_order() {