Bug 1614879 [wpt PR 21750] - Set request mode for beacon request with non-cors-safeli...
[gecko.git] / dom / webidl / Request.webidl
blob3247d0ae8268904cdbe0e9b05a284fa5ee7b1987
1 /* -*- Mode: IDL; tab-width: 1; 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://fetch.spec.whatwg.org/#request-class
8  */
10 typedef (Request or USVString) RequestInfo;
11 typedef unsigned long nsContentPolicyType;
13 [Exposed=(Window,Worker)]
14 interface Request {
15   [Throws]
16   constructor(RequestInfo input, optional RequestInit init = {});
18   readonly attribute ByteString method;
19   readonly attribute USVString url;
20   [SameObject, BinaryName="headers_"] readonly attribute Headers headers;
22   readonly attribute RequestDestination destination;
23   readonly attribute USVString referrer;
24   [BinaryName="referrerPolicy_"]
25   readonly attribute ReferrerPolicy referrerPolicy;
26   readonly attribute RequestMode mode;
27   readonly attribute RequestCredentials credentials;
28   readonly attribute RequestCache cache;
29   readonly attribute RequestRedirect redirect;
30   readonly attribute DOMString integrity;
32   // If a main-thread fetch() promise rejects, the error passed will be a
33   // nsresult code.
34   [ChromeOnly]
35   readonly attribute boolean mozErrors;
37   [BinaryName="getOrCreateSignal"]
38   readonly attribute AbortSignal signal;
40   [Throws,
41    NewObject] Request clone();
43   // Bug 1124638 - Allow chrome callers to set the context.
44   [ChromeOnly]
45   void overrideContentPolicyType(nsContentPolicyType context);
47 Request includes Body;
49 dictionary RequestInit {
50   ByteString method;
51   HeadersInit headers;
52   BodyInit? body;
53   USVString referrer;
54   ReferrerPolicy referrerPolicy;
55   RequestMode mode;
56   RequestCredentials credentials;
57   RequestCache cache;
58   RequestRedirect redirect;
59   DOMString integrity;
61   [ChromeOnly]
62   boolean mozErrors;
64   AbortSignal? signal;
66   [Pref="dom.fetchObserver.enabled"]
67   ObserverCallback observe;
70 enum RequestDestination {
71   "",
72   "audio", "audioworklet", "document", "embed", "font", "image", "manifest", "object",
73   "paintworklet", "report", "script", "sharedworker", "style",  "track", "video",
74   "worker", "xslt"
77 enum RequestMode { "same-origin", "no-cors", "cors", "navigate" };
78 enum RequestCredentials { "omit", "same-origin", "include" };
79 enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
80 enum RequestRedirect { "follow", "error", "manual" };