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 * 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
13 // https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope-mixin
14 [Exposed=(Window,Worker)]
15 interface mixin WindowOrWorkerGlobalScope {
16 [Replaceable] readonly attribute USVString origin;
17 readonly attribute boolean crossOriginIsolated;
19 [Throws, NeedsCallerType]
20 undefined reportError(any e);
22 // base64 utility methods
24 DOMString btoa(DOMString btoa);
26 DOMString atob(DOMString atob);
29 // NOTE: We're using overloads where the spec uses a union. Should
30 // be black-box the same.
32 long setTimeout(Function handler, optional long timeout = 0, any... arguments);
34 long setTimeout(DOMString handler, optional long timeout = 0, any... unused);
35 undefined clearTimeout(optional long handle = 0);
37 long setInterval(Function handler, optional long timeout = 0, any... arguments);
39 long setInterval(DOMString handler, optional long timeout = 0, any... unused);
40 undefined clearInterval(optional long handle = 0);
43 undefined queueMicrotask(VoidFunction callback);
47 Promise<ImageBitmap> createImageBitmap(ImageBitmapSource aImage,
48 optional ImageBitmapOptions aOptions = {});
50 Promise<ImageBitmap> createImageBitmap(ImageBitmapSource aImage,
51 long aSx, long aSy, long aSw, long aSh,
52 optional ImageBitmapOptions aOptions = {});
56 any structuredClone(any value, optional StructuredSerializeOptions options = {});
59 // https://fetch.spec.whatwg.org/#fetch-method
60 partial interface mixin WindowOrWorkerGlobalScope {
61 [NewObject, NeedsCallerType]
62 Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
65 // https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object
66 partial interface mixin WindowOrWorkerGlobalScope {
67 readonly attribute boolean isSecureContext;
70 // http://w3c.github.io/IndexedDB/#factory-interface
71 partial interface mixin WindowOrWorkerGlobalScope {
72 // readonly attribute IDBFactory indexedDB; // bug 1776789
74 readonly attribute IDBFactory? indexedDB;
77 // https://w3c.github.io/ServiceWorker/#self-caches
78 partial interface mixin WindowOrWorkerGlobalScope {
79 [Throws, Func="nsGlobalWindowInner::CachesEnabled", SameObject]
80 readonly attribute CacheStorage caches;
83 // https://wicg.github.io/scheduling-apis/#ref-for-windoworworkerglobalscope-scheduler
84 partial interface mixin WindowOrWorkerGlobalScope {
85 [Replaceable, Pref="dom.enable_web_task_scheduling", SameObject]
86 readonly attribute Scheduler scheduler;
90 // https://w3c.github.io/trusted-types/dist/spec/#extensions-to-the-windoworworkerglobalscope-interface
91 partial interface mixin WindowOrWorkerGlobalScope {
92 [Pref="dom.security.trusted_types.enabled"]
93 readonly attribute TrustedTypePolicyFactory trustedTypes;