1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* globals ExtensionAPI, Services, XPCOMUtils */
7 ChromeUtils.defineESModuleGetters(this, {
8 SpecialPowersParent: "resource://testing-common/SpecialPowersParent.sys.mjs",
11 XPCOMUtils.defineLazyServiceGetter(
14 "@mozilla.org/network/protocol;1?name=resource",
15 "nsISubstitutingProtocolHandler"
18 this.specialpowers = class extends ExtensionAPI {
20 // Register special testing modules.
21 let manifest = Services.dirsvc.get("ProfD", Ci.nsIFile);
22 manifest.append("tests.manifest");
24 .QueryInterface(Ci.nsIComponentRegistrar)
25 .autoRegister(manifest);
28 let uri = Services.io.newURI("content/", null, this.extension.rootURI);
29 resProto.setSubstitutionWithFlags(
32 resProto.ALLOW_CONTENT_ACCESS
36 if (!resProto.hasSubstitution("testing-common")) {
37 let uri = Services.io.newURI("modules/", null, this.extension.rootURI);
38 resProto.setSubstitution(
41 resProto.ALLOW_CONTENT_ACCESS
45 SpecialPowersParent.registerActor();
47 ChromeUtils.registerWindowActor("AppTestDelegate", {
49 esModuleURI: "resource://specialpowers/AppTestDelegateParent.sys.mjs",
52 esModuleURI: "resource://specialpowers/AppTestDelegateChild.sys.mjs",
54 DOMContentLoaded: { capture: true },
55 load: { capture: true },
64 SpecialPowersParent.unregisterActor();
65 ChromeUtils.unregisterWindowActor("AppTestDelegate");
66 resProto.setSubstitution("specialpowers", null);