2 * Global Gecko type declarations.
6 import type { CiClass } from "lib.gecko.xpidl"
10 type Browser = InstanceType<typeof XULBrowserElement>;
11 type bytestring = string;
12 type callback = (...args: any[]) => any;
13 type ColorArray = number[];
14 type integer = number;
15 type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue };
18 createXULElement(name: string): Element;
19 documentReadyForIdle: Promise<void>;
21 interface EventTarget {
27 interface ErrorConstructor {
28 new (message?: string, options?: ErrorOptions, lineNo?: number): Error;
33 // HACK to get the static isInstance for DOMException and Window?
35 isInstance(object: any): boolean;
38 // XPIDL additions/overrides.
40 interface nsISupports {
42 QueryInterface?<T extends CiClass<nsISupports>>(aCiClass: T): T['prototype'];
43 wrappedJSObject?: object;
45 interface nsIProperties {
46 get<T extends CiClass<nsISupports>>(prop: string, aCiClass: T): T['prototype'];
48 interface nsIPrefBranch {
49 getComplexValue<T extends CiClass<nsISupports>>(aPrefName: string, aCiClass: T): T['prototype'];
51 // TODO: incorporate above into lib.xpidl.d.ts generation, somehow?
53 type Sandbox = typeof globalThis;
54 interface nsIXPCComponents_utils_Sandbox {
55 (principal: nsIPrincipal | nsIPrincipal[], options: object): Sandbox;
57 interface nsIXPCComponents_Utils {
58 cloneInto<T>(obj: T, ...args: any[]): T;
59 createObjectIn<T>(Sandbox, options?: T): T;
60 exportFunction<T extends callback>(f: T, ...args: any[]): T;
61 getWeakReference<T extends object>(T): { get(): T };
62 readonly Sandbox: nsIXPCComponents_utils_Sandbox;
63 waiveXrays<T>(obj: T): T;
65 interface nsIDOMWindow extends Window {
66 docShell: nsIDocShell;
69 documentURIObject: nsIURI;
70 createXULElement(name: string): Element;
73 // nsDocShell is the only thing implementing nsIDocShell, but it also
74 // implements nsIWebNavigation, and a few others, so this is "ok".
75 interface nsIDocShell extends nsIWebNavigation {}
76 interface nsISimpleEnumerator extends Iterable<any> {}
78 namespace Components {
79 type Exception = Error;
81 namespace UrlbarUtils {
82 type RESULT_TYPE = any;
83 type RESULT_SOURCE = any;
86 // Various mozilla globals.
87 var Cc, Cr, ChromeUtils, Components, dump, uneval;
89 // [ChromeOnly] WebIDL, to be generated.
90 var BrowsingContext, ChannelWrapper, ChromeWindow, ChromeWorker,
91 ClonedErrorHolder, Glean, InspectorUtils, IOUtils, JSProcessActorChild,
92 JSProcessActorParent, JSWindowActor, JSWindowActorChild,
93 JSWindowActorParent, L10nRegistry, L10nFileSource, Localization,
94 MatchGlob, MatchPattern, MatchPatternSet, PathUtils, PreloadedScript,
95 StructuredCloneHolder, TelemetryStopwatch, WindowGlobalChild,
96 WebExtensionContentScript, WebExtensionParentActor, WebExtensionPolicy,
97 XULBrowserElement, nsIMessageListenerManager;
99 interface XULElement extends Element {}
101 // nsIServices is not a thing.
102 interface nsIServices {
103 scriptloader: mozIJSSubScriptLoader;
104 locale: mozILocaleService;
106 storage: mozIStorageService;
107 appShell: nsIAppShellService;
108 startup: nsIAppStartup;
109 blocklist: nsIBlocklistService;
110 cache2: nsICacheStorageService;
111 catMan: nsICategoryManager;
112 clearData: nsIClearDataService;
113 clipboard: nsIClipboard;
114 console: nsIConsoleService;
115 cookieBanners: nsICookieBannerService;
116 cookies: nsICookieManager & nsICookieService;
117 appinfo: nsICrashReporter & nsIXULAppInfo & nsIXULRuntime;
118 DAPTelemetry: nsIDAPTelemetry;
119 DOMRequest: nsIDOMRequestService;
121 dirsvc: nsIDirectoryService & nsIProperties;
122 droppedLinkHandler: nsIDroppedLinkHandler;
123 eTLD: nsIEffectiveTLDService;
124 policies: nsIEnterprisePolicies;
126 els: nsIEventListenerService;
128 focus: nsIFocusManager;
129 io: nsIIOService & nsINetUtil & nsISpeculativeConnect;
130 loadContextInfo: nsILoadContextInfoFactory;
131 domStorageManager: nsIDOMStorageManager & nsILocalStorageManager;
132 logins: nsILoginManager;
133 obs: nsIObserverService;
134 perms: nsIPermissionManager;
135 prefs: nsIPrefBranch & nsIPrefService;
136 profiler: nsIProfiler;
137 prompt: nsIPromptService;
138 sysinfo: nsISystemInfo & nsIPropertyBag2;
139 qms: nsIQuotaManagerService;
141 scriptSecurityManager: nsIScriptSecurityManager;
142 search: nsISearchService;
143 sessionStorage: nsISessionStorageService;
144 strings: nsIStringBundleService;
145 telemetry: nsITelemetry;
146 textToSubURI: nsITextToSubURI;
147 tm: nsIThreadManager;
148 uriFixup: nsIURIFixup;
149 urlFormatter: nsIURLFormatter;
150 uuid: nsIUUIDGenerator;
151 vc: nsIVersionComparator;
152 wm: nsIWindowMediator;
153 ww: nsIWindowWatcher;
154 xulStore: nsIXULStore;
160 var Ci: nsIXPCComponents_Interfaces;
161 var Cu: nsIXPCComponents_Utils;
162 var Services: nsIServices;