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 */
9
10typedef (Request or USVString) RequestInfo;
11typedef unsigned long nsContentPolicyType;
12
13[Exposed=(Window,Worker)]
14interface Request {
15  [Throws]
16  constructor(RequestInfo input, optional RequestInit init = {});
17
18  readonly attribute ByteString method;
19  readonly attribute USVString url;
20  [SameObject, BinaryName="headers_"] readonly attribute Headers headers;
21
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;
31
32  // If a main-thread fetch() promise rejects, the error passed will be a
33  // nsresult code.
34  [ChromeOnly]
35  readonly attribute boolean mozErrors;
36
37  [BinaryName="getOrCreateSignal"]
38  readonly attribute AbortSignal signal;
39
40  [Throws,
41   NewObject] Request clone();
42
43  // Bug 1124638 - Allow chrome callers to set the context.
44  [ChromeOnly]
45  void overrideContentPolicyType(nsContentPolicyType context);
46};
47Request includes Body;
48
49dictionary 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;
60
61  [ChromeOnly]
62  boolean mozErrors;
63
64  AbortSignal? signal;
65
66  [Pref="dom.fetchObserver.enabled"]
67  ObserverCallback observe;
68};
69
70enum RequestDestination {
71  "",
72  "audio", "audioworklet", "document", "embed", "font", "frame", "iframe",
73  "image", "manifest", "object", "paintworklet", "report", "script",
74  "sharedworker", "style",  "track", "video", "worker", "xslt"
75};
76
77enum RequestMode { "same-origin", "no-cors", "cors", "navigate" };
78enum RequestCredentials { "omit", "same-origin", "include" };
79enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
80enum RequestRedirect { "follow", "error", "manual" };
81