WindowOrWorkerGlobalScope.webidl (3794B)
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/multipage/webappapis.html#windoworworkerglobalscope-mixin 8 * https://fetch.spec.whatwg.org/#fetch-method 9 * https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object 10 * https://w3c.github.io/ServiceWorker/#self-caches 11 */ 12 13 typedef (Function or TrustedScript or DOMString) TimerHandler; 14 15 // https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope-mixin 16 [Exposed=(Window,Worker)] 17 interface mixin WindowOrWorkerGlobalScope { 18 [Replaceable] readonly attribute USVString origin; 19 readonly attribute boolean crossOriginIsolated; 20 21 [Throws, NeedsCallerType] 22 undefined reportError(any e); 23 24 // base64 utility methods 25 [Throws] 26 DOMString btoa(DOMString btoa); 27 [Throws] 28 DOMString atob(DOMString atob); 29 30 // timers 31 [Throws, NeedsSubjectPrincipal=NonSystem] 32 long setTimeout(TimerHandler handler, optional long timeout = 0, any... arguments); 33 undefined clearTimeout(optional long handle = 0); 34 [Throws, NeedsSubjectPrincipal=NonSystem] 35 long setInterval(TimerHandler handler, optional long timeout = 0, any... unused); 36 undefined clearInterval(optional long handle = 0); 37 38 // microtask queuing 39 undefined queueMicrotask(VoidFunction callback); 40 41 // ImageBitmap 42 [Throws] 43 Promise<ImageBitmap> createImageBitmap(ImageBitmapSource aImage, 44 optional ImageBitmapOptions aOptions = {}); 45 [Throws] 46 Promise<ImageBitmap> createImageBitmap(ImageBitmapSource aImage, 47 long aSx, long aSy, long aSw, long aSh, 48 optional ImageBitmapOptions aOptions = {}); 49 50 // structured cloning 51 [Throws] 52 any structuredClone(any value, optional StructuredSerializeOptions options = {}); 53 }; 54 55 // https://fetch.spec.whatwg.org/#fetch-method 56 partial interface mixin WindowOrWorkerGlobalScope { 57 [NewObject, NeedsCallerType] 58 Promise<Response> fetch(RequestInfo input, optional RequestInit init = {}); 59 }; 60 61 // https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object 62 partial interface mixin WindowOrWorkerGlobalScope { 63 readonly attribute boolean isSecureContext; 64 }; 65 66 // http://w3c.github.io/IndexedDB/#factory-interface 67 partial interface mixin WindowOrWorkerGlobalScope { 68 // readonly attribute IDBFactory indexedDB; // bug 1776789 69 [Throws] 70 readonly attribute IDBFactory? indexedDB; 71 }; 72 73 // https://w3c.github.io/ServiceWorker/#self-caches 74 partial interface mixin WindowOrWorkerGlobalScope { 75 [Throws, Func="cache::CacheStorage::CachesEnabled", SameObject] 76 readonly attribute CacheStorage caches; 77 }; 78 79 // https://wicg.github.io/scheduling-apis/#ref-for-windoworworkerglobalscope-scheduler 80 partial interface mixin WindowOrWorkerGlobalScope { 81 [Replaceable, Pref="dom.enable_web_task_scheduling", SameObject] 82 readonly attribute Scheduler scheduler; 83 }; 84 85 86 // https://w3c.github.io/trusted-types/dist/spec/#extensions-to-the-windoworworkerglobalscope-interface 87 partial interface mixin WindowOrWorkerGlobalScope { 88 [Pref="dom.security.trusted_types.enabled"] 89 readonly attribute TrustedTypePolicyFactory trustedTypes; 90 }; 91 92 partial interface mixin WindowOrWorkerGlobalScope { 93 // A testing function to check if the given target is active in the current context. 94 // See valid targets at toolkit/components/resistfingerprinting/RFPTargets.inc 95 [Throws, Pref="privacy.fingerprintingProtection.testing"] 96 boolean isRFPTargetActive(DOMString aTargetName); 97 };