Bug 1688354 [wpt PR 27298] - Treat 'rem' as an absolute unit for font size, a=testonly
[gecko.git] / dom / xhr / XMLHttpRequest.h
blob46339eb35360de88eb992e552a0574fbe8f66b78
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_XMLHttpRequest_h
8 #define mozilla_dom_XMLHttpRequest_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/ErrorResult.h"
12 #include "mozilla/dom/XMLHttpRequestEventTarget.h"
13 #include "mozilla/dom/XMLHttpRequestBinding.h"
15 class nsIInputStream;
17 namespace mozilla {
18 namespace dom {
20 class Blob;
21 class DOMString;
22 class FormData;
23 class URLSearchParams;
24 class XMLHttpRequestUpload;
26 class XMLHttpRequest : public XMLHttpRequestEventTarget {
27 public:
28 static already_AddRefed<XMLHttpRequest> Constructor(
29 const GlobalObject& aGlobal, const MozXMLHttpRequestParameters& aParams,
30 ErrorResult& aRv);
32 static already_AddRefed<XMLHttpRequest> Constructor(
33 const GlobalObject& aGlobal, const nsAString& ignored, ErrorResult& aRv) {
34 // Pretend like someone passed null, so we can pick up the default values
35 MozXMLHttpRequestParameters params;
36 if (!params.Init(aGlobal.Context(), JS::NullHandleValue)) {
37 aRv.Throw(NS_ERROR_UNEXPECTED);
38 return nullptr;
41 return Constructor(aGlobal, params, aRv);
44 IMPL_EVENT_HANDLER(readystatechange)
46 virtual uint16_t ReadyState() const = 0;
48 virtual void Open(const nsACString& aMethod, const nsAString& aUrl,
49 ErrorResult& aRv) = 0;
51 virtual void Open(const nsACString& aMethod, const nsAString& aUrl,
52 bool aAsync, const nsAString& aUser,
53 const nsAString& aPassword, ErrorResult& aRv) = 0;
55 virtual void SetRequestHeader(const nsACString& aHeader,
56 const nsACString& aValue, ErrorResult& aRv) = 0;
58 virtual uint32_t Timeout() const = 0;
60 virtual void SetTimeout(uint32_t aTimeout, ErrorResult& aRv) = 0;
62 virtual bool WithCredentials() const = 0;
64 virtual void SetWithCredentials(bool aWithCredentials, ErrorResult& aRv) = 0;
66 virtual XMLHttpRequestUpload* GetUpload(ErrorResult& aRv) = 0;
68 virtual void Send(
69 const Nullable<
70 DocumentOrBlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString>&
71 aData,
72 ErrorResult& aRv) = 0;
74 virtual void SendInputStream(nsIInputStream* aInputStream,
75 ErrorResult& aRv) = 0;
77 virtual void Abort(ErrorResult& aRv) = 0;
79 virtual void GetResponseURL(nsAString& aUrl) = 0;
81 virtual uint32_t GetStatus(ErrorResult& aRv) = 0;
83 virtual void GetStatusText(nsACString& aStatusText, ErrorResult& aRv) = 0;
85 virtual void GetResponseHeader(const nsACString& aHeader, nsACString& aResult,
86 ErrorResult& aRv) = 0;
88 virtual void GetAllResponseHeaders(nsACString& aResponseHeaders,
89 ErrorResult& aRv) = 0;
91 virtual void OverrideMimeType(const nsAString& aMimeType,
92 ErrorResult& aRv) = 0;
94 virtual XMLHttpRequestResponseType ResponseType() const = 0;
96 virtual void SetResponseType(XMLHttpRequestResponseType aType,
97 ErrorResult& aRv) = 0;
99 virtual void GetResponse(JSContext* aCx,
100 JS::MutableHandle<JS::Value> aResponse,
101 ErrorResult& aRv) = 0;
103 virtual void GetResponseText(DOMString& aResponseText, ErrorResult& aRv) = 0;
105 virtual Document* GetResponseXML(ErrorResult& aRv) = 0;
107 virtual bool MozBackgroundRequest() const = 0;
109 virtual void SetMozBackgroundRequest(bool aMozBackgroundRequest,
110 ErrorResult& aRv) = 0;
112 virtual nsIChannel* GetChannel() const = 0;
114 // We need a GetInterface callable from JS for chrome JS
115 virtual void GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
116 JS::MutableHandle<JS::Value> aRetval,
117 ErrorResult& aRv) = 0;
119 virtual void SetOriginAttributes(
120 const mozilla::dom::OriginAttributesDictionary& aAttrs) = 0;
122 virtual uint16_t ErrorCode() const = 0;
124 virtual bool MozAnon() const = 0;
126 virtual bool MozSystem() const = 0;
128 virtual JSObject* WrapObject(JSContext* aCx,
129 JS::Handle<JSObject*> aGivenProto) override {
130 return mozilla::dom::XMLHttpRequest_Binding::Wrap(aCx, this, aGivenProto);
133 protected:
134 explicit XMLHttpRequest(nsIGlobalObject* aGlobalObject)
135 : XMLHttpRequestEventTarget(aGlobalObject) {}
138 } // namespace dom
139 } // namespace mozilla
141 #endif // mozilla_dom_XMLHttpRequest_h