1/* 2 * Copyright (C) 2008, 2011 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29enum XMLHttpRequestResponseType { 30 "", 31 "arraybuffer", 32 "blob", 33 "document", 34// FIXME: enable once support for json responseText is completed. (bug #73648) 35// "json", 36 "text" 37}; 38 39[ 40 GlobalContext=WindowAndWorker, 41 ActiveDOMObject, 42 Constructor, 43 ConstructorCallWith=ScriptExecutionContext, 44 JSCustomMarkFunction, 45 EventTarget, 46 JSNoStaticTables 47] interface XMLHttpRequest { 48 // From XMLHttpRequestEventTarget 49 // event handler attributes 50 attribute EventListener onabort; 51 attribute EventListener onerror; 52 attribute EventListener onload; 53 attribute EventListener onloadend; 54 attribute EventListener onloadstart; 55 attribute EventListener onprogress; 56 [Conditional=XHR_TIMEOUT] attribute EventListener ontimeout; 57 58 // event handler attributes 59 attribute EventListener onreadystatechange; 60 61 // state 62 const unsigned short UNSENT = 0; 63 const unsigned short OPENED = 1; 64 const unsigned short HEADERS_RECEIVED = 2; 65 const unsigned short LOADING = 3; 66 const unsigned short DONE = 4; 67 68 [Conditional=XHR_TIMEOUT, SetterRaisesException] attribute unsigned long timeout; 69 readonly attribute unsigned short readyState; 70 71 [SetterRaisesException] attribute boolean withCredentials; 72 73 [Custom, RaisesException] void open(DOMString method, DOMString url, optional boolean async, optional DOMString user, optional DOMString password); 74 75 [RaisesException] void setRequestHeader(DOMString header, DOMString value); 76 77 [Custom, RaisesException] void send(); 78 79 void abort(); 80 81 readonly attribute XMLHttpRequestUpload upload; 82 83 // response 84 [TreatReturnedNullStringAs=Undefined, RaisesException] DOMString getAllResponseHeaders(); 85 [TreatReturnedNullStringAs=Null, RaisesException] DOMString getResponseHeader(DOMString header); 86 [GetterRaisesException, CustomGetter] readonly attribute DOMString responseText; // The custom getter implements TreatReturnedNullStringAs=Null 87 [GetterRaisesException] readonly attribute Document responseXML; 88 89 [SetterRaisesException] attribute XMLHttpRequestResponseType responseType; 90 [GetterRaisesException, CustomGetter] readonly attribute Object response; 91 92 [GetterRaisesException] readonly attribute unsigned short status; 93 [GetterRaisesException] readonly attribute DOMString statusText; 94 95 // Extension 96 void overrideMimeType(DOMString override); 97 98 // EventTarget interface 99 void addEventListener(DOMString type, 100 EventListener listener, 101 optional boolean useCapture); 102 void removeEventListener(DOMString type, 103 EventListener listener, 104 optional boolean useCapture); 105 [RaisesException] boolean dispatchEvent(Event evt); 106}; 107