Navigator.webidl (13903B)
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/. 5 * 6 * The origin of this IDL file is 7 * https://html.spec.whatwg.org/#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 20 * https://w3c.github.io/mediasession/#idl-index 21 * 22 * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and 23 * Opera Software ASA. You are granted a license to use, reproduce 24 * and create derivative works of this document. 25 */ 26 27 interface URI; 28 29 // https://html.spec.whatwg.org/#the-navigator-object 30 [HeaderFile="Navigator.h", 31 Exposed=Window] 32 interface Navigator { 33 // objects implementing this interface also implement the interfaces given below 34 }; 35 Navigator includes NavigatorID; 36 Navigator includes NavigatorLanguage; 37 Navigator includes NavigatorOnLine; 38 Navigator includes NavigatorContentUtils; 39 Navigator includes NavigatorStorageUtils; 40 Navigator includes NavigatorConcurrentHardware; 41 Navigator includes NavigatorStorage; 42 Navigator includes NavigatorAutomationInformation; 43 Navigator includes NavigatorGPU; 44 Navigator includes GlobalPrivacyControl; 45 46 interface mixin NavigatorID { 47 // WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla"). 48 [Constant, Cached, Throws] 49 readonly attribute DOMString appCodeName; // constant "Mozilla" 50 [Constant, Cached] 51 readonly attribute DOMString appName; // constant "Netscape" 52 [Constant, Cached, Throws, NeedsCallerType] 53 readonly attribute DOMString appVersion; 54 [Pure, Cached, Throws, NeedsCallerType] 55 readonly attribute DOMString platform; 56 [Pure, Cached, Throws, NeedsCallerType] 57 readonly attribute DOMString userAgent; 58 [Constant, Cached] 59 readonly attribute DOMString product; // constant "Gecko" 60 61 // Everyone but WebKit/Blink supports this. See bug 679971. 62 [Exposed=Window] 63 boolean taintEnabled(); // constant false 64 }; 65 66 interface mixin NavigatorLanguage { 67 68 // These two attributes are cached because this interface is also implemented 69 // by Workernavigator and this way we don't have to go back to the 70 // main-thread from the worker thread anytime we need to retrieve them. They 71 // are updated when pref intl.accept_languages is changed. 72 73 [Pure, Cached] 74 readonly attribute DOMString? language; 75 [Pure, Cached, Frozen] 76 readonly attribute sequence<DOMString> languages; 77 }; 78 79 interface mixin NavigatorOnLine { 80 readonly attribute boolean onLine; 81 }; 82 83 interface mixin NavigatorContentUtils { 84 // content handler registration 85 [Throws, ChromeOnly] 86 undefined checkProtocolHandlerAllowed(DOMString scheme, URI handlerURI, URI documentURI); 87 [Throws, SecureContext] 88 undefined registerProtocolHandler(DOMString scheme, DOMString url); 89 // NOT IMPLEMENTED 90 //undefined unregisterProtocolHandler(DOMString scheme, DOMString url); 91 }; 92 93 [SecureContext] 94 interface mixin NavigatorStorage { 95 readonly attribute StorageManager storage; 96 }; 97 98 interface mixin NavigatorStorageUtils { 99 // NOT IMPLEMENTED 100 //undefined yieldForStorageUpdates(); 101 }; 102 103 // https://w3c.github.io/permissions/#webidl-2112232240 104 partial interface Navigator { 105 [Throws, SameObject] 106 readonly attribute Permissions permissions; 107 }; 108 109 partial interface Navigator { 110 [Throws, SameObject] 111 readonly attribute MimeTypeArray mimeTypes; 112 [Throws, SameObject] 113 readonly attribute PluginArray plugins; 114 readonly attribute boolean pdfViewerEnabled; 115 }; 116 117 // http://www.w3.org/TR/tracking-dnt/ sort of 118 partial interface Navigator { 119 readonly attribute DOMString doNotTrack; 120 }; 121 122 // https://globalprivacycontrol.github.io/gpc-spec/ 123 interface mixin GlobalPrivacyControl { 124 [Pref="privacy.globalprivacycontrol.functionality.enabled"] 125 readonly attribute boolean globalPrivacyControl; 126 }; 127 128 // http://www.w3.org/TR/geolocation-API/#geolocation_interface 129 interface mixin NavigatorGeolocation { 130 [Throws, Pref="geo.enabled"] 131 readonly attribute Geolocation geolocation; 132 }; 133 Navigator includes NavigatorGeolocation; 134 135 // http://www.w3.org/TR/battery-status/#navigatorbattery-interface 136 partial interface Navigator { 137 // ChromeOnly to prevent web content from fingerprinting users' batteries. 138 [Throws, ChromeOnly, Pref="dom.battery.enabled"] 139 Promise<BatteryManager> getBattery(); 140 }; 141 142 // http://www.w3.org/TR/vibration/#vibration-interface 143 partial interface Navigator { 144 // We don't support sequences in unions yet 145 //boolean vibrate ((unsigned long or sequence<unsigned long>) pattern); 146 [Pref="dom.vibrator.enabled"] 147 boolean vibrate(unsigned long duration); 148 [Pref="dom.vibrator.enabled"] 149 boolean vibrate(sequence<unsigned long> pattern); 150 }; 151 152 // http://www.w3.org/TR/pointerevents/#extensions-to-the-navigator-interface 153 partial interface Navigator { 154 [NeedsCallerType] 155 readonly attribute long maxTouchPoints; 156 }; 157 158 // https://wicg.github.io/media-capabilities/#idl-index 159 [Exposed=Window] 160 partial interface Navigator { 161 [SameObject] 162 readonly attribute MediaCapabilities mediaCapabilities; 163 }; 164 165 // Mozilla-specific extensions 166 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 172 */ 173 [ChromeOnly] 174 undefined setVibrationPermission(boolean permitted, 175 optional boolean persistent = true); 176 }; 177 178 partial interface Navigator { 179 [Throws, Constant, Cached, NeedsCallerType] 180 readonly attribute DOMString oscpu; 181 // WebKit/Blink support this; Trident/Presto do not. 182 readonly attribute DOMString vendor; 183 // WebKit/Blink supports this (hardcoded ""); Trident/Presto do not. 184 readonly attribute DOMString vendorSub; 185 // WebKit/Blink supports this (hardcoded "20030107"); Trident/Presto don't 186 readonly attribute DOMString productSub; 187 // WebKit/Blink/Trident/Presto support this. 188 readonly attribute boolean cookieEnabled; 189 [Throws, Constant, Cached, NeedsCallerType] 190 readonly attribute DOMString buildID; 191 192 // WebKit/Blink/Trident/Presto support this. 193 [Affects=Nothing, DependsOn=Nothing] 194 boolean javaEnabled(); 195 }; 196 197 // Addon manager bits 198 partial interface Navigator { 199 [Throws, Func="mozilla::AddonManagerWebAPI::IsAPIEnabled"] 200 readonly attribute AddonManager mozAddonManager; 201 }; 202 203 // NetworkInformation 204 partial interface Navigator { 205 [Throws, Pref="dom.netinfo.enabled"] 206 readonly attribute NetworkInformation connection; 207 }; 208 209 // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension 210 partial interface Navigator { 211 [Throws, Pref="dom.gamepad.enabled"] 212 sequence<Gamepad?> getGamepads(); 213 }; 214 partial interface Navigator { 215 [Throws, Pref="dom.gamepad.test.enabled"] 216 GamepadServiceTest requestGamepadServiceTest(); 217 }; 218 219 // Chrome-only interface for acquiring all gamepads. Normally, a gamepad can 220 // only become visible if it gets interacted by the user. This function bypasses 221 // this restriction; it allow requesting all gamepad info without user 222 // interacting with the gamepads. 223 partial interface Navigator { 224 [Throws, ChromeOnly] 225 Promise<sequence<Gamepad>> requestAllGamepads(); 226 }; 227 228 // https://immersive-web.github.io/webvr/spec/1.1/#interface-navigator 229 partial interface Navigator { 230 [NewObject, SecureContext, Pref="dom.vr.enabled"] 231 Promise<sequence<VRDisplay>> getVRDisplays(); 232 // TODO: Use FrozenArray once available. (Bug 1236777) 233 [SecureContext, Frozen, Cached, Pure, Pref="dom.vr.enabled"] 234 readonly attribute sequence<VRDisplay> activeVRDisplays; 235 [ChromeOnly, Pref="dom.vr.enabled"] 236 readonly attribute boolean isWebVRContentDetected; 237 [ChromeOnly, Pref="dom.vr.enabled"] 238 readonly attribute boolean isWebVRContentPresenting; 239 [ChromeOnly, Pref="dom.vr.enabled"] 240 undefined requestVRPresentation(VRDisplay display); 241 }; 242 partial interface Navigator { 243 [Throws, Pref="dom.vr.puppet.enabled"] 244 VRServiceTest requestVRServiceTest(); 245 }; 246 247 // https://immersive-web.github.io/webxr/#dom-navigator-xr 248 partial interface Navigator { 249 [SecureContext, SameObject, Throws, Pref="dom.vr.webxr.enabled"] 250 readonly attribute XRSystem xr; 251 }; 252 253 // http://webaudio.github.io/web-midi-api/#requestmidiaccess 254 partial interface Navigator { 255 [NewObject, Func="Navigator::HasMidiSupport"] 256 Promise<MIDIAccess> requestMIDIAccess(optional MIDIOptions options = {}); 257 258 // Deprecated. Use mediaDevices.getUserMedia instead. 259 [Deprecated="NavigatorGetUserMedia", Throws, 260 Func="Navigator::MozGetUserMediaSupport", 261 NeedsCallerType, 262 UseCounter] 263 undefined mozGetUserMedia(MediaStreamConstraints constraints, 264 NavigatorUserMediaSuccessCallback successCallback, 265 NavigatorUserMediaErrorCallback errorCallback); 266 }; 267 268 callback NavigatorUserMediaSuccessCallback = undefined (MediaStream stream); 269 callback NavigatorUserMediaErrorCallback = undefined (MediaStreamError error); 270 271 partial interface Navigator { 272 [Throws, Func="Navigator::HasUserMediaSupport"] 273 readonly attribute MediaDevices mediaDevices; 274 }; 275 276 // Service Workers/Navigation Controllers 277 // https://w3c.github.io/ServiceWorker/#navigator-serviceworker 278 partial interface Navigator { 279 [Func="ServiceWorkersEnabled", SameObject, BinaryName="serviceWorkerJS"] 280 readonly attribute ServiceWorkerContainer serviceWorker; 281 }; 282 283 partial interface Navigator { 284 [Throws, Pref="beacon.enabled"] 285 boolean sendBeacon(DOMString url, 286 optional BodyInit? data = null); 287 }; 288 289 partial interface Navigator { 290 [NewObject, Func="mozilla::dom::TCPSocket::ShouldTCPSocketExist"] 291 readonly attribute LegacyMozTCPSocket mozTCPSocket; 292 }; 293 294 partial interface Navigator { 295 [NewObject] 296 Promise<MediaKeySystemAccess> 297 requestMediaKeySystemAccess(DOMString keySystem, 298 sequence<MediaKeySystemConfiguration> supportedConfigurations); 299 }; 300 301 interface mixin NavigatorConcurrentHardware { 302 readonly attribute unsigned long long hardwareConcurrency; 303 }; 304 305 // https://w3c.github.io/webappsec-credential-management/#framework-credential-management 306 partial interface Navigator { 307 [Pref="security.webauth.webauthn", SecureContext, SameObject] 308 readonly attribute CredentialsContainer credentials; 309 }; 310 311 // https://w3c.github.io/webdriver/webdriver-spec.html#interface 312 interface mixin NavigatorAutomationInformation { 313 [Constant, Cached] 314 readonly attribute boolean webdriver; 315 }; 316 317 // https://www.w3.org/TR/clipboard-apis/#navigator-interface 318 partial interface Navigator { 319 [SecureContext, SameObject] 320 readonly attribute Clipboard clipboard; 321 }; 322 323 // Used for testing of origin trials. 324 partial interface Navigator { 325 [Trial="TestTrial"] 326 readonly attribute boolean testTrialGatedAttribute; 327 }; 328 329 // https://wicg.github.io/web-share/#navigator-interface 330 partial interface Navigator { 331 [SecureContext, NewObject, Func="Navigator::HasShareSupport"] 332 Promise<undefined> share(optional ShareData data = {}); 333 [SecureContext, Func="Navigator::HasShareSupport"] 334 boolean canShare(optional ShareData data = {}); 335 }; 336 // https://wicg.github.io/web-share/#sharedata-dictionary 337 dictionary ShareData { 338 USVString title; 339 USVString text; 340 USVString url; 341 // Note: we don't actually support files yet 342 // we have it here for the .canShare() checks. 343 sequence<File> files; 344 }; 345 346 // https://w3c.github.io/mediasession/#idl-index 347 [Exposed=Window] 348 partial interface Navigator { 349 [SameObject] 350 readonly attribute MediaSession mediaSession; 351 }; 352 353 // https://w3c.github.io/web-locks/#navigator-mixins 354 [SecureContext] 355 interface mixin NavigatorLocks { 356 readonly attribute LockManager locks; 357 }; 358 Navigator includes NavigatorLocks; 359 360 // https://w3c.github.io/autoplay/#autoplay-policy 361 enum AutoplayPolicy { 362 "allowed", 363 "allowed-muted", 364 "disallowed" 365 }; 366 367 enum AutoplayPolicyMediaType { 368 "mediaelement", 369 "audiocontext" 370 }; 371 372 // https://w3c.github.io/autoplay/#autoplay-detection-methods 373 partial interface Navigator { 374 [Pref="dom.media.autoplay-policy-detection.enabled"] 375 AutoplayPolicy getAutoplayPolicy(AutoplayPolicyMediaType type); 376 377 [Pref="dom.media.autoplay-policy-detection.enabled"] 378 AutoplayPolicy getAutoplayPolicy(HTMLMediaElement element); 379 380 [Pref="dom.media.autoplay-policy-detection.enabled"] 381 AutoplayPolicy getAutoplayPolicy(AudioContext context); 382 }; 383 384 // https://html.spec.whatwg.org/multipage/interaction.html#the-useractivation-interface 385 partial interface Navigator { 386 [SameObject] readonly attribute UserActivation userActivation; 387 }; 388 389 // https://w3c.github.io/screen-wake-lock/#extensions-to-the-navigator-interface 390 [SecureContext] 391 partial interface Navigator { 392 [SameObject, Pref="dom.screenwakelock.enabled"] 393 readonly attribute WakeLock wakeLock; 394 }; 395 396 [SecureContext] 397 partial interface Navigator { 398 [SameObject, Trial="PrivateAttributionV2"] 399 readonly attribute PrivateAttribution privateAttribution; 400 }; 401 402 // https://w3c-fedid.github.io/login-status/#login-status-javascript 403 [SecureContext] 404 partial interface Navigator { 405 [SameObject] readonly attribute NavigatorLogin login; 406 };