| <!doctype html> |
| <meta charset=utf-8> |
| <title>XMLHttpRequest IDL tests</title> |
| <script src=/resources/testharness.js></script> |
| <script src=/resources/testharnessreport.js></script> |
| <script src=/resources/WebIDLParser.js></script> |
| <script src=/resources/idlharness.js></script> |
| |
| <h1>XMLHttpRequest IDL tests</h1> |
| <div id=log></div> |
| |
| <script type=text/plain class=untested> |
| [Constructor(DOMString type, optional EventInit eventInitDict)/*, |
| Exposed=(Window,Worker)*/] |
| interface Event { |
| readonly attribute DOMString type; |
| readonly attribute EventTarget? target; |
| readonly attribute EventTarget? currentTarget; |
| |
| const unsigned short NONE = 0; |
| const unsigned short CAPTURING_PHASE = 1; |
| const unsigned short AT_TARGET = 2; |
| const unsigned short BUBBLING_PHASE = 3; |
| readonly attribute unsigned short eventPhase; |
| |
| void stopPropagation(); |
| void stopImmediatePropagation(); |
| |
| readonly attribute boolean bubbles; |
| readonly attribute boolean cancelable; |
| void preventDefault(); |
| readonly attribute boolean defaultPrevented; |
| |
| [Unforgeable] readonly attribute boolean isTrusted; |
| readonly attribute DOMTimeStamp timeStamp; |
| |
| void initEvent(DOMString type, boolean bubbles, boolean cancelable); |
| }; |
| |
| dictionary EventInit { |
| boolean bubbles = false; |
| boolean cancelable = false; |
| }; |
| |
| /*[Exposed=(Window,Worker)]*/ |
| interface EventTarget { |
| void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false); |
| void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false); |
| boolean dispatchEvent(Event event); |
| }; |
| </script> |
| <script type=text/plain class=untested> |
| [TreatNonCallableAsNull] |
| callback EventHandlerNonNull = any (Event event); |
| typedef EventHandlerNonNull? EventHandler; |
| </script> |
| <script type=text/plain> |
| /*[Exposed=(Window,Worker)]*/ |
| interface XMLHttpRequestEventTarget : EventTarget { |
| // event handlers |
| attribute EventHandler onloadstart; |
| attribute EventHandler onprogress; |
| attribute EventHandler onabort; |
| attribute EventHandler onerror; |
| attribute EventHandler onload; |
| attribute EventHandler ontimeout; |
| attribute EventHandler onloadend; |
| }; |
| |
| /*[Exposed=(Window,Worker)]*/ |
| interface XMLHttpRequestUpload : XMLHttpRequestEventTarget { |
| }; |
| |
| enum XMLHttpRequestResponseType { |
| "", |
| "arraybuffer", |
| "blob", |
| "document", |
| "json", |
| "text" |
| }; |
| |
| [Constructor/*, |
| Exposed=(Window,Worker)*/] |
| interface XMLHttpRequest : XMLHttpRequestEventTarget { |
| // event handler |
| attribute EventHandler onreadystatechange; |
| |
| // states |
| const unsigned short UNSENT = 0; |
| const unsigned short OPENED = 1; |
| const unsigned short HEADERS_RECEIVED = 2; |
| const unsigned short LOADING = 3; |
| const unsigned short DONE = 4; |
| readonly attribute unsigned short readyState; |
| |
| // request |
| void open(ByteString method, USVString url); |
| void open(ByteString method, USVString url, boolean async, optional USVString? username = null, optional USVString? password = null); |
| void setRequestHeader(ByteString name, ByteString value); |
| attribute unsigned long timeout; |
| attribute boolean withCredentials; |
| readonly attribute XMLHttpRequestUpload upload; |
| void send(optional (Document or BodyInit)? body = null); |
| void abort(); |
| |
| // response |
| readonly attribute USVString responseURL; |
| readonly attribute unsigned short status; |
| readonly attribute ByteString statusText; |
| ByteString? getResponseHeader(ByteString name); |
| ByteString getAllResponseHeaders(); |
| void overrideMimeType(DOMString mime); |
| attribute XMLHttpRequestResponseType responseType; |
| readonly attribute any response; |
| readonly attribute USVString responseText; |
| [Exposed=Window] readonly attribute Document? responseXML; |
| }; |
| |
| typedef (File or USVString) FormDataEntryValue; |
| |
| [Constructor(optional HTMLFormElement form)/*, |
| Exposed=(Window,Worker)*/] |
| interface FormData { |
| void append(USVString name, Blob value, optional USVString filename); |
| void append(USVString name, USVString value); |
| void delete(USVString name); |
| FormDataEntryValue? get(USVString name); |
| sequence<FormDataEntryValue> getAll(USVString name); |
| boolean has(USVString name); |
| void set(USVString name, Blob value, optional USVString filename); |
| void set(USVString name, USVString value); |
| /*iterable<USVString, FormDataEntryValue>;*/ |
| }; |
| |
| [Constructor(DOMString type, optional ProgressEventInit eventInitDict)/*, |
| Exposed=(Window,Worker)*/] |
| interface ProgressEvent : Event { |
| readonly attribute boolean lengthComputable; |
| readonly attribute unsigned long long loaded; |
| readonly attribute unsigned long long total; |
| }; |
| |
| dictionary ProgressEventInit : EventInit { |
| boolean lengthComputable = false; |
| unsigned long long loaded = 0; |
| unsigned long long total = 0; |
| }; |
| </script> |
| <script> |
| "use strict"; |
| var form; |
| var idlArray; |
| setup(function() { |
| form = document.createElement("form"); |
| idlArray = new IdlArray(); |
| [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) { |
| if (node.className == "untested") { |
| idlArray.add_untested_idls(node.textContent); |
| } else { |
| idlArray.add_idls(node.textContent); |
| } |
| }); |
| idlArray.add_objects({ |
| XMLHttpRequest: ['new XMLHttpRequest()'], |
| XMLHttpRequestUpload: ['(new XMLHttpRequest()).upload'], |
| FormData: ['new FormData()', 'new FormData(form)'] |
| }); |
| }); |
| idlArray.test(); |
| </script> |