From 8410d7c30067bae5f0668eca14e6948afb5160b5 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 6 Apr 2017 20:14:24 -0700 Subject: [PATCH] Bug 1317697: Lazily initialize Schemas.jsm. r=mixedpuppy MozReview-Commit-ID: 83pKM6lLsra --HG-- extra : rebase_source : 287cedaf1f05da9e63958631f8c9ae61c93c45ed --- toolkit/components/extensions/ExtensionContent.jsm | 1 - toolkit/components/extensions/Schemas.jsm | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/toolkit/components/extensions/ExtensionContent.jsm b/toolkit/components/extensions/ExtensionContent.jsm index 8dfb7f3cb099..048d7adb48a5 100644 --- a/toolkit/components/extensions/ExtensionContent.jsm +++ b/toolkit/components/extensions/ExtensionContent.jsm @@ -1093,7 +1093,6 @@ ExtensionManager = { extensions: new Map(), init() { - Schemas.init(); ExtensionChild.initOnce(); Services.cpmm.addMessageListener("Extension:Startup", this); diff --git a/toolkit/components/extensions/Schemas.jsm b/toolkit/components/extensions/Schemas.jsm index dfbd2b36aebf..8587ee383c5a 100644 --- a/toolkit/components/extensions/Schemas.jsm +++ b/toolkit/components/extensions/Schemas.jsm @@ -2654,6 +2654,10 @@ this.Schemas = { * True if the context has permission for the given namespace. */ checkPermissions(namespace, wrapperFuncs) { + if (!this.initialized) { + this.init(); + } + let ns = this.getNamespace(namespace); if (ns && ns.permissions) { return ns.permissions.some(perm => wrapperFuncs.hasPermission(perm)); @@ -2672,6 +2676,10 @@ this.Schemas = { * interface, which runs the actual functionality of the generated API. */ inject(dest, wrapperFuncs) { + if (!this.initialized) { + this.init(); + } + let context = new InjectionContext(wrapperFuncs); this.rootNamespace.injectInto(dest, context); @@ -2687,6 +2695,10 @@ this.Schemas = { * @returns {object} The normalized object. */ normalize(obj, typeName, context) { + if (!this.initialized) { + this.init(); + } + let [namespaceName, prop] = typeName.split("."); let ns = this.getNamespace(namespaceName); let type = ns.get(prop);