michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: * michael@0: * The origin of this IDL file is michael@0: * www.w3.org/TR/2012/WD-XMLHttpRequest-20120117/ michael@0: * michael@0: * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C michael@0: * liability, trademark and document use rules apply. michael@0: */ michael@0: michael@0: interface Blob; michael@0: interface InputStream; michael@0: interface MozChannel; michael@0: interface IID; michael@0: michael@0: enum XMLHttpRequestResponseType { michael@0: "", michael@0: "arraybuffer", michael@0: "blob", michael@0: "document", michael@0: "json", michael@0: "text", michael@0: michael@0: // Mozilla-specific stuff michael@0: "moz-chunked-text", michael@0: "moz-chunked-arraybuffer", michael@0: "moz-blob" michael@0: }; michael@0: michael@0: /** michael@0: * Parameters for instantiating an XMLHttpRequest. They are passed as an michael@0: * optional argument to the constructor: michael@0: * michael@0: * new XMLHttpRequest({anon: true, system: true}); michael@0: */ michael@0: dictionary MozXMLHttpRequestParameters michael@0: { michael@0: /** michael@0: * If true, the request will be sent without cookie and authentication michael@0: * headers. michael@0: */ michael@0: boolean mozAnon = false; michael@0: michael@0: /** michael@0: * If true, the same origin policy will not be enforced on the request. michael@0: */ michael@0: boolean mozSystem = false; michael@0: }; michael@0: michael@0: [Constructor(optional MozXMLHttpRequestParameters params), michael@0: // There are apparently callers, specifically CoffeeScript, who do michael@0: // things like this: michael@0: // c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP") michael@0: // To handle that, we need a constructor that takes a string. michael@0: Constructor(DOMString ignored)] michael@0: interface XMLHttpRequest : XMLHttpRequestEventTarget { michael@0: // event handler michael@0: attribute EventHandler onreadystatechange; michael@0: michael@0: // states michael@0: const unsigned short UNSENT = 0; michael@0: const unsigned short OPENED = 1; michael@0: const unsigned short HEADERS_RECEIVED = 2; michael@0: const unsigned short LOADING = 3; michael@0: const unsigned short DONE = 4; michael@0: michael@0: readonly attribute unsigned short readyState; michael@0: michael@0: // request michael@0: [Throws] michael@0: void open(ByteString method, DOMString url); michael@0: [Throws] michael@0: void open(ByteString method, DOMString url, boolean async, michael@0: optional DOMString? user, optional DOMString? password); michael@0: [Throws] michael@0: void setRequestHeader(ByteString header, ByteString value); michael@0: michael@0: [SetterThrows] michael@0: attribute unsigned long timeout; michael@0: michael@0: [SetterThrows] michael@0: attribute boolean withCredentials; michael@0: michael@0: [Throws=Workers] michael@0: readonly attribute XMLHttpRequestUpload upload; michael@0: michael@0: [Throws] michael@0: void send(); michael@0: [Throws] michael@0: void send(ArrayBuffer data); michael@0: [Throws] michael@0: void send(ArrayBufferView data); michael@0: [Throws] michael@0: void send(Blob data); michael@0: [Throws] michael@0: void send(Document data); michael@0: [Throws] michael@0: void send(DOMString? data); michael@0: [Throws] michael@0: void send(FormData data); michael@0: [Throws] michael@0: void send(InputStream data); michael@0: michael@0: [Throws=Workers] michael@0: void abort(); michael@0: michael@0: // response michael@0: [Throws=Workers] michael@0: readonly attribute unsigned short status; michael@0: michael@0: readonly attribute ByteString statusText; michael@0: [Throws] michael@0: ByteString? getResponseHeader(ByteString header); michael@0: michael@0: [Throws=Workers] michael@0: ByteString getAllResponseHeaders(); michael@0: michael@0: [Throws=Workers] michael@0: void overrideMimeType(DOMString mime); michael@0: michael@0: [SetterThrows] michael@0: attribute XMLHttpRequestResponseType responseType; michael@0: [Throws] michael@0: readonly attribute any response; michael@0: [Throws] michael@0: readonly attribute DOMString? responseText; michael@0: michael@0: [Throws=MainThread] michael@0: readonly attribute Document? responseXML; michael@0: michael@0: // Mozilla-specific stuff michael@0: michael@0: [SetterThrows=Workers] michael@0: attribute boolean mozBackgroundRequest; michael@0: michael@0: [ChromeOnly] michael@0: readonly attribute MozChannel? channel; michael@0: michael@0: [Throws] michael@0: void sendAsBinary(DOMString body); michael@0: [Throws, ChromeOnly] michael@0: any getInterface(IID iid); michael@0: michael@0: readonly attribute boolean mozAnon; michael@0: readonly attribute boolean mozSystem; michael@0: };