Bug 1787199 [wpt PR 35620] - Add tests for `VisibilityStateEntry`, a=testonly
[gecko.git] / dom / webidl / Window.webidl
blob59c7b1414c546da5f9c78f7483136ce8df761b43
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  * 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
20  */
22 interface Principal;
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,
32  Exposed=Window,
33  InstrumentedProps=(AbsoluteOrientationSensor,
34                     Accelerometer,
35                     ApplicationCache,
36                     ApplicationCacheErrorEvent,
37                     Atomics,
38                     AudioParamMap,
39                     AudioWorklet,
40                     AudioWorkletNode,
41                     BackgroundFetchManager,
42                     BackgroundFetchRecord,
43                     BackgroundFetchRegistration,
44                     BeforeInstallPromptEvent,
45                     Bluetooth,
46                     BluetoothCharacteristicProperties,
47                     BluetoothDevice,
48                     BluetoothRemoteGATTCharacteristic,
49                     BluetoothRemoteGATTDescriptor,
50                     BluetoothRemoteGATTServer,
51                     BluetoothRemoteGATTService,
52                     BluetoothUUID,
53                     CanvasCaptureMediaStreamTrack,
54                     chrome,
55                     clientInformation,
56                     ClipboardItem,
57                     CSSImageValue,
58                     CSSKeywordValue,
59                     CSSMathInvert,
60                     CSSMathMax,
61                     CSSMathMin,
62                     CSSMathNegate,
63                     CSSMathProduct,
64                     CSSMathSum,
65                     CSSMathValue,
66                     CSSMatrixComponent,
67                     CSSNumericArray,
68                     CSSNumericValue,
69                     CSSPerspective,
70                     CSSPositionValue,
71                     CSSRotate,
72                     CSSScale,
73                     CSSSkew,
74                     CSSSkewX,
75                     CSSSkewY,
76                     CSSStyleValue,
77                     CSSTransformComponent,
78                     CSSTransformValue,
79                     CSSTranslate,
80                     CSSUnitValue,
81                     CSSUnparsedValue,
82                     CSSVariableReferenceValue,
83                     defaultStatus,
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.
88                     //defaultstatus,
89                     DeviceMotionEventAcceleration,
90                     DeviceMotionEventRotationRate,
91                     DOMError,
92                     EnterPictureInPictureEvent,
93                     External,
94                     FederatedCredential,
95                     Gyroscope,
96                     HTMLContentElement,
97                     HTMLDialogElement,
98                     HTMLShadowElement,
99                     ImageCapture,
100                     InputDeviceCapabilities,
101                     InputDeviceInfo,
102                     Keyboard,
103                     KeyboardLayoutMap,
104                     LinearAccelerationSensor,
105                     Lock,
106                     LockManager,
107                     MediaMetadata,
108                     MediaSession,
109                     MediaSettingsRange,
110                     MIDIAccess,
111                     MIDIConnectionEvent,
112                     MIDIInput,
113                     MIDIInputMap,
114                     MIDIMessageEvent,
115                     MIDIOutput,
116                     MIDIOutputMap,
117                     MIDIPort,
118                     NavigationPreloadManager,
119                     NetworkInformation,
120                     offscreenBuffering,
121                     OffscreenCanvas,
122                     OffscreenCanvasRenderingContext2D,
123                     onbeforeinstallprompt,
124                     oncancel,
125                     ondeviceorientationabsolute,
126                     onmousewheel,
127                     onsearch,
128                     onselectionchange,
129                     openDatabase,
130                     OrientationSensor,
131                     OverconstrainedError,
132                     PasswordCredential,
133                     PaymentAddress,
134                     PaymentInstruments,
135                     PaymentManager,
136                     PaymentMethodChangeEvent,
137                     PaymentRequest,
138                     PaymentRequestUpdateEvent,
139                     PaymentResponse,
140                     PerformanceEventTiming,
141                     PerformanceLongTaskTiming,
142                     PerformancePaintTiming,
143                     PhotoCapabilities,
144                     PictureInPictureWindow,
145                     Presentation,
146                     PresentationAvailability,
147                     PresentationConnection,
148                     PresentationConnectionAvailableEvent,
149                     PresentationConnectionCloseEvent,
150                     PresentationConnectionList,
151                     PresentationReceiver,
152                     PresentationRequest,
153                     RelativeOrientationSensor,
154                     RemotePlayback,
155                     ReportingObserver,
156                     RTCDtlsTransport,
157                     RTCError,
158                     RTCErrorEvent,
159                     RTCIceTransport,
160                     RTCSctpTransport,
161                     Sensor,
162                     SensorErrorEvent,
163                     SharedArrayBuffer,
164                     styleMedia,
165                     StylePropertyMap,
166                     StylePropertyMapReadOnly,
167                     SVGDiscardElement,
168                     SyncManager,
169                     TaskAttributionTiming,
170                     TextDecoderStream,
171                     TextEncoderStream,
172                     TextEvent,
173                     Touch,
174                     TouchEvent,
175                     TouchList,
176                     TransformStream,
177                     USB,
178                     USBAlternateInterface,
179                     USBConfiguration,
180                     USBConnectionEvent,
181                     USBDevice,
182                     USBEndpoint,
183                     USBInterface,
184                     USBInTransferResult,
185                     USBIsochronousInTransferPacket,
186                     USBIsochronousInTransferResult,
187                     USBIsochronousOutTransferPacket,
188                     USBIsochronousOutTransferResult,
189                     USBOutTransferResult,
190                     UserActivation,
191                     visualViewport,
192                     webkitCancelAnimationFrame,
193                     webkitMediaStream,
194                     WebKitMutationObserver,
195                     webkitRequestAnimationFrame,
196                     webkitRequestFileSystem,
197                     webkitResolveLocalFileSystemURL,
198                     webkitRTCPeerConnection,
199                     webkitSpeechGrammar,
200                     webkitSpeechGrammarList,
201                     webkitSpeechRecognition,
202                     webkitSpeechRecognitionError,
203                     webkitSpeechRecognitionEvent,
204                     webkitStorageInfo,
205                     Worklet,
206                     WritableStream)]
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);
246   // the user agent
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;
254   // user prompts
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"]
260   undefined print();
262   // Returns a window that you can use for a print preview.
263   //
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;
334   // browsing context
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);
344   // viewport
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;
376   // client
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;
404 #ifdef MOZ_WEBSPEECH
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;
411 #endif
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
419   /**
420    * Method for scrolling this window by a number of lines.
421    */
422   undefined                 scrollByLines(long numLines, optional ScrollOptions options = {});
424   /**
425    * Method for scrolling this window by a number of pages.
426    */
427   undefined                 scrollByPages(long numPages, optional ScrollOptions options = {});
429   /**
430    * Method for sizing this window to the content in the window.
431    */
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.
453   [ChromeOnly, Throws]
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);
470   /* Find in page.
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
478    */
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);
497   /**
498    * This method is here for backwards compatibility with 4.x only,
499    * its implementation is a no-op
500    */
501   undefined                 setResizable(boolean resizable);
503   /**
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).
508    */
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);
520   /**
521    * Same as nsIDOMWindow.windowRoot, useful for event listener targeting.
522    */
523   [ChromeOnly, Throws]
524   readonly attribute WindowRoot? windowRoot;
526   /**
527    * ChromeOnly method to determine if a particular window should see console
528    * reports from service workers of the given scope.
529    */
530   [ChromeOnly]
531   boolean shouldReportForServiceWorkerScope(USVString aScope);
533   /**
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.
537    */
538   [Replaceable, Deprecated="InstallTriggerDeprecated", Pref="extensions.InstallTrigger.enabled"]
539   readonly attribute InstallTriggerImpl? InstallTrigger;
541   /**
542    * Get the nsIDOMWindowUtils for this window.
543    */
544   [Constant, Throws, ChromeOnly]
545   readonly attribute nsIDOMWindowUtils windowUtils;
547   [Pure, ChromeOnly]
548   readonly attribute WindowGlobalChild? windowGlobalChild;
550   /**
551    * The principal of the client source of the window. This is supposed to be
552    * used for the service worker.
553    *
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.
558    *
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.
563    */
564   [ChromeOnly]
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 {
575   [NeedsCallerType]
576   readonly attribute short orientation;
577            attribute EventHandler onorientationchange;
579 #endif
581 // Mozilla extension
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;
609   /**
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.
613    */
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"]
631   undefined                 restore();
632   [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
633   DOMString                 getWorkspaceID();
634   [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
635   undefined                 moveToWorkspace(DOMString workspaceID);
637   /**
638    * Notify a default button is loaded on a dialog or a wizard.
639    * defaultButton is the default button.
640    */
641   [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
642   undefined notifyDefaultButtonLoaded(Element defaultButton);
644   [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
645   readonly attribute ChromeMessageBroadcaster messageManager;
647   /**
648    * Returns the message manager identified by the given group name that
649    * manages all frame loaders belonging to that group.
650    */
651   [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
652   ChromeMessageBroadcaster getGroupMessageManager(DOMString aGroup);
654   /**
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.
658    *
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
661    * tears itself down.
662    *
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.
667    *
668    * Note that the callback can be called either synchronously or asynchronously
669    * depending on whether or not flushes are pending:
670    *
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
674    *   is called.
675    *
676    *   The callback will be called asynchronously if a flush is pending.
677    *
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.
682    *
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:
686    *
687    *   let result = await window.top.promiseDocumentFlushed(() => {
688    *     return window.document.body.getBoundingClientRect();
689    *   });
690    *
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.
695    *
696    *   See bug 1519407 for further details.
697    *
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.
702    *
703    * The callback function *must not make any changes which would require
704    * a style or layout flush*.
705    *
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).
708    *
709    * @param {function} callback
710    * @returns {Promise}
711    */
712   [NewObject, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
713   Promise<any> promiseDocumentFlushed(PromiseDocumentFlushedCallback callback);
715   [ChromeOnly]
716   readonly attribute boolean isChromeWindow;
718   [ChromeOnly]
719   readonly attribute GleanImpl Glean;
720   [ChromeOnly]
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;
743 #endif
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 {
762   /**
763    * Returns a list of locales that the internationalization components
764    * should be localized to.
765    *
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.
769    *
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.
772    *
773    * This API always returns at least one locale.
774    *
775    * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
776    */
777   [Func="IsChromeOrUAWidget"]
778   sequence<DOMString> getRegionalPrefsLocales();
780   /**
781    * Returns a list of locales that the web content would know from the user.
782    *
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()|.
786    *
787    * If the pref is set to spoof locale setting, this function will return the
788    * spoofed locale, otherwise it returns what |getRegionalPrefsLocales()| returns.
789    *
790    * This API always returns at least one locale.
791    *
792    * Example: ["en-US"]
793    */
794   [Func="IsChromeOrUAWidget"]
795   sequence<DOMString> getWebExposedLocales();
797   /**
798    * Getter funcion for IntlUtils, which provides helper functions for
799    * localization.
800    */
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}.
814   [ChromeOnly]
815   undefined setScrollMarks(sequence<unsigned long> marks,
816                            optional boolean onHorizontalScrollbar = false);
819 dictionary WindowPostMessageOptions : StructuredSerializeOptions {
820   USVString targetOrigin = "/";