1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object
8 * http://www.w3.org/TR/tracking-dnt/
9 * http://www.w3.org/TR/geolocation-API/#geolocation_interface
10 * http://www.w3.org/TR/battery-status/#navigatorbattery-interface
11 * http://www.w3.org/TR/vibration/#vibration-interface
12 * http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1
13 * https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
14 * http://www.w3.org/TR/beacon/#sec-beacon-method
15 * https://html.spec.whatwg.org/#navigatorconcurrenthardware
16 * http://wicg.github.io/netinfo/#extensions-to-the-navigator-interface
17 * https://w3c.github.io/webappsec-credential-management/#framework-credential-management
18 * https://w3c.github.io/webdriver/webdriver-spec.html#interface
19 * https://wicg.github.io/media-capabilities/#idl-index
21 * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
22 * Opera Software ASA. You are granted a license to use, reproduce
23 * and create derivative works of this document.
28 // http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object
29 [HeaderFile="Navigator.h"]
31 // objects implementing this interface also implement the interfaces given below
33 Navigator implements NavigatorID;
34 Navigator implements NavigatorLanguage;
35 Navigator implements NavigatorOnLine;
36 Navigator implements NavigatorContentUtils;
37 Navigator implements NavigatorStorageUtils;
38 Navigator implements NavigatorConcurrentHardware;
39 Navigator implements NavigatorStorage;
40 Navigator implements NavigatorAutomationInformation;
42 [NoInterfaceObject, Exposed=(Window,Worker)]
43 interface NavigatorID {
44 // WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla").
45 [Constant, Cached, Throws]
46 readonly attribute DOMString appCodeName; // constant "Mozilla"
47 [Constant, Cached, NeedsCallerType]
48 readonly attribute DOMString appName;
49 [Constant, Cached, Throws, NeedsCallerType]
50 readonly attribute DOMString appVersion;
51 [Constant, Cached, Throws, NeedsCallerType]
52 readonly attribute DOMString platform;
53 [Pure, Cached, Throws, NeedsCallerType]
54 readonly attribute DOMString userAgent;
56 readonly attribute DOMString product; // constant "Gecko"
58 // Everyone but WebKit/Blink supports this. See bug 679971.
60 boolean taintEnabled(); // constant false
63 [NoInterfaceObject, Exposed=(Window,Worker)]
64 interface NavigatorLanguage {
66 // These two attributes are cached because this interface is also implemented
67 // by Workernavigator and this way we don't have to go back to the
68 // main-thread from the worker thread anytime we need to retrieve them. They
69 // are updated when pref intl.accept_languages is changed.
72 readonly attribute DOMString? language;
73 [Pure, Cached, Frozen]
74 readonly attribute sequence<DOMString> languages;
77 [NoInterfaceObject, Exposed=(Window,Worker)]
78 interface NavigatorOnLine {
79 readonly attribute boolean onLine;
83 interface NavigatorContentUtils {
84 // content handler registration
86 void checkProtocolHandlerAllowed(DOMString scheme, URI handlerURI, URI documentURI);
87 [Throws, Func="nsGlobalWindowInner::RegisterProtocolHandlerAllowedForContext"]
88 void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title);
89 [Pref="dom.registerContentHandler.enabled", Throws]
90 void registerContentHandler(DOMString mimeType, DOMString url, DOMString title);
92 //DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url);
93 //DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url);
94 //void unregisterProtocolHandler(DOMString scheme, DOMString url);
95 //void unregisterContentHandler(DOMString mimeType, DOMString url);
98 [SecureContext, NoInterfaceObject, Exposed=(Window,Worker)]
99 interface NavigatorStorage {
100 [Func="mozilla::dom::DOMPrefs::dom_storageManager_enabled"]
101 readonly attribute StorageManager storage;
105 interface NavigatorStorageUtils {
107 //void yieldForStorageUpdates();
110 partial interface Navigator {
112 readonly attribute Permissions permissions;
115 // Things that definitely need to be in the spec and and are not for some
116 // reason. See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22406
117 partial interface Navigator {
119 readonly attribute MimeTypeArray mimeTypes;
121 readonly attribute PluginArray plugins;
124 // http://www.w3.org/TR/tracking-dnt/ sort of
125 partial interface Navigator {
126 readonly attribute DOMString doNotTrack;
129 // http://www.w3.org/TR/geolocation-API/#geolocation_interface
131 interface NavigatorGeolocation {
132 [Throws, Pref="geo.enabled"]
133 readonly attribute Geolocation geolocation;
135 Navigator implements NavigatorGeolocation;
137 // http://www.w3.org/TR/battery-status/#navigatorbattery-interface
138 partial interface Navigator {
139 // ChromeOnly to prevent web content from fingerprinting users' batteries.
140 [Throws, ChromeOnly, Pref="dom.battery.enabled"]
141 Promise<BatteryManager> getBattery();
144 // http://www.w3.org/TR/vibration/#vibration-interface
145 partial interface Navigator {
146 // We don't support sequences in unions yet
147 //boolean vibrate ((unsigned long or sequence<unsigned long>) pattern);
148 boolean vibrate(unsigned long duration);
149 boolean vibrate(sequence<unsigned long> pattern);
152 // http://www.w3.org/TR/pointerevents/#extensions-to-the-navigator-interface
153 partial interface Navigator {
154 [Pref="dom.w3c_pointer_events.enabled", NeedsCallerType]
155 readonly attribute long maxTouchPoints;
158 // https://wicg.github.io/media-capabilities/#idl-index
160 partial interface Navigator {
161 [SameObject, Func="mozilla::dom::MediaCapabilities::Enabled"]
162 readonly attribute MediaCapabilities mediaCapabilities;
165 // Mozilla-specific extensions
167 // Chrome-only interface for Vibration API permission handling.
168 partial interface Navigator {
169 /* Set permission state to device vibration.
170 * @param permitted permission state (true for allowing vibration)
171 * @param persistent make the permission session-persistent
174 void setVibrationPermission(boolean permitted,
175 optional boolean persistent = true);
178 callback interface MozIdleObserver {
179 // Time is in seconds and is read only when idle observers are added
181 readonly attribute unsigned long time;
186 partial interface Navigator {
187 [Throws, Constant, Cached, NeedsCallerType]
188 readonly attribute DOMString oscpu;
189 // WebKit/Blink support this; Trident/Presto do not.
190 readonly attribute DOMString vendor;
191 // WebKit/Blink supports this (hardcoded ""); Trident/Presto do not.
192 readonly attribute DOMString vendorSub;
193 // WebKit/Blink supports this (hardcoded "20030107"); Trident/Presto don't
194 readonly attribute DOMString productSub;
195 // WebKit/Blink/Trident/Presto support this.
196 readonly attribute boolean cookieEnabled;
197 [Throws, Constant, Cached, NeedsCallerType]
198 readonly attribute DOMString buildID;
200 // WebKit/Blink/Trident/Presto support this.
201 [Affects=Nothing, DependsOn=Nothing]
202 boolean javaEnabled();
205 * Navigator requests to add an idle observer to the existing window.
208 void addIdleObserver(MozIdleObserver aIdleObserver);
211 * Navigator requests to remove an idle observer from the existing window.
214 void removeIdleObserver(MozIdleObserver aIdleObserver);
217 // NetworkInformation
218 partial interface Navigator {
219 [Throws, Pref="dom.netinfo.enabled"]
220 readonly attribute NetworkInformation connection;
223 // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
224 partial interface Navigator {
225 [Throws, Pref="dom.gamepad.enabled"]
226 sequence<Gamepad?> getGamepads();
228 partial interface Navigator {
229 [Pref="dom.gamepad.test.enabled"]
230 GamepadServiceTest requestGamepadServiceTest();
233 partial interface Navigator {
234 [Throws, Pref="dom.vr.enabled"]
235 Promise<sequence<VRDisplay>> getVRDisplays();
236 // TODO: Use FrozenArray once available. (Bug 1236777)
237 [Frozen, Cached, Pure, Pref="dom.vr.enabled"]
238 readonly attribute sequence<VRDisplay> activeVRDisplays;
239 [ChromeOnly, Pref="dom.vr.enabled"]
240 readonly attribute boolean isWebVRContentDetected;
241 [ChromeOnly, Pref="dom.vr.enabled"]
242 readonly attribute boolean isWebVRContentPresenting;
243 [ChromeOnly, Pref="dom.vr.enabled"]
244 void requestVRPresentation(VRDisplay display);
246 partial interface Navigator {
247 [Pref="dom.vr.test.enabled"]
248 VRServiceTest requestVRServiceTest();
251 // http://webaudio.github.io/web-midi-api/#requestmidiaccess
252 partial interface Navigator {
253 [Throws, Pref="dom.webmidi.enabled"]
254 Promise<MIDIAccess> requestMIDIAccess(optional MIDIOptions options);
257 callback NavigatorUserMediaSuccessCallback = void (MediaStream stream);
258 callback NavigatorUserMediaErrorCallback = void (MediaStreamError error);
260 partial interface Navigator {
261 [Throws, Func="Navigator::HasUserMediaSupport"]
262 readonly attribute MediaDevices mediaDevices;
264 // Deprecated. Use mediaDevices.getUserMedia instead.
265 [Deprecated="NavigatorGetUserMedia", Throws,
266 Func="Navigator::HasUserMediaSupport",
268 void mozGetUserMedia(MediaStreamConstraints constraints,
269 NavigatorUserMediaSuccessCallback successCallback,
270 NavigatorUserMediaErrorCallback errorCallback);
273 // nsINavigatorUserMedia
274 callback MozGetUserMediaDevicesSuccessCallback = void (nsIVariant? devices);
275 partial interface Navigator {
277 void mozGetUserMediaDevices(MediaStreamConstraints constraints,
278 MozGetUserMediaDevicesSuccessCallback onsuccess,
279 NavigatorUserMediaErrorCallback onerror,
280 // The originating innerWindowID is needed to
281 // avoid calling the callbacks if the window has
282 // navigated away. It is optional only as legacy.
283 optional unsigned long long innerWindowID = 0,
284 // The callID is needed in case of multiple
285 // concurrent requests to find the right one.
286 // It is optional only as legacy.
287 // TODO: Rewrite to not need this method anymore,
288 // now that devices are enumerated earlier.
289 optional DOMString callID = "");
292 // Service Workers/Navigation Controllers
293 partial interface Navigator {
294 [Func="ServiceWorkerContainer::IsEnabled", SameObject]
295 readonly attribute ServiceWorkerContainer serviceWorker;
298 partial interface Navigator {
299 [Throws, Pref="beacon.enabled"]
300 boolean sendBeacon(DOMString url,
301 optional BodyInit? data = null);
304 partial interface Navigator {
305 [Throws, Pref="dom.presentation.enabled", SameObject]
306 readonly attribute Presentation? presentation;
309 partial interface Navigator {
310 [NewObject, Func="mozilla::dom::TCPSocket::ShouldTCPSocketExist"]
311 readonly attribute LegacyMozTCPSocket mozTCPSocket;
314 partial interface Navigator {
316 Promise<MediaKeySystemAccess>
317 requestMediaKeySystemAccess(DOMString keySystem,
318 sequence<MediaKeySystemConfiguration> supportedConfigurations);
321 [NoInterfaceObject, Exposed=(Window,Worker)]
322 interface NavigatorConcurrentHardware {
323 readonly attribute unsigned long long hardwareConcurrency;
326 // https://w3c.github.io/webappsec-credential-management/#framework-credential-management
327 partial interface Navigator {
328 [Pref="security.webauth.webauthn", SecureContext, SameObject]
329 readonly attribute CredentialsContainer credentials;
332 // https://w3c.github.io/webdriver/webdriver-spec.html#interface
334 interface NavigatorAutomationInformation {
335 [Pref="dom.webdriver.enabled"]
336 readonly attribute boolean webdriver;
339 // https://www.w3.org/TR/clipboard-apis/#navigator-interface
340 partial interface Navigator {
341 [Pref="dom.events.asyncClipboard", SecureContext, SameObject]
342 readonly attribute Clipboard clipboard;