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/
8 * https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html
9 * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html
10 * http://dev.w3.org/csswg/cssom/
11 * http://dev.w3.org/csswg/cssom-view/
12 * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html
13 * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
14 * https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html
15 * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
16 * https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object
17 * https://w3c.github.io/requestidlecallback/
18 * https://drafts.css-houdini.org/css-paint-api-1/#dom-window-paintworklet
19 * https://wicg.github.io/visual-viewport/#the-visualviewport-interface
23 interface nsIBrowserDOMWindow;
24 interface XULControllers;
25 interface nsIDOMWindowUtils;
26 interface nsIPrintSettings;
28 typedef OfflineResourceList ApplicationCache;
30 // http://www.whatwg.org/specs/web-apps/current-work/
31 [Global, LegacyUnenumerableNamedProperties, NeedResolve,
33 InstrumentedProps=(AbsoluteOrientationSensor,
36 ApplicationCacheErrorEvent,
41 BackgroundFetchManager,
42 BackgroundFetchRecord,
43 BackgroundFetchRegistration,
44 BeforeInstallPromptEvent,
46 BluetoothCharacteristicProperties,
48 BluetoothRemoteGATTCharacteristic,
49 BluetoothRemoteGATTDescriptor,
50 BluetoothRemoteGATTServer,
51 BluetoothRemoteGATTService,
53 CanvasCaptureMediaStreamTrack,
77 CSSTransformComponent,
82 CSSVariableReferenceValue,
84 // Unfortunately, our telemetry histogram name generator
85 // (the one that generates TelemetryHistogramEnums.h) can't
86 // handle two DOM methods with names that only differ in
87 // case, because it forces everything to uppercase.
89 DeviceMotionEventAcceleration,
90 DeviceMotionEventRotationRate,
92 EnterPictureInPictureEvent,
100 InputDeviceCapabilities,
104 LinearAccelerationSensor,
118 NavigationPreloadManager,
122 OffscreenCanvasRenderingContext2D,
123 onbeforeinstallprompt,
125 ondeviceorientationabsolute,
131 OverconstrainedError,
136 PaymentMethodChangeEvent,
138 PaymentRequestUpdateEvent,
140 PerformanceEventTiming,
141 PerformanceLongTaskTiming,
142 PerformancePaintTiming,
144 PictureInPictureWindow,
146 PresentationAvailability,
147 PresentationConnection,
148 PresentationConnectionAvailableEvent,
149 PresentationConnectionCloseEvent,
150 PresentationConnectionList,
151 PresentationReceiver,
153 RelativeOrientationSensor,
166 StylePropertyMapReadOnly,
169 TaskAttributionTiming,
178 USBAlternateInterface,
185 USBIsochronousInTransferPacket,
186 USBIsochronousInTransferResult,
187 USBIsochronousOutTransferPacket,
188 USBIsochronousOutTransferResult,
189 USBOutTransferResult,
192 webkitCancelAnimationFrame,
194 WebKitMutationObserver,
195 webkitRequestAnimationFrame,
196 webkitRequestFileSystem,
197 webkitResolveLocalFileSystemURL,
198 webkitRTCPeerConnection,
200 webkitSpeechGrammarList,
201 webkitSpeechRecognition,
202 webkitSpeechRecognitionError,
203 webkitSpeechRecognitionEvent,
207 /*sealed*/ interface Window : EventTarget {
208 // the current browsing context
209 [LegacyUnforgeable, Constant, StoreInSlot,
210 CrossOriginReadable] readonly attribute WindowProxy window;
211 [Replaceable, Constant, StoreInSlot,
212 CrossOriginReadable] readonly attribute WindowProxy self;
213 [LegacyUnforgeable, StoreInSlot, Pure] readonly attribute Document? document;
214 [Throws] attribute DOMString name;
215 [PutForwards=href, LegacyUnforgeable, CrossOriginReadable,
216 CrossOriginWritable] readonly attribute Location location;
217 [Throws] readonly attribute History history;
218 readonly attribute CustomElementRegistry customElements;
219 [Replaceable, Throws] readonly attribute BarProp locationbar;
220 [Replaceable, Throws] readonly attribute BarProp menubar;
221 [Replaceable, Throws] readonly attribute BarProp personalbar;
222 [Replaceable, Throws] readonly attribute BarProp scrollbars;
223 [Replaceable, Throws] readonly attribute BarProp statusbar;
224 [Replaceable, Throws] readonly attribute BarProp toolbar;
225 [Throws] attribute DOMString status;
226 [Throws, CrossOriginCallable, NeedsCallerType] undefined close();
227 [Throws, CrossOriginReadable] readonly attribute boolean closed;
228 [Throws] undefined stop();
229 [Throws, CrossOriginCallable, NeedsCallerType] undefined focus();
230 [Throws, CrossOriginCallable, NeedsCallerType] undefined blur();
231 [Replaceable, Pref="dom.window.event.enabled"] readonly attribute any event;
233 // other browsing contexts
234 [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy frames;
235 [Replaceable, CrossOriginReadable] readonly attribute unsigned long length;
236 //[Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy top;
237 [LegacyUnforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy? top;
238 [Throws, CrossOriginReadable] attribute any opener;
239 //[Throws] readonly attribute WindowProxy parent;
240 [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy? parent;
241 [Throws, NeedsSubjectPrincipal] readonly attribute Element? frameElement;
242 //[Throws] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "");
243 [Throws] WindowProxy? open(optional USVString url = "", optional DOMString target = "", optional [LegacyNullToEmptyString] DOMString features = "");
244 getter object (DOMString name);
247 readonly attribute Navigator navigator;
248 [Pref="dom.window.clientinformation.enabled", BinaryName="Navigator"]
249 readonly attribute Navigator clientInformation;
251 [Replaceable, Throws] readonly attribute External external;
252 [Throws, SecureContext, Pref="browser.cache.offline.enable"] readonly attribute ApplicationCache applicationCache;
255 [Throws, NeedsSubjectPrincipal] undefined alert();
256 [Throws, NeedsSubjectPrincipal] undefined alert(DOMString message);
257 [Throws, NeedsSubjectPrincipal] boolean confirm(optional DOMString message = "");
258 [Throws, NeedsSubjectPrincipal] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
259 [Throws, Pref="dom.enable_window_print"]
262 // Returns a window that you can use for a print preview.
264 // This may reuse an existing window if this window is already a print
265 // preview document, or if you pass a docshell explicitly.
266 [Throws, Func="nsContentUtils::IsCallerChromeOrFuzzingEnabled"]
267 WindowProxy? printPreview(optional nsIPrintSettings? settings = null,
268 optional nsIWebProgressListener? listener = null,
269 optional nsIDocShell? docShellToPreviewInto = null);
271 [Throws, CrossOriginCallable, NeedsSubjectPrincipal,
272 BinaryName="postMessageMoz"]
273 undefined postMessage(any message, DOMString targetOrigin, optional sequence<object> transfer = []);
274 [Throws, CrossOriginCallable, NeedsSubjectPrincipal,
275 BinaryName="postMessageMoz"]
276 undefined postMessage(any message, optional WindowPostMessageOptions options = {});
278 // also has obsolete members
280 Window includes GlobalEventHandlers;
281 Window includes WindowEventHandlers;
283 // http://www.whatwg.org/specs/web-apps/current-work/
284 interface mixin WindowSessionStorage {
285 //[Throws] readonly attribute Storage sessionStorage;
286 [Throws] readonly attribute Storage? sessionStorage;
288 Window includes WindowSessionStorage;
290 // http://www.whatwg.org/specs/web-apps/current-work/
291 interface mixin WindowLocalStorage {
292 [Throws] readonly attribute Storage? localStorage;
294 Window includes WindowLocalStorage;
296 // http://www.whatwg.org/specs/web-apps/current-work/
297 partial interface Window {
298 undefined captureEvents();
299 undefined releaseEvents();
302 // https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html
303 partial interface Window {
304 //[Throws] Selection getSelection();
305 [Throws] Selection? getSelection();
308 // https://drafts.csswg.org/cssom/#extensions-to-the-window-interface
309 partial interface Window {
310 //[NewObject, Throws] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString? pseudoElt = "");
311 [NewObject, Throws] CSSStyleDeclaration? getComputedStyle(Element elt, optional DOMString? pseudoElt = "");
314 // http://dev.w3.org/csswg/cssom-view/
315 enum ScrollBehavior { "auto", "instant", "smooth" };
317 dictionary ScrollOptions {
318 ScrollBehavior behavior = "auto";
321 dictionary ScrollToOptions : ScrollOptions {
322 unrestricted double left;
323 unrestricted double top;
326 partial interface Window {
327 //[Throws, NewObject, NeedsCallerType] MediaQueryList matchMedia(DOMString query);
328 [Throws, NewObject, NeedsCallerType] MediaQueryList? matchMedia(UTF8String query);
329 // Per spec, screen is SameObject, but we don't actually guarantee that given
330 // nsGlobalWindow::Cleanup. :(
331 //[SameObject, Replaceable, Throws] readonly attribute Screen screen;
332 [Replaceable, Throws] readonly attribute Screen screen;
335 //[Throws] undefined moveTo(double x, double y);
336 //[Throws] undefined moveBy(double x, double y);
337 //[Throws] undefined resizeTo(double x, double y);
338 //[Throws] undefined resizeBy(double x, double y);
339 [Throws, NeedsCallerType] undefined moveTo(long x, long y);
340 [Throws, NeedsCallerType] undefined moveBy(long x, long y);
341 [Throws, NeedsCallerType] undefined resizeTo(long x, long y);
342 [Throws, NeedsCallerType] undefined resizeBy(long x, long y);
345 // These are writable because we allow chrome to write them. And they need
346 // to use 'any' as the type, because non-chrome writing them needs to act
347 // like a [Replaceable] attribute would, which needs the original JS value.
348 //[Replaceable, Throws] readonly attribute double innerWidth;
349 //[Replaceable, Throws] readonly attribute double innerHeight;
350 [Throws, NeedsCallerType] attribute any innerWidth;
351 [Throws, NeedsCallerType] attribute any innerHeight;
353 // viewport scrolling
354 undefined scroll(unrestricted double x, unrestricted double y);
355 undefined scroll(optional ScrollToOptions options = {});
356 undefined scrollTo(unrestricted double x, unrestricted double y);
357 undefined scrollTo(optional ScrollToOptions options = {});
358 undefined scrollBy(unrestricted double x, unrestricted double y);
359 undefined scrollBy(optional ScrollToOptions options = {});
360 // mozScrollSnap is used by chrome to perform scroll snapping after the
361 // user performs actions that may affect scroll position
362 // mozScrollSnap is deprecated, to be replaced by a web accessible API, such
363 // as an extension to the ScrollOptions dictionary. See bug 1137937.
364 [ChromeOnly] undefined mozScrollSnap();
365 // The four properties below are double per spec at the moment, but whether
366 // that will continue is unclear.
367 [Replaceable, Throws] readonly attribute double scrollX;
368 [Replaceable, Throws] readonly attribute double pageXOffset;
369 [Replaceable, Throws] readonly attribute double scrollY;
370 [Replaceable, Throws] readonly attribute double pageYOffset;
372 // Aliases for screenX / screenY.
373 [Replaceable, Throws, NeedsCallerType] readonly attribute double screenLeft;
374 [Replaceable, Throws, NeedsCallerType] readonly attribute double screenTop;
377 // These are writable because we allow chrome to write them. And they need
378 // to use 'any' as the type, because non-chrome writing them needs to act
379 // like a [Replaceable] attribute would, which needs the original JS value.
380 //[Replaceable, Throws] readonly attribute double screenX;
381 //[Replaceable, Throws] readonly attribute double screenY;
382 //[Replaceable, Throws] readonly attribute double outerWidth;
383 //[Replaceable, Throws] readonly attribute double outerHeight;
384 [Throws, NeedsCallerType] attribute any screenX;
385 [Throws, NeedsCallerType] attribute any screenY;
386 [Throws, NeedsCallerType] attribute any outerWidth;
387 [Throws, NeedsCallerType] attribute any outerHeight;
390 // https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animation-frames
391 Window includes AnimationFrameProvider;
393 // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
394 partial interface Window {
395 [Replaceable, Pure, StoreInSlot] readonly attribute Performance? performance;
398 // https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html
399 Window includes GlobalCrypto;
401 // https://fidoalliance.org/specifications/download/
402 Window includes GlobalU2F;
405 // http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
406 interface mixin SpeechSynthesisGetter {
407 [Throws, Pref="media.webspeech.synth.enabled"] readonly attribute SpeechSynthesis speechSynthesis;
410 Window includes SpeechSynthesisGetter;
413 // Mozilla-specific stuff
414 partial interface Window {
415 //[NewObject, Throws] CSSStyleDeclaration getDefaultComputedStyle(Element elt, optional DOMString pseudoElt = "");
416 [NewObject, Throws] CSSStyleDeclaration? getDefaultComputedStyle(Element elt, optional DOMString pseudoElt = "");
418 // Mozilla extensions
420 * Method for scrolling this window by a number of lines.
422 undefined scrollByLines(long numLines, optional ScrollOptions options = {});
425 * Method for scrolling this window by a number of pages.
427 undefined scrollByPages(long numPages, optional ScrollOptions options = {});
430 * Method for sizing this window to the content in the window.
432 [Throws, NeedsCallerType] undefined sizeToContent();
434 // XXX Shouldn't this be in nsIDOMChromeWindow?
435 [ChromeOnly, Replaceable, Throws] readonly attribute XULControllers controllers;
437 [ChromeOnly, Throws] readonly attribute Element? realFrameElement;
439 [ChromeOnly] readonly attribute nsIDocShell? docShell;
441 [ChromeOnly, Constant, CrossOriginReadable, BinaryName="getBrowsingContext"]
442 readonly attribute BrowsingContext browsingContext;
444 [Throws, NeedsCallerType]
445 readonly attribute float mozInnerScreenX;
446 [Throws, NeedsCallerType]
447 readonly attribute float mozInnerScreenY;
448 [Replaceable, Throws, NeedsCallerType]
449 readonly attribute double devicePixelRatio;
451 // Allows chrome code to convert desktop pixels to device pixels and vice
452 // versa. Useful for interacting with the screen manager.
454 readonly attribute double desktopToDeviceScale;
456 /* The maximum offset that the window can be scrolled to
457 (i.e., the document width/height minus the scrollport width/height) */
458 [ChromeOnly, Throws] readonly attribute long scrollMinX;
459 [ChromeOnly, Throws] readonly attribute long scrollMinY;
460 [Replaceable, Throws] readonly attribute long scrollMaxX;
461 [Replaceable, Throws] readonly attribute long scrollMaxY;
463 [Throws] attribute boolean fullScreen;
465 // XXX Should this be in nsIDOMChromeWindow?
466 undefined updateCommands(DOMString action,
467 optional Selection? sel = null,
468 optional short reason = 0);
471 * @param str: the search pattern
472 * @param caseSensitive: is the search caseSensitive
473 * @param backwards: should we search backwards
474 * @param wrapAround: should we wrap the search
475 * @param wholeWord: should we search only for whole words
476 * @param searchInFrames: should we search through all frames
477 * @param showDialog: should we show the Find dialog
479 [Throws] boolean find(optional DOMString str = "",
480 optional boolean caseSensitive = false,
481 optional boolean backwards = false,
482 optional boolean wrapAround = false,
483 optional boolean wholeWord = false,
484 optional boolean searchInFrames = false,
485 optional boolean showDialog = false);
487 attribute EventHandler ondevicemotion;
488 attribute EventHandler ondeviceorientation;
489 attribute EventHandler onabsolutedeviceorientation;
490 [Pref="device.sensors.proximity.enabled"]
491 attribute EventHandler onuserproximity;
492 [Pref="device.sensors.ambientLight.enabled"]
493 attribute EventHandler ondevicelight;
495 undefined dump(DOMString str);
498 * This method is here for backwards compatibility with 4.x only,
499 * its implementation is a no-op
501 undefined setResizable(boolean resizable);
504 * This is the scriptable version of
505 * nsPIDOMWindow::OpenDialog() that takes 3 optional
506 * arguments, plus any additional arguments are passed on as
507 * arguments on the dialog's window object (window.arguments).
509 [Throws, ChromeOnly] WindowProxy? openDialog(optional DOMString url = "",
510 optional DOMString name = "",
511 optional DOMString options = "",
512 any... extraArguments);
514 [Func="nsGlobalWindowInner::ContentPropertyEnabled",
515 NonEnumerable, Replaceable, Throws, NeedsCallerType]
516 readonly attribute object? content;
518 [Throws, ChromeOnly] any getInterface(any iid);
521 * Same as nsIDOMWindow.windowRoot, useful for event listener targeting.
524 readonly attribute WindowRoot? windowRoot;
527 * ChromeOnly method to determine if a particular window should see console
528 * reports from service workers of the given scope.
531 boolean shouldReportForServiceWorkerScope(USVString aScope);
534 * InstallTrigger is used for extension installs. Ideally it would
535 * be something like a WebIDL namespace, but we don't support
536 * JS-implemented static things yet. See bug 863952.
538 [Replaceable, Deprecated="InstallTriggerDeprecated", Pref="extensions.InstallTrigger.enabled"]
539 readonly attribute InstallTriggerImpl? InstallTrigger;
542 * Get the nsIDOMWindowUtils for this window.
544 [Constant, Throws, ChromeOnly]
545 readonly attribute nsIDOMWindowUtils windowUtils;
548 readonly attribute WindowGlobalChild? windowGlobalChild;
551 * The principal of the client source of the window. This is supposed to be
552 * used for the service worker.
554 * This is used for APIs like https://w3c.github.io/push-api/ that extend
555 * ServiceWorkerRegistration and therefore need to operate consistently with
556 * ServiceWorkers and its Clients API. The client principal is the appropriate
557 * principal to pass to all nsIServiceWorkerManager APIs.
559 * Note that the client principal will be different from the node principal of
560 * the window's document if the window is in a third-party context when dFPI
561 * is enabled. In this case, the client principal will be the partitioned
562 * principal to support the service worker partitioning.
565 readonly attribute Principal? clientPrincipal;
568 Window includes TouchEventHandlers;
570 Window includes OnErrorEventHandlerForWindow;
572 #if defined(MOZ_WIDGET_ANDROID)
573 // https://compat.spec.whatwg.org/#windoworientation-interface
574 partial interface Window {
576 readonly attribute short orientation;
577 attribute EventHandler onorientationchange;
582 // Sidebar is deprecated and it will be removed in the next cycles. See bug 1640138.
583 partial interface Window {
584 [Replaceable, Throws, UseCounter, Pref="dom.window.sidebar.enabled"]
585 readonly attribute (External or WindowProxy) sidebar;
588 [MOZ_CAN_RUN_SCRIPT_BOUNDARY]
589 callback PromiseDocumentFlushedCallback = any ();
591 // Mozilla extensions for Chrome windows.
592 partial interface Window {
593 // The STATE_* constants need to match the corresponding enum in nsGlobalWindow.cpp.
594 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
595 const unsigned short STATE_MAXIMIZED = 1;
596 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
597 const unsigned short STATE_MINIMIZED = 2;
598 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
599 const unsigned short STATE_NORMAL = 3;
600 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
601 const unsigned short STATE_FULLSCREEN = 4;
603 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
604 readonly attribute unsigned short windowState;
606 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
607 readonly attribute boolean isFullyOccluded;
610 * browserDOMWindow provides access to yet another layer of
611 * utility functions implemented by chrome script. It will be null
612 * for DOMWindows not corresponding to browsers.
614 [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
615 attribute nsIBrowserDOMWindow? browserDOMWindow;
617 [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
618 undefined getAttention();
620 [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
621 undefined getAttentionWithCycleCount(long aCycleCount);
623 [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
624 undefined setCursor(UTF8String cursor);
626 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
627 undefined maximize();
628 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
629 undefined minimize();
630 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
632 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
633 DOMString getWorkspaceID();
634 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
635 undefined moveToWorkspace(DOMString workspaceID);
638 * Notify a default button is loaded on a dialog or a wizard.
639 * defaultButton is the default button.
641 [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
642 undefined notifyDefaultButtonLoaded(Element defaultButton);
644 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
645 readonly attribute ChromeMessageBroadcaster messageManager;
648 * Returns the message manager identified by the given group name that
649 * manages all frame loaders belonging to that group.
651 [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
652 ChromeMessageBroadcaster getGroupMessageManager(DOMString aGroup);
655 * Calls the given function as soon as a style or layout flush for the
656 * top-level document is not necessary, and returns a Promise which
657 * resolves to the callback's return value after it executes.
659 * In the event that the window goes away before a flush can occur, the
660 * callback will still be called and the Promise resolved as the window
663 * The callback _must not modify the DOM for any window in any way_. If it
664 * does, after finishing executing, the Promise returned by
665 * promiseDocumentFlushed will reject with
666 * NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR.
668 * Note that the callback can be called either synchronously or asynchronously
669 * depending on whether or not flushes are pending:
671 * The callback will be called synchronously when calling
672 * promiseDocumentFlushed when NO flushes are already pending. This is
673 * to ensure that no script has a chance to dirty the DOM before the callback
676 * The callback will be called asynchronously if a flush is pending.
678 * The expected execution order is that all pending callbacks will
679 * be fired first (and in the order that they were queued) and then the
680 * Promise resolution handlers will all be invoked later on during the
681 * next microtask checkpoint.
683 * Using window.top.promiseDocumentFlushed in combination with a callback
684 * that is querying items in a window that might be swapped out via
685 * nsFrameLoader::SwapWithOtherLoader is highly discouraged. For example:
687 * let result = await window.top.promiseDocumentFlushed(() => {
688 * return window.document.body.getBoundingClientRect();
691 * If "window" might get swapped out via nsFrameLoader::SwapWithOtherLoader
692 * at any time, then the callback might get called when the new host window
693 * will still incur layout flushes, since it's only the original host window
694 * that's being monitored via window.top.promiseDocumentFlushed.
696 * See bug 1519407 for further details.
698 * promiseDocumentFlushed does not support re-entrancy - so calling it from
699 * within a promiseDocumentFlushed callback will result in the inner call
700 * throwing an NS_ERROR_FAILURE exception, and the outer Promise rejecting
701 * with that exception.
703 * The callback function *must not make any changes which would require
704 * a style or layout flush*.
706 * Also throws NS_ERROR_FAILURE if the window is not in a state where flushes
707 * can be waited for (for example, the PresShell has not yet been created).
709 * @param {function} callback
712 [NewObject, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
713 Promise<any> promiseDocumentFlushed(PromiseDocumentFlushedCallback callback);
716 readonly attribute boolean isChromeWindow;
719 readonly attribute GleanImpl Glean;
721 readonly attribute GleanPingsImpl GleanPings;
724 partial interface Window {
725 [Pref="dom.vr.enabled"]
726 attribute EventHandler onvrdisplayconnect;
727 [Pref="dom.vr.enabled"]
728 attribute EventHandler onvrdisplaydisconnect;
729 [Pref="dom.vr.enabled"]
730 attribute EventHandler onvrdisplayactivate;
731 [Pref="dom.vr.enabled"]
732 attribute EventHandler onvrdisplaydeactivate;
733 [Pref="dom.vr.enabled"]
734 attribute EventHandler onvrdisplaypresentchange;
737 #ifndef RELEASE_OR_BETA
738 // https://drafts.css-houdini.org/css-paint-api-1/#dom-window-paintworklet
739 partial interface Window {
740 [Pref="dom.paintWorklet.enabled", Throws]
741 readonly attribute Worklet paintWorklet;
745 Window includes WindowOrWorkerGlobalScope;
747 partial interface Window {
748 [Throws, Func="nsGlobalWindowInner::IsRequestIdleCallbackEnabled"]
749 unsigned long requestIdleCallback(IdleRequestCallback callback,
750 optional IdleRequestOptions options = {});
751 [Func="nsGlobalWindowInner::IsRequestIdleCallbackEnabled"]
752 undefined cancelIdleCallback(unsigned long handle);
755 dictionary IdleRequestOptions {
756 unsigned long timeout;
759 callback IdleRequestCallback = undefined (IdleDeadline deadline);
761 partial interface Window {
763 * Returns a list of locales that the internationalization components
764 * should be localized to.
766 * The function name refers to Regional Preferences which can be either
767 * fetched from the internal internationalization database (CLDR), or
768 * from the host environment.
770 * The result is a sorted list of valid locale IDs and it should be
771 * used for all APIs that accept list of locales, like ECMA402 and L10n APIs.
773 * This API always returns at least one locale.
775 * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
777 [Func="IsChromeOrUAWidget"]
778 sequence<DOMString> getRegionalPrefsLocales();
781 * Returns a list of locales that the web content would know from the user.
783 * One of the fingerprinting technique is to recognize users from their locales
784 * exposed to web content. For those components that would be fingerprintable
785 * from the locale should call this API instead of |getRegionalPrefsLocales()|.
787 * If the pref is set to spoof locale setting, this function will return the
788 * spoofed locale, otherwise it returns what |getRegionalPrefsLocales()| returns.
790 * This API always returns at least one locale.
794 [Func="IsChromeOrUAWidget"]
795 sequence<DOMString> getWebExposedLocales();
798 * Getter funcion for IntlUtils, which provides helper functions for
801 [Throws, Func="IsChromeOrUAWidget"]
802 readonly attribute IntlUtils intlUtils;
805 partial interface Window {
806 [SameObject, Pref="dom.visualviewport.enabled", Replaceable]
807 readonly attribute VisualViewport visualViewport;
810 // Used to assign marks to appear on the scrollbar when
811 // finding on a page.
812 partial interface Window {
813 // The marks are values between 0 and scrollMax{X,Y} - scrollMin{X,Y}.
815 undefined setScrollMarks(sequence<unsigned long> marks,
816 optional boolean onHorizontalScrollbar = false);
819 dictionary WindowPostMessageOptions : StructuredSerializeOptions {
820 USVString targetOrigin = "/";