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 */ 20 21// invalid widl 22// interface ApplicationCache; 23// interface IID; 24// interface nsIBrowserDOMWindow; 25// interface XULControllers; 26 27// http://www.whatwg.org/specs/web-apps/current-work/ 28[Global=Window, 29 Exposed=Window, 30 LegacyUnenumerableNamedProperties] 31/*sealed*/ interface Window : EventTarget { 32 // the current browsing context 33 [Unforgeable, Constant, StoreInSlot, 34 CrossOriginReadable] readonly attribute Window window; 35 [Replaceable, Constant, StoreInSlot, 36 CrossOriginReadable] readonly attribute Window self; 37 [Unforgeable, StoreInSlot, Pure] readonly attribute Document? document; 38 [Throws] attribute DOMString name; 39 [PutForwards=href, Unforgeable, BinaryName="getLocation", 40 CrossOriginReadable, CrossOriginWritable] readonly attribute Location location; 41 [Throws] readonly attribute History history; 42 [Func="CustomElementRegistry::IsCustomElementEnabled"] 43 readonly attribute CustomElementRegistry customElements; 44 [Replaceable, Throws] readonly attribute BarProp locationbar; 45 [Replaceable, Throws] readonly attribute BarProp menubar; 46 [Replaceable, Throws] readonly attribute BarProp personalbar; 47 [Replaceable, Throws] readonly attribute BarProp scrollbars; 48 [Replaceable, Throws] readonly attribute BarProp statusbar; 49 [Replaceable, Throws] readonly attribute BarProp toolbar; 50 [Throws] attribute DOMString status; 51 [Throws, CrossOriginCallable] undefined close(); 52 [Throws, CrossOriginReadable] readonly attribute boolean closed; 53 [Throws] undefined stop(); 54 [Throws, CrossOriginCallable] undefined focus(); 55 [Throws, CrossOriginCallable] undefined blur(); 56 [Replaceable] readonly attribute any event; 57 58 // other browsing contexts 59 [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy frames; 60 [Replaceable, CrossOriginReadable] readonly attribute unsigned long length; 61 //[Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy top; 62 [Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy? top; 63 [Throws, CrossOriginReadable] attribute any opener; 64 //[Throws] readonly attribute WindowProxy parent; 65 [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy? parent; 66 [Throws, NeedsSubjectPrincipal] readonly attribute Element? frameElement; 67 //[Throws] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = ""); 68 [Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = ""); 69 getter object (DOMString name); 70 71 // the user agent 72 readonly attribute Navigator navigator; 73//#ifdef HAVE_SIDEBAR 74 [Replaceable, Throws] readonly attribute External external; 75//#endif 76 [Throws, Pref="browser.cache.offline.enable", Func="nsGlobalWindowInner::OfflineCacheAllowedForContext"] readonly attribute ApplicationCache applicationCache; 77 78 // user prompts 79 [Throws, NeedsSubjectPrincipal] undefined alert(); 80 [Throws, NeedsSubjectPrincipal] undefined alert(DOMString message); 81 [Throws, NeedsSubjectPrincipal] boolean confirm(optional DOMString message = ""); 82 [Throws, NeedsSubjectPrincipal] DOMString? prompt(optional DOMString message = "", optional DOMString default = ""); 83 [Throws, Func="nsGlobalWindowInner::IsWindowPrintEnabled"] 84 undefined print(); 85 86 [Throws, CrossOriginCallable, NeedsSubjectPrincipal] 87 undefined postMessage(any message, DOMString targetOrigin, optional sequence<object> transfer = []); 88 89 // also has obsolete members 90}; 91Window includes GlobalEventHandlers; 92Window includes WindowEventHandlers; 93 94// https://www.w3.org/TR/appmanifest/#onappinstalled-attribute 95partial interface Window { 96 [Pref="dom.manifest.onappinstalled"] 97 attribute EventHandler onappinstalled; 98}; 99 100// http://www.whatwg.org/specs/web-apps/current-work/ 101interface mixin WindowSessionStorage { 102 //[Throws] readonly attribute Storage sessionStorage; 103 [Throws] readonly attribute Storage? sessionStorage; 104}; 105Window includes WindowSessionStorage; 106 107// http://www.whatwg.org/specs/web-apps/current-work/ 108interface mixin WindowLocalStorage { 109 [Throws] readonly attribute Storage? localStorage; 110}; 111Window includes WindowLocalStorage; 112 113// http://www.whatwg.org/specs/web-apps/current-work/ 114partial interface Window { 115 undefined captureEvents(); 116 undefined releaseEvents(); 117}; 118 119// https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html 120partial interface Window { 121 //[Throws] Selection getSelection(); 122 [Throws] Selection? getSelection(); 123}; 124 125// http://dev.w3.org/csswg/cssom/ 126partial interface Window { 127 //[NewObject, Throws] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString pseudoElt = ""); 128 [NewObject, Throws] CSSStyleDeclaration? getComputedStyle(Element elt, optional DOMString pseudoElt = ""); 129}; 130 131// http://dev.w3.org/csswg/cssom-view/ 132enum ScrollBehavior { "auto", "instant", "smooth" }; 133 134dictionary ScrollOptions { 135 ScrollBehavior behavior = "auto"; 136}; 137 138dictionary ScrollToOptions : ScrollOptions { 139 unrestricted double left; 140 unrestricted double top; 141}; 142 143partial interface Window { 144 //[Throws, NewObject, NeedsCallerType] MediaQueryList matchMedia(DOMString query); 145 [Throws, NewObject, NeedsCallerType] MediaQueryList? matchMedia(DOMString query); 146 // Per spec, screen is SameObject, but we don't actually guarantee that given 147 // nsGlobalWindow::Cleanup. :( 148 //[SameObject, Replaceable, Throws] readonly attribute Screen screen; 149 [Replaceable, Throws] readonly attribute Screen screen; 150 151 // browsing context 152 //[Throws] undefined moveTo(double x, double y); 153 //[Throws] undefined moveBy(double x, double y); 154 //[Throws] undefined resizeTo(double x, double y); 155 //[Throws] undefined resizeBy(double x, double y); 156 [Throws, NeedsCallerType] undefined moveTo(long x, long y); 157 [Throws, NeedsCallerType] undefined moveBy(long x, long y); 158 [Throws, NeedsCallerType] undefined resizeTo(long x, long y); 159 [Throws, NeedsCallerType] undefined resizeBy(long x, long y); 160 161 // viewport 162 // These are writable because we allow chrome to write them. And they need 163 // to use 'any' as the type, because non-chrome writing them needs to act 164 // like a [Replaceable] attribute would, which needs the original JS value. 165 //[Replaceable, Throws] readonly attribute double innerWidth; 166 //[Replaceable, Throws] readonly attribute double innerHeight; 167 [Throws, NeedsCallerType] attribute any innerWidth; 168 [Throws, NeedsCallerType] attribute any innerHeight; 169 170 // viewport scrolling 171 undefined scroll(unrestricted double x, unrestricted double y); 172 undefined scroll(optional ScrollToOptions options); 173 undefined scrollTo(unrestricted double x, unrestricted double y); 174 undefined scrollTo(optional ScrollToOptions options); 175 undefined scrollBy(unrestricted double x, unrestricted double y); 176 undefined scrollBy(optional ScrollToOptions options); 177 // The four properties below are double per spec at the moment, but whether 178 // that will continue is unclear. 179 [Replaceable, Throws] readonly attribute double scrollX; 180 [Replaceable, Throws] readonly attribute double pageXOffset; 181 [Replaceable, Throws] readonly attribute double scrollY; 182 [Replaceable, Throws] readonly attribute double pageYOffset; 183 184 // client 185 // These are writable because we allow chrome to write them. And they need 186 // to use 'any' as the type, because non-chrome writing them needs to act 187 // like a [Replaceable] attribute would, which needs the original JS value. 188 //[Replaceable, Throws] readonly attribute double screenX; 189 //[Replaceable, Throws] readonly attribute double screenY; 190 //[Replaceable, Throws] readonly attribute double outerWidth; 191 //[Replaceable, Throws] readonly attribute double outerHeight; 192 [Throws, NeedsCallerType] attribute any screenX; 193 [Throws, NeedsCallerType] attribute any screenY; 194 [Throws, NeedsCallerType] attribute any outerWidth; 195 [Throws, NeedsCallerType] attribute any outerHeight; 196 [Replaceable] readonly attribute double devicePixelRatio; 197}; 198 199// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html 200partial interface Window { 201 [Throws] long requestAnimationFrame(FrameRequestCallback callback); 202 [Throws] undefined cancelAnimationFrame(long handle); 203}; 204callback FrameRequestCallback = undefined (DOMHighResTimeStamp time); 205 206// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html 207partial interface Window { 208 [Replaceable, Pure, StoreInSlot] readonly attribute Performance? performance; 209}; 210 211// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html 212Window includes GlobalCrypto; 213 214// https://fidoalliance.org/specifications/download/ 215Window includes GlobalU2F; 216 217//#ifdef MOZ_WEBSPEECH 218// http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html 219interface mixin SpeechSynthesisGetter { 220 [Throws, Pref="media.webspeech.synth.enabled"] readonly attribute SpeechSynthesis speechSynthesis; 221}; 222 223Window includes SpeechSynthesisGetter; 224//#endif 225 226Window includes TouchEventHandlers; 227 228Window includes OnErrorEventHandlerForWindow; 229 230//#if defined(MOZ_WIDGET_ANDROID) 231// https://compat.spec.whatwg.org/#windoworientation-interface 232partial interface Window { 233 [NeedsCallerType] 234 readonly attribute short orientation; 235 attribute EventHandler onorientationchange; 236}; 237//#endif 238 239callback PromiseDocumentFlushedCallback = any (); 240 241partial interface Window { 242 [Pref="dom.vr.enabled"] 243 attribute EventHandler onvrdisplayconnect; 244 [Pref="dom.vr.enabled"] 245 attribute EventHandler onvrdisplaydisconnect; 246 [Pref="dom.vr.enabled"] 247 attribute EventHandler onvrdisplayactivate; 248 [Pref="dom.vr.enabled"] 249 attribute EventHandler onvrdisplaydeactivate; 250 [Pref="dom.vr.enabled"] 251 attribute EventHandler onvrdisplaypresentchange; 252}; 253 254// https://drafts.css-houdini.org/css-paint-api-1/#dom-window-paintworklet 255partial interface Window { 256 [Pref="dom.paintWorklet.enabled", Throws] 257 readonly attribute Worklet paintWorklet; 258}; 259 260Window includes WindowOrWorkerGlobalScope; 261 262partial interface Window { 263 [Throws, Func="nsGlobalWindowInner::IsRequestIdleCallbackEnabled"] 264 unsigned long requestIdleCallback(IdleRequestCallback callback, 265 optional IdleRequestOptions options); 266 [Func="nsGlobalWindowInner::IsRequestIdleCallbackEnabled"] 267 undefined cancelIdleCallback(unsigned long handle); 268}; 269 270dictionary IdleRequestOptions { 271 unsigned long timeout; 272}; 273 274callback IdleRequestCallback = undefined (IdleDeadline deadline); 275