Bug 1302898 - Rename 'restrictions' to 'allowedContexts' r=kmag
authorMatthew Wein <mwein@mozilla.com>
Mon, 19 Sep 2016 17:36:46 -0700
changeset 314756 164ce4a8757a5181788924958d0598bed7f45869
parent 314755 d1789329b81f28584d39c4ac1eb5cf94f9a22445
child 314757 f4ffc342eaac01e12e5dd771b3b95a1c95e29985
push id30733
push usercbook@mozilla.com
push dateThu, 22 Sep 2016 09:50:59 +0000
treeherdermozilla-central@4aa20c3e211f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1302898
milestone52.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 1302898 - Rename 'restrictions' to 'allowedContexts' r=kmag All tests pass locally. MozReview-Commit-ID: 5dPPthlPT6i
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/ExtensionUtils.jsm
toolkit/components/extensions/Schemas.jsm
toolkit/components/extensions/schemas/extension.json
toolkit/components/extensions/schemas/i18n.json
toolkit/components/extensions/schemas/runtime.json
toolkit/components/extensions/schemas/storage.json
toolkit/components/extensions/schemas/test.json
toolkit/components/extensions/test/xpcshell/test_ext_schemas_allowed_contexts.js
toolkit/components/extensions/test/xpcshell/test_ext_schemas_restrictions.js
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -693,19 +693,19 @@ GlobalManager = {
       get cloneScope() {
         return context.cloneScope;
       },
 
       hasPermission(permission) {
         return context.extension.hasPermission(permission);
       },
 
-      shouldInject(namespace, name, restrictions) {
+      shouldInject(namespace, name, allowedContexts) {
         // Do not generate content script APIs, unless explicitly allowed.
-        if (context.envType === "content_parent" && !restrictions.includes("content")) {
+        if (context.envType === "content_parent" && !allowedContexts.includes("content")) {
           return false;
         }
         return findPathInObject(apis, namespace) !== null;
       },
 
       getImplementation(namespace, name) {
         let pathObj = findPathInObject(apis, namespace);
         return new LocalAPIImplementation(pathObj, name, context);
--- a/toolkit/components/extensions/ExtensionUtils.jsm
+++ b/toolkit/components/extensions/ExtensionUtils.jsm
@@ -1756,19 +1756,19 @@ class ChildAPIManager {
   close() {
     this.messageManager.sendAsyncMessage("API:CloseProxyContext", {childId: this.id});
   }
 
   get cloneScope() {
     return this.context.cloneScope;
   }
 
-  shouldInject(namespace, name, restrictions) {
+  shouldInject(namespace, name, allowedContexts) {
     // Do not generate content script APIs, unless explicitly allowed.
-    return this.context.envType !== "content_child" || restrictions.includes("content");
+    return this.context.envType !== "content_child" || allowedContexts.includes("content");
   }
 
   getImplementation(namespace, name) {
     let pathObj = this.localApis;
     if (pathObj) {
       for (let part of namespace.split(".")) {
         pathObj = pathObj[part];
         if (!pathObj) {
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/extensions/Schemas.jsm
@@ -336,21 +336,24 @@ class InjectionContext extends Context {
   /**
    * Check whether the API should be injected.
    *
    * @abstract
    * @param {string} namespace The namespace of the API. This may contain dots,
    *     e.g. in the case of "devtools.inspectedWindow".
    * @param {string} [name] The name of the property in the namespace.
    *     `null` if we are checking whether the namespace should be injected.
-   * @param {Array} restrictions An arbitrary list of restrictions as declared
-   *     by the schema for a given API node.
+   * @param {Array<string>} allowedContexts A list of additional contexts in which
+   *     this API should be available. May include any of:
+   *         "main" - The main chrome browser process.
+   *         "addon" - An addon process.
+   *         "content" - A content process.
    * @returns {boolean} Whether the API should be injected.
    */
-  shouldInject(namespace, name, restrictions) {
+  shouldInject(namespace, name, allowedContexts) {
     throw new Error("Not implemented");
   }
 
   /**
    * Generate the implementation for `namespace`.`name`.
    *
    * @abstract
    * @param {string} namespace The full path to the namespace of the API, minus
@@ -465,21 +468,21 @@ class Entry {
      * @property {string} [preprocessor]
      * If set to a string value, and a preprocessor of the same is
      * defined in the validation context, it will be applied to this
      * value prior to any normalization.
      */
     this.preprocessor = schema.preprocess || null;
 
     /**
-     * @property {Array<string>} restrictions A list of restrictions to
-     * consider before generating the API.
+     * @property {Array<string>} allowedContexts A list of allowed contexts
+     * to consider before generating the API.
      * These are not parsed by the schema, but passed to `shouldInject`.
      */
-    this.restrictions = schema.restrictions || [];
+    this.allowedContexts = schema.allowedContexts || [];
   }
 
   /**
    * Preprocess the given value with the preprocessor declared in
    * `preprocessor`.
    *
    * @param {*} value
    * @param {Context} context
@@ -549,17 +552,17 @@ class Entry {
 // schema or else to any type object used throughout the schema.
 class Type extends Entry {
   /**
    * @property {Array<string>} EXTRA_PROPERTIES
    *        An array of extra properties which may be present for
    *        schemas of this type.
    */
   static get EXTRA_PROPERTIES() {
-    return ["description", "deprecated", "preprocess", "restrictions"];
+    return ["description", "deprecated", "preprocess", "allowedContexts"];
   }
 
   /**
    * Parses the given schema object and returns an instance of this
    * class which corresponds to its properties.
    *
    * @param {object} schema
    *        A JSON schema object which corresponds to a definition of
@@ -1420,18 +1423,18 @@ class SubModuleProperty extends Entry {
     if (!type || !(type instanceof SubModuleType)) {
       throw new Error(`Internal error: ${this.namespaceName}.${this.reference} is not a sub-module`);
     }
 
     let functions = type.functions;
     for (let fun of functions) {
       let subpath = path.concat(name);
       let namespace = subpath.join(".");
-      let restrictions = fun.restrictions.length ? fun.restrictions : ns.defaultRestrictions;
-      if (context.shouldInject(namespace, fun.name, restrictions)) {
+      let allowedContexts = fun.allowedContexts.length ? fun.allowedContexts : ns.defaultContexts;
+      if (context.shouldInject(namespace, fun.name, allowedContexts)) {
         let apiImpl = context.getImplementation(namespace, fun.name);
         fun.inject(apiImpl, subpath, fun.name, obj, context);
       }
     }
 
     // TODO: Inject this.properties.
   }
 }
@@ -1651,18 +1654,18 @@ this.Schemas = {
   // This keeps track of all the schemas that have been loaded so far.
   namespaces: new Map(),
 
   register(namespaceName, symbol, value) {
     let ns = this.namespaces.get(namespaceName);
     if (!ns) {
       ns = new Map();
       ns.permissions = null;
-      ns.restrictions = [];
-      ns.defeaultRestrictions = [];
+      ns.allowedContexts = [];
+      ns.defaultContexts = [];
       this.namespaces.set(namespaceName, ns);
     }
     ns.set(symbol, value);
   },
 
   parseSchema(schema, path, extraProperties = []) {
     let allowedProperties = new Set(extraProperties);
 
@@ -1846,18 +1849,18 @@ this.Schemas = {
 
       let events = namespace.events || [];
       for (let event of events) {
         this.loadEvent(name, event);
       }
 
       let ns = this.namespaces.get(name);
       ns.permissions = namespace.permissions || null;
-      ns.restrictions = namespace.restrictions || [];
-      ns.defaultRestrictions = namespace.defaultRestrictions || [];
+      ns.allowedContexts = namespace.allowedContexts || [];
+      ns.defaultContexts = namespace.defaultContexts || [];
     }
   },
 
   load(url) {
     if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_CONTENT) {
       return readJSON(url).then(json => {
         this.schemaJSON.set(url, json);
 
@@ -1915,24 +1918,24 @@ this.Schemas = {
   inject(dest, wrapperFuncs) {
     let context = new InjectionContext(wrapperFuncs);
 
     for (let [namespace, ns] of this.namespaces) {
       if (ns.permissions && !ns.permissions.some(perm => context.hasPermission(perm))) {
         continue;
       }
 
-      if (!wrapperFuncs.shouldInject(namespace, null, ns.restrictions)) {
+      if (!wrapperFuncs.shouldInject(namespace, null, ns.allowedContexts)) {
         continue;
       }
 
       let obj = Cu.createObjectIn(dest, {defineAs: namespace});
       for (let [name, entry] of ns) {
-        let restrictions = entry.restrictions.length ? entry.restrictions : ns.defaultRestrictions;
-        if (context.shouldInject(namespace, name, restrictions)) {
+        let allowedContexts = entry.allowedContexts.length ? entry.allowedContexts : ns.defaultContexts;
+        if (context.shouldInject(namespace, name, allowedContexts)) {
           let apiImpl = context.getImplementation(namespace, name);
           entry.inject(apiImpl, [namespace], name, obj, context);
         }
       }
 
       // Remove the namespace object if it is empty
       if (!Object.keys(obj).length) {
         delete dest[namespace];
--- a/toolkit/components/extensions/schemas/extension.json
+++ b/toolkit/components/extensions/schemas/extension.json
@@ -1,50 +1,50 @@
 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 [
   {
     "namespace": "extension",
-    "restrictions": ["content"],
+    "allowedContexts": ["content"],
     "description": "The <code>browser.extension</code> API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in $(topic:messaging)[Message Passing].",
     "properties": {
       "lastError": {
         "type": "object",
         "optional": true,
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be <var>undefined</var>.",
         "properties": {
           "message": { "type": "string", "description": "Description of the error that has taken place." }
         },
         "additionalProperties": {
           "type": "any"
         }
       },
       "inIncognitoContext": {
         "type": "boolean",
         "optional": true,
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior."
       }
     },
     "types": [
       {
         "id": "ViewType",
         "type": "string",
         "enum": ["tab", "notification", "popup"],
         "description": "The type of extension view."
       }
     ],
     "functions": [
       {
         "name": "getURL",
         "type": "function",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Converts a relative path within an extension install directory to a fully-qualified URL.",
         "parameters": [
           {
             "type": "string",
             "name": "path",
             "description": "A path to a resource within an extension expressed relative to its install directory."
           }
         ],
--- a/toolkit/components/extensions/schemas/i18n.json
+++ b/toolkit/components/extensions/schemas/i18n.json
@@ -14,18 +14,18 @@
             "optional": "true"
           }
         }
       }
     ]
   },
   {
     "namespace": "i18n",
-    "restrictions": ["content"],
-    "defaultRestrictions": ["content"],
+    "allowedContexts": ["content"],
+    "defaultContexts": ["content"],
     "description": "Use the <code>browser.i18n</code> infrastructure to implement internationalization across your whole app or extension.",
     "types": [
       {
         "id": "LanguageCode",
         "type": "string",
         "description": "An ISO language code such as <code>en</code> or <code>fr</code>. For a complete list of languages supported by this method, see <a href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc'>kLanguageInfoTable</a>. For an unknown language, <code>und</code> will be returned, which means that [percentage] of the text is unknown to CLD"
       }
     ],
--- a/toolkit/components/extensions/schemas/runtime.json
+++ b/toolkit/components/extensions/schemas/runtime.json
@@ -14,23 +14,23 @@
             "nativeMessaging"
           ]
         }]
       }
     ]
   },
   {
     "namespace": "runtime",
-    "restrictions": ["content"],
+    "allowedContexts": ["content"],
     "description": "Use the <code>browser.runtime</code> API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.",
     "types": [
       {
         "id": "Port",
         "type": "object",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "An object which allows two way communication with other pages.",
         "properties": {
           "name": {"type": "string"},
           "disconnect": { "type": "function" },
           "onDisconnect": { "$ref": "events.Event" },
           "onMessage": { "$ref": "events.Event" },
           "postMessage": {"type": "function"},
           "sender": {
@@ -39,44 +39,44 @@
             "description": "This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners."
           }
         },
         "additionalProperties": { "type": "any"}
       },
       {
         "id": "MessageSender",
         "type": "object",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "An object containing information about the script context that sent a message or request.",
         "properties": {
           "tab": {"$ref": "tabs.Tab", "optional": true, "description": "The $(ref:tabs.Tab) which opened the connection, if any. This property will <strong>only</strong> be present when the connection was opened from a tab (including content scripts), and <strong>only</strong> if the receiver is an extension, not an app."},
           "frameId": {"type": "integer", "optional": true, "description": "The $(topic:frame_ids)[frame] that opened the connection. 0 for top-level frames, positive for child frames. This will only be set when <code>tab</code> is set."},
           "id": {"type": "string", "optional": true, "description": "The ID of the extension or app that opened the connection, if any."},
           "url": {"type": "string", "optional": true, "description": "The URL of the page or frame that opened the connection. If the sender is in an iframe, it will be iframe's URL not the URL of the page which hosts it."},
           "tlsChannelId": {"unsupported": true, "type": "string", "optional": true, "description": "The TLS channel ID of the page or frame that opened the connection, if requested by the extension or app, and if available."}
         }
       },
       {
         "id": "PlatformOs",
         "type": "string",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "The operating system the browser is running on.",
         "enum": ["mac", "win", "android", "cros", "linux", "openbsd"]
       },
       {
         "id": "PlatformArch",
         "type": "string",
         "enum": ["arm", "x86-32", "x86-64"],
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "The machine's processor architecture."
       },
       {
         "id": "PlatformInfo",
         "type": "object",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "An object containing information about the current platform.",
         "properties": {
           "os": {
             "$ref": "PlatformOs",
             "description": "The operating system the browser is running on."
           },
           "arch": {
             "$ref": "PlatformArch",
@@ -111,54 +111,54 @@
             "description": "The browser's build ID/date, for example '20160101'."
           }
         }
       },
       {
         "id": "RequestUpdateCheckStatus",
         "type": "string",
         "enum": ["throttled", "no_update", "update_available"],
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Result of the update check."
       },
       {
         "id": "OnInstalledReason",
         "type": "string",
         "enum": ["install", "update", "chrome_update", "shared_module_update"],
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "The reason that this event is being dispatched."
       },
       {
         "id": "OnRestartRequiredReason",
         "type": "string",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "The reason that the event is being dispatched. 'app_update' is used when the restart is needed because the application is updated to a newer version. 'os_update' is used when the restart is needed because the browser/OS is updated to a newer version. 'periodic' is used when the system runs for more than the permitted uptime set in the enterprise policy.",
         "enum": ["app_update", "os_update", "periodic"]
       }
     ],
     "properties": {
       "lastError": {
         "type": "object",
         "optional": true,
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "This will be defined during an API method callback if there was an error",
         "properties": {
           "message": {
             "optional": true,
             "type": "string",
             "description": "Details about the error which occurred."
           }
         },
         "additionalProperties": {
           "type": "any"
         }
       },
       "id": {
         "type": "string",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "The ID of the extension/app."
       }
     },
     "functions": [
       {
         "name": "getBackgroundPage",
         "type": "function",
         "description": "Retrieves the JavaScript 'window' object for the background page running inside the current extension/app. If the background page is an event page, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set.",
@@ -189,31 +189,31 @@
           "type": "function",
           "name": "callback",
           "parameters": [],
           "optional": true
         }]
       },
       {
         "name": "getManifest",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Returns details about the app or extension from the manifest. The object returned is a serialization of the full $(topic:manifest)[manifest file].",
         "type": "function",
         "parameters": [],
         "returns": {
           "type": "object",
           "properties": {},
           "additionalProperties": { "type": "any" },
           "description": "The manifest details."
         }
       },
       {
         "name": "getURL",
         "type": "function",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Converts a relative path within an app/extension install directory to a fully-qualified URL.",
         "parameters": [
           {
             "type": "string",
             "name": "path",
             "description": "A path to a resource within an app/extension expressed relative to its install directory."
           }
         ],
@@ -286,17 +286,17 @@
         "unsupported": true,
         "description": "Restart the device when the app runs in kiosk mode. Otherwise, it's no-op.",
         "type": "function",
         "parameters": []
       },
       {
         "name": "connect",
         "type": "function",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and $(topic:manifest/externally_connectable)[web messaging]. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).",
         "parameters": [
           {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for $(topic:manifest/externally_connectable)[web messaging]."},
           {
             "type": "object",
             "name": "connectInfo",
             "properties": {
               "name": { "type": "string", "optional": true, "description": "Will be passed into onConnect for processes that are listening for the connection event." },
@@ -326,17 +326,17 @@
           "$ref": "Port",
           "description": "Port through which messages can be sent and received with the application"
         }
       },
       {
         "name": "sendMessage",
         "type": "function",
         "allowAmbiguousOptionalArguments": true,
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Sends a single message to event listeners within your extension/app or a different extension/app. Similar to $(ref:runtime.connect) but only sends a single message, with an optional response. If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime.onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use $(ref:tabs.sendMessage).",
         "async": "responseCallback",
         "parameters": [
           {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for $(topic:manifest/externally_connectable)[web messaging]."},
           { "type": "any", "name": "message" },
           {
             "type": "object",
             "name": "options",
@@ -522,17 +522,17 @@
         "type": "function",
         "description": "Fired when an update for the browser is available, but isn't installed immediately because a browser restart is required.",
         "deprecated": "Please use $(ref:runtime.onRestartRequired).",
         "parameters": []
       },
       {
         "name": "onConnect",
         "type": "function",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Fired when a connection is made from either an extension process or a content script.",
         "parameters": [
           {"$ref": "Port", "name": "port"}
         ]
       },
       {
         "name": "onConnectExternal",
         "unsupported": true,
@@ -540,17 +540,17 @@
         "description": "Fired when a connection is made from another extension.",
         "parameters": [
           {"$ref": "Port", "name": "port"}
         ]
       },
       {
         "name": "onMessage",
         "type": "function",
-        "restrictions": ["content"],
+        "allowedContexts": ["content"],
         "description": "Fired when a message is sent from either an extension process or a content script.",
         "parameters": [
           {"name": "message", "type": "any", "optional": true, "description": "The message sent by the calling script."},
           {"name": "sender", "$ref": "MessageSender" },
           {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." }
         ],
         "returns": {
           "type": "boolean",
--- a/toolkit/components/extensions/schemas/storage.json
+++ b/toolkit/components/extensions/schemas/storage.json
@@ -1,17 +1,17 @@
 // Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 [
   {
     "namespace": "storage",
-    "restrictions": ["content"],
-    "defaultRestrictions": ["content"],
+    "allowedContexts": ["content"],
+    "defaultContexts": ["content"],
     "description": "Use the <code>browser.storage</code> API to store, retrieve, and track changes to user data.",
     "permissions": ["storage"],
     "types": [
       {
         "id": "StorageChange",
         "type": "object",
         "properties": {
           "oldValue": {
--- a/toolkit/components/extensions/schemas/test.json
+++ b/toolkit/components/extensions/schemas/test.json
@@ -1,17 +1,17 @@
 // Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 [
   {
     "namespace": "test",
-    "restrictions": ["content"],
-    "defaultRestrictions": ["content"],
+    "allowedContexts": ["content"],
+    "defaultContexts": ["content"],
     "description": "none",
     "functions": [
       {
         "name": "notifyFail",
         "type": "function",
         "description": "Notifies the browser process that test code running in the extension failed.  This is only used for internal unit testing.",
         "parameters": [
           {"type": "string", "name": "message"}
rename from toolkit/components/extensions/test/xpcshell/test_ext_schemas_restrictions.js
rename to toolkit/components/extensions/test/xpcshell/test_ext_schemas_allowed_contexts.js
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_restrictions.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_schemas_allowed_contexts.js
@@ -1,85 +1,84 @@
 "use strict";
 
 Components.utils.import("resource://gre/modules/Schemas.jsm");
 
 let schemaJson = [
   {
-    namespace: "noRestrict",
+    namespace: "noAllowedContexts",
     properties: {
       prop1: {type: "object"},
-      prop2: {type: "object", restrictions: ["test_zero", "test_one"]},
+      prop2: {type: "object", allowedContexts: ["test_zero", "test_one"]},
       prop3: {type: "number", value: 1},
-      prop4: {type: "number", value: 1, restrictions: ["numeric_one"]},
+      prop4: {type: "number", value: 1, allowedContexts: ["numeric_one"]},
     },
   },
   {
-    namespace: "defaultRestrict",
-    defaultRestrictions: ["test_two"],
+    namespace: "defaultContexts",
+    defaultContexts: ["test_two"],
     properties: {
       prop1: {type: "object"},
-      prop2: {type: "object", restrictions: ["test_three"]},
+      prop2: {type: "object", allowedContexts: ["test_three"]},
       prop3: {type: "number", value: 1},
-      prop4: {type: "number", value: 1, restrictions: ["numeric_two"]},
+      prop4: {type: "number", value: 1, allowedContexts: ["numeric_two"]},
     },
   },
   {
-    namespace: "withRestrict",
-    restrictions: ["test_four"],
+    namespace: "withAllowedContexts",
+    allowedContexts: ["test_four"],
     properties: {
       prop1: {type: "object"},
-      prop2: {type: "object", restrictions: ["test_five"]},
+      prop2: {type: "object", allowedContexts: ["test_five"]},
       prop3: {type: "number", value: 1},
-      prop4: {type: "number", value: 1, restrictions: ["numeric_three"]},
+      prop4: {type: "number", value: 1, allowedContexts: ["numeric_three"]},
     },
   },
   {
-    namespace: "withRestrictAndDefault",
-    restrictions: ["test_six"],
-    defaultRestrictions: ["test_seven"],
+    namespace: "withAllowedContextsAndDefault",
+    allowedContexts: ["test_six"],
+    defaultContexts: ["test_seven"],
     properties: {
       prop1: {type: "object"},
-      prop2: {type: "object", restrictions: ["test_eight"]},
+      prop2: {type: "object", allowedContexts: ["test_eight"]},
       prop3: {type: "number", value: 1},
-      prop4: {type: "number", value: 1, restrictions: ["numeric_four"]},
+      prop4: {type: "number", value: 1, allowedContexts: ["numeric_four"]},
     },
   },
   {
     namespace: "with_submodule",
-    defaultRestrictions: ["test_nine"],
+    defaultContexts: ["test_nine"],
     types: [{
       id: "subtype",
       type: "object",
       functions: [{
-        name: "restrictNo",
+        name: "noAllowedContexts",
         type: "function",
         parameters: [],
       }, {
-        name: "restrictYes",
-        restrictions: ["test_ten"],
+        name: "allowedContexts",
+        allowedContexts: ["test_ten"],
         type: "function",
         parameters: [],
       }],
     }],
     properties: {
       prop1: {$ref: "subtype"},
-      prop2: {$ref: "subtype", restrictions: ["test_eleven"]},
+      prop2: {$ref: "subtype", allowedContexts: ["test_eleven"]},
     },
   },
 ];
 add_task(function* testRestrictions() {
   let url = "data:," + JSON.stringify(schemaJson);
   yield Schemas.load(url);
   let results = {};
   let localWrapper = {
-    shouldInject(ns, name, restrictions) {
-      restrictions = restrictions ? restrictions.join() : "none";
+    shouldInject(ns, name, allowedContexts) {
       name = name === null ? ns : ns + "." + name;
-      results[name] = restrictions;
+      results[name] = allowedContexts.join();
       return true;
     },
     getImplementation() {
       // The actual implementation is not significant for this test.
       // Let's take this opportunity to see if schema generation is free of
       // exceptions even when somehow getImplementation does not return an
       // implementation.
     },
@@ -88,52 +87,52 @@ add_task(function* testRestrictions() {
   let root = {};
   Schemas.inject(root, localWrapper);
 
   function verify(path, expected) {
     let result = results[path];
     do_check_eq(result, expected);
   }
 
-  verify("noRestrict", "none");
-  verify("noRestrict.prop1", "none");
-  verify("noRestrict.prop2", "test_zero,test_one");
-  verify("noRestrict.prop3", "none");
-  verify("noRestrict.prop4", "numeric_one");
+  verify("noAllowedContexts", "");
+  verify("noAllowedContexts.prop1", "");
+  verify("noAllowedContexts.prop2", "test_zero,test_one");
+  verify("noAllowedContexts.prop3", "");
+  verify("noAllowedContexts.prop4", "numeric_one");
 
-  verify("defaultRestrict", "none");
-  verify("defaultRestrict.prop1", "test_two");
-  verify("defaultRestrict.prop2", "test_three");
-  verify("defaultRestrict.prop3", "test_two");
-  verify("defaultRestrict.prop4", "numeric_two");
+  verify("defaultContexts", "");
+  verify("defaultContexts.prop1", "test_two");
+  verify("defaultContexts.prop2", "test_three");
+  verify("defaultContexts.prop3", "test_two");
+  verify("defaultContexts.prop4", "numeric_two");
 
-  verify("withRestrict", "test_four");
-  verify("withRestrict.prop1", "none");
-  verify("withRestrict.prop2", "test_five");
-  verify("withRestrict.prop3", "none");
-  verify("withRestrict.prop4", "numeric_three");
+  verify("withAllowedContexts", "test_four");
+  verify("withAllowedContexts.prop1", "");
+  verify("withAllowedContexts.prop2", "test_five");
+  verify("withAllowedContexts.prop3", "");
+  verify("withAllowedContexts.prop4", "numeric_three");
 
-  verify("withRestrictAndDefault", "test_six");
-  verify("withRestrictAndDefault.prop1", "test_seven");
-  verify("withRestrictAndDefault.prop2", "test_eight");
-  verify("withRestrictAndDefault.prop3", "test_seven");
-  verify("withRestrictAndDefault.prop4", "numeric_four");
+  verify("withAllowedContextsAndDefault", "test_six");
+  verify("withAllowedContextsAndDefault.prop1", "test_seven");
+  verify("withAllowedContextsAndDefault.prop2", "test_eight");
+  verify("withAllowedContextsAndDefault.prop3", "test_seven");
+  verify("withAllowedContextsAndDefault.prop4", "numeric_four");
 
-  verify("with_submodule", "none");
+  verify("with_submodule", "");
   verify("with_submodule.prop1", "test_nine");
-  verify("with_submodule.prop1.restrictNo", "test_nine");
-  verify("with_submodule.prop1.restrictYes", "test_ten");
+  verify("with_submodule.prop1.noAllowedContexts", "test_nine");
+  verify("with_submodule.prop1.allowedContexts", "test_ten");
   verify("with_submodule.prop2", "test_eleven");
-  // Note: test_nine inherits restrictions from the namespace, not from
-  // submodule. There is no "defaultRestrictions" for submodule types to not
+  // Note: test_nine inherits allowed contexts from the namespace, not from
+  // submodule. There is no "defaultContexts" for submodule types to not
   // complicate things.
-  verify("with_submodule.prop1.restrictNo", "test_nine");
-  verify("with_submodule.prop1.restrictYes", "test_ten");
+  verify("with_submodule.prop1.noAllowedContexts", "test_nine");
+  verify("with_submodule.prop1.allowedContexts", "test_ten");
 
   // This is a constant, so it does not matter that getImplementation does not
   // return an implementation since the API injector should take care of it.
-  do_check_eq(root.noRestrict.prop3, 1);
+  do_check_eq(root.noAllowedContexts.prop3, 1);
 
-  Assert.throws(() => root.noRestrict.prop1,
+  Assert.throws(() => root.noAllowedContexts.prop1,
                 /undefined/,
                 "Should throw when the implementation is absent.");
 });
 
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -47,17 +47,17 @@ skip-if = release_build
 [test_ext_runtime_getBrowserInfo.js]
 [test_ext_runtime_getPlatformInfo.js]
 [test_ext_runtime_sendMessage.js]
 [test_ext_runtime_sendMessage_errors.js]
 [test_ext_runtime_sendMessage_no_receiver.js]
 [test_ext_runtime_sendMessage_self.js]
 [test_ext_schemas.js]
 [test_ext_schemas_api_injection.js]
-[test_ext_schemas_restrictions.js]
+[test_ext_schemas_allowed_contexts.js]
 [test_ext_simple.js]
 [test_ext_storage.js]
 [test_getAPILevelForWindow.js]
 [test_ext_legacy_extension_context.js]
 [test_ext_legacy_extension_embedding.js]
 [test_locale_converter.js]
 [test_locale_data.js]
 [test_native_messaging.js]