Bug 1285063 - Part 2: Switch to using the Category Manager to register scripts/schemas in order to load them in time for Fennec. r=kmag
authorMatthew Wein <mwein@mozilla.com>
Fri, 22 Jul 2016 12:44:40 -0700
changeset 346941 e9ca8dc4b42e341a9ecc451f9033ce2947418b41
parent 346940 e3a7713a67355531701df9c0baab805c539aa26c
child 346942 47426821ace445d4c9fa24c4cffe3be9e1c6f3b1
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1285063
milestone50.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 1285063 - Part 2: Switch to using the Category Manager to register scripts/schemas in order to load them in time for Fennec. r=kmag MozReview-Commit-ID: 2U8cTYeH8kg
browser/components/extensions/ext-bookmarks.js
browser/components/extensions/ext-history.js
browser/components/extensions/extensions-browser.manifest
browser/components/extensions/moz.build
browser/components/extensions/test/xpcshell/head.js
browser/components/nsBrowserGlue.js
browser/installer/package-manifest.in
mobile/android/chrome/content/browser.js
mobile/android/components/extensions/extensions-mobile.manifest
mobile/android/components/extensions/moz.build
mobile/android/installer/package-manifest.in
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/ExtensionManagement.jsm
toolkit/components/extensions/Schemas.jsm
toolkit/components/extensions/extensions-toolkit.manifest
toolkit/components/extensions/moz.build
--- a/browser/components/extensions/ext-bookmarks.js
+++ b/browser/components/extensions/ext-bookmarks.js
@@ -1,18 +1,20 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
-Cu.import("resource://gre/modules/PlacesUtils.jsm");
-var Bookmarks = PlacesUtils.bookmarks;
+Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 
-Cu.import("resource://gre/modules/ExtensionUtils.jsm");
+XPCOMUtils.defineLazyGetter(this, "Bookmarks", () => {
+  Cu.import("resource://gre/modules/PlacesUtils.jsm");
+  return PlacesUtils.bookmarks;
+});
 
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 
 function getTree(rootGuid, onlyChildren) {
   function convert(node, parent) {
     let treenode = {
       id: node.guid,
--- a/browser/components/extensions/ext-history.js
+++ b/browser/components/extensions/ext-history.js
@@ -1,33 +1,38 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
-Cu.import("resource://gre/modules/PlacesUtils.jsm");
+
+XPCOMUtils.defineLazyGetter(this, "History", () => {
+  Cu.import("resource://gre/modules/PlacesUtils.jsm");
+  return PlacesUtils.history;
+});
+
 XPCOMUtils.defineLazyModuleGetter(this, "EventEmitter",
                                   "resource://devtools/shared/event-emitter.js");
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
 
 const {
   normalizeTime,
   SingletonEventManager,
 } = ExtensionUtils;
 
-const History = PlacesUtils.history;
+let nsINavHistoryService = Ci.nsINavHistoryService;
 const TRANSITION_TO_TRANSITION_TYPES_MAP = new Map([
-  ["link", History.TRANSITION_LINK],
-  ["typed", History.TRANSITION_TYPED],
-  ["auto_bookmark", History.TRANSITION_BOOKMARK],
-  ["auto_subframe", History.TRANSITION_EMBED],
-  ["manual_subframe", History.TRANSITION_FRAMED_LINK],
+  ["link", nsINavHistoryService.TRANSITION_LINK],
+  ["typed", nsINavHistoryService.TRANSITION_TYPED],
+  ["auto_bookmark", nsINavHistoryService.TRANSITION_BOOKMARK],
+  ["auto_subframe", nsINavHistoryService.TRANSITION_EMBED],
+  ["manual_subframe", nsINavHistoryService.TRANSITION_FRAMED_LINK],
 ]);
 
 let TRANSITION_TYPE_TO_TRANSITIONS_MAP = new Map();
 for (let [transition, transitionType] of TRANSITION_TO_TRANSITION_TYPES_MAP) {
   TRANSITION_TYPE_TO_TRANSITIONS_MAP.set(transitionType, transition);
 }
 
 function getTransitionType(transition) {
@@ -118,17 +123,17 @@ function getObserver() {
       onPageChanged: function() {},
       onFrecencyChanged: function() {},
       onManyFrecenciesChanged: function() {},
       onDeleteVisits: function(uri, time, guid, reason) {
         this.emit("visitRemoved", {allHistory: false, urls: [uri.spec]});
       },
     };
     EventEmitter.decorate(_observer);
-    PlacesUtils.history.addObserver(_observer, false);
+    History.addObserver(_observer, false);
   }
   return _observer;
 }
 
 extensions.registerSchemaAPI("history", (extension, context) => {
   return {
     history: {
       addUrl: function(details) {
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/extensions-browser.manifest
@@ -0,0 +1,22 @@
+# scripts
+category webextension-scripts bookmarks chrome://browser/content/ext-bookmarks.js
+category webextension-scripts browserAction chrome://browser/content/ext-browserAction.js
+category webextension-scripts commands chrome://browser/content/ext-commands.js
+category webextension-scripts contextMenus chrome://browser/content/ext-contextMenus.js
+category webextension-scripts desktop-runtime chrome://browser/content/ext-desktop-runtime.js
+category webextension-scripts history chrome://browser/content/ext-history.js
+category webextension-scripts pageAction chrome://browser/content/ext-pageAction.js
+category webextension-scripts tabs chrome://browser/content/ext-tabs.js
+category webextension-scripts utils chrome://browser/content/ext-utils.js
+category webextension-scripts windows chrome://browser/content/ext-windows.js
+
+# schemas
+category webextension-schemas bookmarks chrome://browser/content/schemas/bookmarks.json
+category webextension-schemas browser_action chrome://browser/content/schemas/browser_action.json
+category webextension-schemas commands chrome://browser/content/schemas/commands.json
+category webextension-schemas context_menus chrome://browser/content/schemas/context_menus.json
+category webextension-schemas context_menus_internal chrome://browser/content/schemas/context_menus_internal.json
+category webextension-schemas history chrome://browser/content/schemas/history.json
+category webextension-schemas page_action chrome://browser/content/schemas/page_action.json
+category webextension-schemas tabs chrome://browser/content/schemas/tabs.json
+category webextension-schemas windows chrome://browser/content/schemas/windows.json
\ No newline at end of file
--- a/browser/components/extensions/moz.build
+++ b/browser/components/extensions/moz.build
@@ -1,12 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 JAR_MANIFESTS += ['jar.mn']
 
+EXTRA_COMPONENTS += [
+    'extensions-browser.manifest',
+]
+
 DIRS += ['schemas']
 
 BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
 XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']
--- a/browser/components/extensions/test/xpcshell/head.js
+++ b/browser/components/extensions/test/xpcshell/head.js
@@ -10,34 +10,29 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/Extension.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Schemas",
                                   "resource://gre/modules/Schemas.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 
-Cu.import("resource://gre/modules/ExtensionManagement.jsm");
-
 /* exported normalizeManifest */
 
 let BASE_MANIFEST = {
   "applications": {"gecko": {"id": "test@web.ext"}},
 
   "manifest_version": 2,
 
   "name": "name",
   "version": "0",
 };
 
-ExtensionManagement.registerSchema("chrome://browser/content/schemas/commands.json");
-
 function* normalizeManifest(manifest, baseManifest = BASE_MANIFEST) {
   const {Management} = Cu.import("resource://gre/modules/Extension.jsm", {});
-
   yield Management.lazyInit();
 
   let errors = [];
   let context = {
     url: null,
 
     logError: error => {
       errors.push(error);
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -153,19 +153,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource:///modules/ReaderParent.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "AddonWatcher",
                                   "resource://gre/modules/AddonWatcher.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
                                   "resource://gre/modules/LightweightThemeManager.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "ExtensionManagement",
-                                  "resource://gre/modules/ExtensionManagement.jsm");
-
 XPCOMUtils.defineLazyModuleGetter(this, "ShellService",
                                   "resource:///modules/ShellService.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry",
                                   "resource://gre/modules/WindowsRegistry.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils",
                                    "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils");
@@ -555,37 +552,16 @@ BrowserGlue.prototype = {
     os.addObserver(this, "flash-plugin-hang", false);
     os.addObserver(this, "xpi-signature-changed", false);
     os.addObserver(this, "autocomplete-did-enter-text", false);
 
     if (AppConstants.NIGHTLY_BUILD) {
       os.addObserver(this, AddonWatcher.TOPIC_SLOW_ADDON_DETECTED, false);
     }
 
-    ExtensionManagement.registerScript("chrome://browser/content/ext-bookmarks.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-browserAction.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-commands.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-contextMenus.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-desktop-runtime.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-history.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-pageAction.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-tabs.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-utils.js");
-    ExtensionManagement.registerScript("chrome://browser/content/ext-windows.js");
-
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/bookmarks.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/browser_action.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/commands.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/context_menus.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/context_menus_internal.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/history.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/page_action.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/tabs.json");
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/windows.json");
-
     this._flashHangCount = 0;
     this._firstWindowReady = new Promise(resolve => this._firstWindowLoaded = resolve);
   },
 
   // cleanup (called on application shutdown)
   _dispose: function BG__dispose() {
     let os = Services.obs;
     os.removeObserver(this, "notifications-open-settings");
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -569,16 +569,20 @@
 @RESPATH@/components/TestInterfaceJS.js
 @RESPATH@/components/TestInterfaceJS.manifest
 @RESPATH@/components/TestInterfaceJSMaplike.js
 #endif
 
 @RESPATH@/components/PACGenerator.js
 @RESPATH@/components/PACGenerator.manifest
 
+; [Extensions]
+@RESPATH@/components/extensions-toolkit.manifest
+@RESPATH@/browser/components/extensions-browser.manifest
+
 ; Modules
 @RESPATH@/browser/modules/*
 @RESPATH@/modules/*
 
 ; Safe Browsing
 #ifdef MOZ_URL_CLASSIFIER
 @RESPATH@/components/nsURLClassifier.manifest
 @RESPATH@/components/nsUrlClassifierHashCompleter.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -89,19 +89,16 @@ XPCOMUtils.defineLazyServiceGetter(this,
 
 XPCOMUtils.defineLazyServiceGetter(this, "Profiler",
                                    "@mozilla.org/tools/profiler;1",
                                    "nsIProfiler");
 
 XPCOMUtils.defineLazyModuleGetter(this, "SimpleServiceDiscovery",
                                   "resource://gre/modules/SimpleServiceDiscovery.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "ExtensionManagement",
-                                  "resource://gre/modules/ExtensionManagement.jsm");
-
 XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
                                   "resource://gre/modules/CharsetMenu.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "NetErrorHelper",
                                   "resource://gre/modules/NetErrorHelper.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PermissionsUtils",
                                   "resource://gre/modules/PermissionsUtils.jsm");
@@ -384,22 +381,16 @@ var BrowserApp = {
     Services.obs.addObserver(this, "android-get-pref", false);
     Services.obs.addObserver(this, "android-set-pref", false);
     Services.obs.addObserver(this, "gather-telemetry", false);
     Services.obs.addObserver(this, "keyword-search", false);
     Services.obs.addObserver(this, "sessionstore-state-purge-complete", false);
     Services.obs.addObserver(this, "Fonts:Reload", false);
     Services.obs.addObserver(this, "Vibration:Request", false);
 
-    // Register extension source files.
-    ExtensionManagement.registerScript("chrome://browser/content/ext-pageAction.js");
-
-    // Register extension schemas.
-    ExtensionManagement.registerSchema("chrome://browser/content/schemas/page_action.json");
-
     Messaging.addListener(this.getHistory.bind(this), "Session:GetHistory");
 
     function showFullScreenWarning() {
       Snackbars.show(Strings.browser.GetStringFromName("alertFullScreenToast"), Snackbars.LENGTH_LONG);
     }
 
     window.addEventListener("fullscreen", function() {
       Messaging.sendRequest({
@@ -6775,17 +6766,17 @@ var SearchEngines = {
               formData.push({ name: escape(formElement.name), value: escape(formElement.value) });
               break;
             }
           }
         }
       }
     };
 
-    // Return valid, pre-sorted queryParams. 
+    // Return valid, pre-sorted queryParams.
     return formData.filter(a => a.name && a.value).sort((a, b) => {
       // nsIBrowserSearchService.hasEngineWithURL() ensures sort, but this helps.
       if (a.name > b.name) {
         return 1;
       }
       if (b.name > a.name) {
         return -1;
       }
new file mode 100644
--- /dev/null
+++ b/mobile/android/components/extensions/extensions-mobile.manifest
@@ -0,0 +1,5 @@
+# scripts
+category webextension-scripts pageAction chrome://browser/content/ext-pageAction.js
+
+# schemas
+category webextension-schemas page_action chrome://browser/content/schemas/page_action.json
\ No newline at end of file
--- a/mobile/android/components/extensions/moz.build
+++ b/mobile/android/components/extensions/moz.build
@@ -1,11 +1,15 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 JAR_MANIFESTS += ['jar.mn']
 
+EXTRA_COMPONENTS += [
+    'extensions-mobile.manifest',
+]
+
 DIRS += ['schemas']
 
 MOCHITEST_CHROME_MANIFESTS += ['test/mochitest/chrome.ini']
\ No newline at end of file
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -444,16 +444,20 @@
 ; Security Reports
 @BINPATH@/components/SecurityReporter.manifest
 @BINPATH@/components/SecurityReporter.js
 
 ; [Browser Chrome Files]
 @BINPATH@/chrome/toolkit@JAREXT@
 @BINPATH@/chrome/toolkit.manifest
 
+; [Extensions]
+@BINPATH@/components/extensions-toolkit.manifest
+@BINPATH@/components/extensions-mobile.manifest
+
 ; Features
 @BINPATH@/features/*
 
 ; DevTools
 @BINPATH@/chrome/devtools@JAREXT@
 @BINPATH@/chrome/devtools.manifest
 
 ; [Default Preferences]
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -53,48 +53,19 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/AppConstants.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MessageChannel",
                                   "resource://gre/modules/MessageChannel.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
                                   "resource://gre/modules/AddonManager.jsm");
 
 Cu.import("resource://gre/modules/ExtensionManagement.jsm");
 
-// Register built-in parts of the API. Other parts may be registered
-// in browser/, mobile/, or b2g/.
-ExtensionManagement.registerScript("chrome://extensions/content/ext-alarms.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-backgroundPage.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-cookies.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-downloads.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-notifications.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-i18n.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-idle.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-runtime.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-extension.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-webNavigation.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-webRequest.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-storage.js");
-ExtensionManagement.registerScript("chrome://extensions/content/ext-test.js");
-
 const BASE_SCHEMA = "chrome://extensions/content/schemas/manifest.json";
-
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/alarms.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/cookies.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/downloads.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/extension.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/extension_types.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/i18n.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/idle.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/notifications.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/runtime.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/storage.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/test.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/events.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/web_navigation.json");
-ExtensionManagement.registerSchema("chrome://extensions/content/schemas/web_request.json");
+const CATEGORY_EXTENSION_SCHEMAS = "webextension-schemas";
+const CATEGORY_EXTENSION_SCRIPTS = "webextension-scripts";
 
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 var {
   BaseContext,
   EventEmitter,
   LocaleData,
   Messenger,
   injectAPI,
@@ -134,28 +105,30 @@ var Management = {
     if (this.initialized) {
       return this.initialized;
     }
 
     // Load order matters here. The base manifest defines types which are
     // extended by other schemas, so needs to be loaded first.
     let promise = Schemas.load(BASE_SCHEMA).then(() => {
       let promises = [];
-      for (let schema of ExtensionManagement.getSchemas()) {
-        promises.push(Schemas.load(schema));
+      for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCHEMAS)) {
+        promises.push(Schemas.load(value));
       }
       return Promise.all(promises);
     });
 
-    for (let script of ExtensionManagement.getScripts()) {
-      let scope = {extensions: this,
-                   global: scriptScope,
-                   ExtensionContext: ExtensionContext,
-                   GlobalManager: GlobalManager};
-      Services.scriptloader.loadSubScript(script, scope, "UTF-8");
+    for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCRIPTS)) {
+      let scope = {
+        extensions: this,
+        global: scriptScope,
+        ExtensionContext: ExtensionContext,
+        GlobalManager: GlobalManager,
+      };
+      Services.scriptloader.loadSubScript(value, scope, "UTF-8");
 
       // Save the scope to avoid it being garbage collected.
       this.scopes.push(scope);
     }
 
     this.initialized = promise;
     return this.initialized;
   },
--- a/toolkit/components/extensions/ExtensionManagement.jsm
+++ b/toolkit/components/extensions/ExtensionManagement.jsm
@@ -80,42 +80,16 @@ var Frames = {
       case "Extension:RemoveTopWindowID":
         this.topWindowIds.delete(data.windowId);
         break;
     }
   },
 };
 Frames.init();
 
-// Manage the collection of ext-*.js scripts that define the extension API.
-var Scripts = {
-  scripts: new Set(),
-
-  register(script) {
-    this.scripts.add(script);
-  },
-
-  getScripts() {
-    return this.scripts;
-  },
-};
-
-// Manage the collection of schemas/*.json schemas that define the extension API.
-var Schemas = {
-  schemas: new Set(),
-
-  register(schema) {
-    this.schemas.add(schema);
-  },
-
-  getSchemas() {
-    return this.schemas;
-  },
-};
-
 // This object manages various platform-level issues related to
 // moz-extension:// URIs. It lives here so that it can be used in both
 // the parent and child processes.
 //
 // moz-extension URIs have the form moz-extension://uuid/path. Each
 // extension has its own UUID, unique to the machine it's installed
 // on. This is easier and more secure than using the extension ID,
 // since it makes it slightly harder to fingerprint for extensions if
@@ -295,22 +269,16 @@ function getAPILevelForWindow(window, ad
   // WebExtension URLs loaded into top frames UI could have full API level privileges.
   return FULL_PRIVILEGES;
 }
 
 this.ExtensionManagement = {
   startupExtension: Service.startupExtension.bind(Service),
   shutdownExtension: Service.shutdownExtension.bind(Service),
 
-  registerScript: Scripts.register.bind(Scripts),
-  getScripts: Scripts.getScripts.bind(Scripts),
-
-  registerSchema: Schemas.register.bind(Schemas),
-  getSchemas: Schemas.getSchemas.bind(Schemas),
-
   getFrameId: Frames.getId.bind(Frames),
   getParentFrameId: Frames.getParentId.bind(Frames),
 
   // exported API Level Helpers
   getAddonIdForWindow,
   getAPILevelForWindow,
   API_LEVELS,
 };
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/extensions/Schemas.jsm
@@ -478,17 +478,17 @@ class Type extends Entry {
   normalize(value, context) {
     return context.error("invalid type");
   }
 
   // Unlike normalize, this function does a shallow check to see if
   // |baseType| (one of the possible getValueBaseType results) is
   // valid for this type. It returns true or false. It's used to fill
   // in optional arguments to functions before actually type checking
-  // the arguments.
+
   checkBaseType(baseType) {
     return false;
   }
 
   // Helper method that simply relies on checkBaseType to implement
   // normalize. Subclasses can choose to use it or not.
   normalizeBase(type, value, context) {
     if (this.checkBaseType(getValueBaseType(value))) {
@@ -1403,18 +1403,17 @@ this.Schemas = {
       return new NumberType(type);
     } else if (type.type == "integer") {
       checkTypeProperties("minimum", "maximum");
       return new IntegerType(type, type.minimum || -Infinity, type.maximum || Infinity);
     } else if (type.type == "boolean") {
       checkTypeProperties();
       return new BooleanType(type);
     } else if (type.type == "function") {
-      let isAsync = Boolean(type.async);
-
+      let isAsync = !!type.async;
       let parameters = null;
       if ("parameters" in type) {
         parameters = [];
         for (let param of type.parameters) {
           // Callbacks default to optional for now, because of promise
           // handling.
           let isCallback = isAsync && param.name == type.async;
 
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/extensions-toolkit.manifest
@@ -0,0 +1,31 @@
+# scripts
+category webextension-scripts alarms chrome://extensions/content/ext-alarms.js
+category webextension-scripts backgroundPage chrome://extensions/content/ext-backgroundPage.js
+category webextension-scripts cookies chrome://extensions/content/ext-cookies.js
+category webextension-scripts downloads chrome://extensions/content/ext-downloads.js
+category webextension-scripts notifications chrome://extensions/content/ext-notifications.js
+category webextension-scripts i18n chrome://extensions/content/ext-i18n.js
+category webextension-scripts idle chrome://extensions/content/ext-idle.js
+category webextension-scripts webRequest chrome://extensions/content/ext-webRequest.js
+category webextension-scripts webNavigation chrome://extensions/content/ext-webNavigation.js
+category webextension-scripts runtime chrome://extensions/content/ext-runtime.js
+category webextension-scripts extension chrome://extensions/content/ext-extension.js
+category webextension-scripts storage chrome://extensions/content/ext-storage.js
+category webextension-scripts test chrome://extensions/content/ext-test.js
+
+# schemas
+category webextension-schemas alarms chrome://extensions/content/schemas/alarms.json
+category webextension-schemas cookies chrome://extensions/content/schemas/cookies.json
+category webextension-schemas downloads chrome://extensions/content/schemas/downloads.json
+category webextension-schemas events chrome://extensions/content/schemas/events.json
+category webextension-schemas extension chrome://extensions/content/schemas/extension.json
+category webextension-schemas extension_types chrome://extensions/content/schemas/extension_types.json
+category webextension-schemas i18n chrome://extensions/content/schemas/i18n.json
+category webextension-schemas idle chrome://extensions/content/schemas/idle.json
+category webextension-schemas native_host_manifest chrome://extensions/content/schemas/native_host_manifest.json
+category webextension-schemas notifications chrome://extensions/content/schemas/notifications.json
+category webextension-schemas runtime chrome://extensions/content/schemas/runtime.json
+category webextension-schemas storage chrome://extensions/content/schemas/storage.json
+category webextension-schemas test chrome://extensions/content/schemas/test.json
+category webextension-schemas web_navigation chrome://extensions/content/schemas/web_navigation.json
+category webextension-schemas web_request chrome://extensions/content/schemas/web_request.json
\ No newline at end of file
--- a/toolkit/components/extensions/moz.build
+++ b/toolkit/components/extensions/moz.build
@@ -10,15 +10,19 @@ EXTRA_JS_MODULES += [
     'ExtensionManagement.jsm',
     'ExtensionStorage.jsm',
     'ExtensionUtils.jsm',
     'MessageChannel.jsm',
     'NativeMessaging.jsm',
     'Schemas.jsm',
 ]
 
+EXTRA_COMPONENTS += [
+    'extensions-toolkit.manifest',
+]
+
 DIRS += ['schemas']
 
 JAR_MANIFESTS += ['jar.mn']
 
 MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['test/mochitest/chrome.ini']
 XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']