Commit 78609e83 authored by Kris Maglione's avatar Kris Maglione
Browse files

Bug 1393621: Part 1 - Don't load ext-contextualIdentities at startup without permissions. r=zombie

MozReview-Commit-ID: AiIYAXSRrii

--HG--
extra : rebase_source : 5004ef9b90391be2ae06a1b610b8922e2a091ffa
parent f4d5c234
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -917,6 +917,10 @@ class CanOfAPIs {
 *       its appropriate event handler method to be called. Currently
 *       only accepts "startup".
 *
 * @property {Array<string>} permissions
 *       An optional list of permissions, any of which must be present
 *       in order for the module to load.
 *
 * @property {Array<Array<string>>} paths
 *       A list of paths from the root API object which, when accessed,
 *       will cause the API module to be instantiated and injected.
@@ -1219,6 +1223,10 @@ class SchemaAPIManager extends EventEmitter {
  _checkGetAPI(name, extension, scope = null) {
    let module = this.modules.get(name);

    if (module.permissions && !module.permissions.some(perm => extension.hasPermission(perm))) {
      return false;
    }

    if (!scope) {
      return true;
    }
+3 −1
Original line number Diff line number Diff line
@@ -80,7 +80,9 @@ let apiManager = new class extends SchemaAPIManager {
      let promises = [];
      for (let apiName of this.eventModules.get("startup")) {
        promises.push(this.asyncGetAPI(apiName, extension).then(api => {
          if (api) {
            api.onStartup(extension.startupReason);
          }
        }));
      }

+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
    "schema": "chrome://extensions/content/schemas/contextual_identities.json",
    "scopes": ["addon_parent"],
    "events": ["startup"],
    "permissions": ["contextualIdentities"],
    "paths": [
      ["contextualIdentities"]
    ]