Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 5 | * |
michael@0 | 6 | * The origin of this IDL file is |
michael@0 | 7 | * www.w3.org/TR/2012/WD-XMLHttpRequest-20120117/ |
michael@0 | 8 | * |
michael@0 | 9 | * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C |
michael@0 | 10 | * liability, trademark and document use rules apply. |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | interface Blob; |
michael@0 | 14 | interface InputStream; |
michael@0 | 15 | interface MozChannel; |
michael@0 | 16 | interface IID; |
michael@0 | 17 | |
michael@0 | 18 | enum XMLHttpRequestResponseType { |
michael@0 | 19 | "", |
michael@0 | 20 | "arraybuffer", |
michael@0 | 21 | "blob", |
michael@0 | 22 | "document", |
michael@0 | 23 | "json", |
michael@0 | 24 | "text", |
michael@0 | 25 | |
michael@0 | 26 | // Mozilla-specific stuff |
michael@0 | 27 | "moz-chunked-text", |
michael@0 | 28 | "moz-chunked-arraybuffer", |
michael@0 | 29 | "moz-blob" |
michael@0 | 30 | }; |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * Parameters for instantiating an XMLHttpRequest. They are passed as an |
michael@0 | 34 | * optional argument to the constructor: |
michael@0 | 35 | * |
michael@0 | 36 | * new XMLHttpRequest({anon: true, system: true}); |
michael@0 | 37 | */ |
michael@0 | 38 | dictionary MozXMLHttpRequestParameters |
michael@0 | 39 | { |
michael@0 | 40 | /** |
michael@0 | 41 | * If true, the request will be sent without cookie and authentication |
michael@0 | 42 | * headers. |
michael@0 | 43 | */ |
michael@0 | 44 | boolean mozAnon = false; |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | * If true, the same origin policy will not be enforced on the request. |
michael@0 | 48 | */ |
michael@0 | 49 | boolean mozSystem = false; |
michael@0 | 50 | }; |
michael@0 | 51 | |
michael@0 | 52 | [Constructor(optional MozXMLHttpRequestParameters params), |
michael@0 | 53 | // There are apparently callers, specifically CoffeeScript, who do |
michael@0 | 54 | // things like this: |
michael@0 | 55 | // c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP") |
michael@0 | 56 | // To handle that, we need a constructor that takes a string. |
michael@0 | 57 | Constructor(DOMString ignored)] |
michael@0 | 58 | interface XMLHttpRequest : XMLHttpRequestEventTarget { |
michael@0 | 59 | // event handler |
michael@0 | 60 | attribute EventHandler onreadystatechange; |
michael@0 | 61 | |
michael@0 | 62 | // states |
michael@0 | 63 | const unsigned short UNSENT = 0; |
michael@0 | 64 | const unsigned short OPENED = 1; |
michael@0 | 65 | const unsigned short HEADERS_RECEIVED = 2; |
michael@0 | 66 | const unsigned short LOADING = 3; |
michael@0 | 67 | const unsigned short DONE = 4; |
michael@0 | 68 | |
michael@0 | 69 | readonly attribute unsigned short readyState; |
michael@0 | 70 | |
michael@0 | 71 | // request |
michael@0 | 72 | [Throws] |
michael@0 | 73 | void open(ByteString method, DOMString url); |
michael@0 | 74 | [Throws] |
michael@0 | 75 | void open(ByteString method, DOMString url, boolean async, |
michael@0 | 76 | optional DOMString? user, optional DOMString? password); |
michael@0 | 77 | [Throws] |
michael@0 | 78 | void setRequestHeader(ByteString header, ByteString value); |
michael@0 | 79 | |
michael@0 | 80 | [SetterThrows] |
michael@0 | 81 | attribute unsigned long timeout; |
michael@0 | 82 | |
michael@0 | 83 | [SetterThrows] |
michael@0 | 84 | attribute boolean withCredentials; |
michael@0 | 85 | |
michael@0 | 86 | [Throws=Workers] |
michael@0 | 87 | readonly attribute XMLHttpRequestUpload upload; |
michael@0 | 88 | |
michael@0 | 89 | [Throws] |
michael@0 | 90 | void send(); |
michael@0 | 91 | [Throws] |
michael@0 | 92 | void send(ArrayBuffer data); |
michael@0 | 93 | [Throws] |
michael@0 | 94 | void send(ArrayBufferView data); |
michael@0 | 95 | [Throws] |
michael@0 | 96 | void send(Blob data); |
michael@0 | 97 | [Throws] |
michael@0 | 98 | void send(Document data); |
michael@0 | 99 | [Throws] |
michael@0 | 100 | void send(DOMString? data); |
michael@0 | 101 | [Throws] |
michael@0 | 102 | void send(FormData data); |
michael@0 | 103 | [Throws] |
michael@0 | 104 | void send(InputStream data); |
michael@0 | 105 | |
michael@0 | 106 | [Throws=Workers] |
michael@0 | 107 | void abort(); |
michael@0 | 108 | |
michael@0 | 109 | // response |
michael@0 | 110 | [Throws=Workers] |
michael@0 | 111 | readonly attribute unsigned short status; |
michael@0 | 112 | |
michael@0 | 113 | readonly attribute ByteString statusText; |
michael@0 | 114 | [Throws] |
michael@0 | 115 | ByteString? getResponseHeader(ByteString header); |
michael@0 | 116 | |
michael@0 | 117 | [Throws=Workers] |
michael@0 | 118 | ByteString getAllResponseHeaders(); |
michael@0 | 119 | |
michael@0 | 120 | [Throws=Workers] |
michael@0 | 121 | void overrideMimeType(DOMString mime); |
michael@0 | 122 | |
michael@0 | 123 | [SetterThrows] |
michael@0 | 124 | attribute XMLHttpRequestResponseType responseType; |
michael@0 | 125 | [Throws] |
michael@0 | 126 | readonly attribute any response; |
michael@0 | 127 | [Throws] |
michael@0 | 128 | readonly attribute DOMString? responseText; |
michael@0 | 129 | |
michael@0 | 130 | [Throws=MainThread] |
michael@0 | 131 | readonly attribute Document? responseXML; |
michael@0 | 132 | |
michael@0 | 133 | // Mozilla-specific stuff |
michael@0 | 134 | |
michael@0 | 135 | [SetterThrows=Workers] |
michael@0 | 136 | attribute boolean mozBackgroundRequest; |
michael@0 | 137 | |
michael@0 | 138 | [ChromeOnly] |
michael@0 | 139 | readonly attribute MozChannel? channel; |
michael@0 | 140 | |
michael@0 | 141 | [Throws] |
michael@0 | 142 | void sendAsBinary(DOMString body); |
michael@0 | 143 | [Throws, ChromeOnly] |
michael@0 | 144 | any getInterface(IID iid); |
michael@0 | 145 | |
michael@0 | 146 | readonly attribute boolean mozAnon; |
michael@0 | 147 | readonly attribute boolean mozSystem; |
michael@0 | 148 | }; |