1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/webidl/XMLHttpRequest.webidl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,148 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + * 1.9 + * The origin of this IDL file is 1.10 + * www.w3.org/TR/2012/WD-XMLHttpRequest-20120117/ 1.11 + * 1.12 + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 1.13 + * liability, trademark and document use rules apply. 1.14 + */ 1.15 + 1.16 +interface Blob; 1.17 +interface InputStream; 1.18 +interface MozChannel; 1.19 +interface IID; 1.20 + 1.21 +enum XMLHttpRequestResponseType { 1.22 + "", 1.23 + "arraybuffer", 1.24 + "blob", 1.25 + "document", 1.26 + "json", 1.27 + "text", 1.28 + 1.29 + // Mozilla-specific stuff 1.30 + "moz-chunked-text", 1.31 + "moz-chunked-arraybuffer", 1.32 + "moz-blob" 1.33 +}; 1.34 + 1.35 +/** 1.36 + * Parameters for instantiating an XMLHttpRequest. They are passed as an 1.37 + * optional argument to the constructor: 1.38 + * 1.39 + * new XMLHttpRequest({anon: true, system: true}); 1.40 + */ 1.41 +dictionary MozXMLHttpRequestParameters 1.42 +{ 1.43 + /** 1.44 + * If true, the request will be sent without cookie and authentication 1.45 + * headers. 1.46 + */ 1.47 + boolean mozAnon = false; 1.48 + 1.49 + /** 1.50 + * If true, the same origin policy will not be enforced on the request. 1.51 + */ 1.52 + boolean mozSystem = false; 1.53 +}; 1.54 + 1.55 +[Constructor(optional MozXMLHttpRequestParameters params), 1.56 + // There are apparently callers, specifically CoffeeScript, who do 1.57 + // things like this: 1.58 + // c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP") 1.59 + // To handle that, we need a constructor that takes a string. 1.60 + Constructor(DOMString ignored)] 1.61 +interface XMLHttpRequest : XMLHttpRequestEventTarget { 1.62 + // event handler 1.63 + attribute EventHandler onreadystatechange; 1.64 + 1.65 + // states 1.66 + const unsigned short UNSENT = 0; 1.67 + const unsigned short OPENED = 1; 1.68 + const unsigned short HEADERS_RECEIVED = 2; 1.69 + const unsigned short LOADING = 3; 1.70 + const unsigned short DONE = 4; 1.71 + 1.72 + readonly attribute unsigned short readyState; 1.73 + 1.74 + // request 1.75 + [Throws] 1.76 + void open(ByteString method, DOMString url); 1.77 + [Throws] 1.78 + void open(ByteString method, DOMString url, boolean async, 1.79 + optional DOMString? user, optional DOMString? password); 1.80 + [Throws] 1.81 + void setRequestHeader(ByteString header, ByteString value); 1.82 + 1.83 + [SetterThrows] 1.84 + attribute unsigned long timeout; 1.85 + 1.86 + [SetterThrows] 1.87 + attribute boolean withCredentials; 1.88 + 1.89 + [Throws=Workers] 1.90 + readonly attribute XMLHttpRequestUpload upload; 1.91 + 1.92 + [Throws] 1.93 + void send(); 1.94 + [Throws] 1.95 + void send(ArrayBuffer data); 1.96 + [Throws] 1.97 + void send(ArrayBufferView data); 1.98 + [Throws] 1.99 + void send(Blob data); 1.100 + [Throws] 1.101 + void send(Document data); 1.102 + [Throws] 1.103 + void send(DOMString? data); 1.104 + [Throws] 1.105 + void send(FormData data); 1.106 + [Throws] 1.107 + void send(InputStream data); 1.108 + 1.109 + [Throws=Workers] 1.110 + void abort(); 1.111 + 1.112 + // response 1.113 + [Throws=Workers] 1.114 + readonly attribute unsigned short status; 1.115 + 1.116 + readonly attribute ByteString statusText; 1.117 + [Throws] 1.118 + ByteString? getResponseHeader(ByteString header); 1.119 + 1.120 + [Throws=Workers] 1.121 + ByteString getAllResponseHeaders(); 1.122 + 1.123 + [Throws=Workers] 1.124 + void overrideMimeType(DOMString mime); 1.125 + 1.126 + [SetterThrows] 1.127 + attribute XMLHttpRequestResponseType responseType; 1.128 + [Throws] 1.129 + readonly attribute any response; 1.130 + [Throws] 1.131 + readonly attribute DOMString? responseText; 1.132 + 1.133 + [Throws=MainThread] 1.134 + readonly attribute Document? responseXML; 1.135 + 1.136 + // Mozilla-specific stuff 1.137 + 1.138 + [SetterThrows=Workers] 1.139 + attribute boolean mozBackgroundRequest; 1.140 + 1.141 + [ChromeOnly] 1.142 + readonly attribute MozChannel? channel; 1.143 + 1.144 + [Throws] 1.145 + void sendAsBinary(DOMString body); 1.146 + [Throws, ChromeOnly] 1.147 + any getInterface(IID iid); 1.148 + 1.149 + readonly attribute boolean mozAnon; 1.150 + readonly attribute boolean mozSystem; 1.151 +};