Bug 1866777 - Disable test_race_cache_with_network.js on windows opt for frequent...
[gecko.git] / testing / specialpowers / api.js
bloba0ffe42b3208e00d109bed1ace678ad6aba56ce6
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",
9 });
11 XPCOMUtils.defineLazyServiceGetter(
12   this,
13   "resProto",
14   "@mozilla.org/network/protocol;1?name=resource",
15   "nsISubstitutingProtocolHandler"
18 this.specialpowers = class extends ExtensionAPI {
19   onStartup() {
20     // Register special testing modules.
21     let manifest = Services.dirsvc.get("ProfD", Ci.nsIFile);
22     manifest.append("tests.manifest");
23     Components.manager
24       .QueryInterface(Ci.nsIComponentRegistrar)
25       .autoRegister(manifest);
27     {
28       let uri = Services.io.newURI("content/", null, this.extension.rootURI);
29       resProto.setSubstitutionWithFlags(
30         "specialpowers",
31         uri,
32         resProto.ALLOW_CONTENT_ACCESS
33       );
34     }
36     if (!resProto.hasSubstitution("testing-common")) {
37       let uri = Services.io.newURI("modules/", null, this.extension.rootURI);
38       resProto.setSubstitution(
39         "testing-common",
40         uri,
41         resProto.ALLOW_CONTENT_ACCESS
42       );
43     }
45     SpecialPowersParent.registerActor();
47     ChromeUtils.registerWindowActor("AppTestDelegate", {
48       parent: {
49         esModuleURI: "resource://specialpowers/AppTestDelegateParent.sys.mjs",
50       },
51       child: {
52         esModuleURI: "resource://specialpowers/AppTestDelegateChild.sys.mjs",
53         events: {
54           DOMContentLoaded: { capture: true },
55           load: { capture: true },
56         },
57       },
58       allFrames: true,
59       includeChrome: true,
60     });
61   }
63   onShutdown() {
64     SpecialPowersParent.unregisterActor();
65     ChromeUtils.unregisterWindowActor("AppTestDelegate");
66     resProto.setSubstitution("specialpowers", null);
67   }