blob: 56ba5523e318ba6419e3b7fbbf75313561a873f6 [file] [log] [blame]
Ms2ger33d43652013-04-04 11:45:181<!doctype html>
2<meta charset=utf-8>
3<title>XMLHttpRequest IDL tests</title>
4<script src=/resources/testharness.js></script>
5<script src=/resources/testharnessreport.js></script>
6<script src=/resources/WebIDLParser.js></script>
7<script src=/resources/idlharness.js></script>
8
9<h1>XMLHttpRequest IDL tests</h1>
10<div id=log></div>
11
12<script type=text/plain class=untested>
Ms2ger33d43652013-04-04 11:45:1813[TreatNonCallableAsNull]
14callback EventHandlerNonNull = any (Event event);
15typedef EventHandlerNonNull? EventHandler;
16</script>
17<script type=text/plain>
Boris Zbarsky18fffac2015-02-10 20:42:3518/*[Exposed=(Window,Worker)]*/
Ms2ger33d43652013-04-04 11:45:1819interface XMLHttpRequestEventTarget : EventTarget {
20 // event handlers
21 attribute EventHandler onloadstart;
22 attribute EventHandler onprogress;
23 attribute EventHandler onabort;
24 attribute EventHandler onerror;
25 attribute EventHandler onload;
26 attribute EventHandler ontimeout;
27 attribute EventHandler onloadend;
28};
29
Ms2ger9fa75202014-11-09 10:37:0030/*[Exposed=(Window,Worker)]*/
Ms2ger33d43652013-04-04 11:45:1831interface XMLHttpRequestUpload : XMLHttpRequestEventTarget {
32};
33
34enum XMLHttpRequestResponseType {
35 "",
36 "arraybuffer",
37 "blob",
38 "document",
39 "json",
40 "text"
41};
42
Ms2ger9fa75202014-11-09 10:37:0043[Constructor/*,
44 Exposed=(Window,Worker)*/]
Ms2ger33d43652013-04-04 11:45:1845interface XMLHttpRequest : XMLHttpRequestEventTarget {
46 // event handler
47 attribute EventHandler onreadystatechange;
48
49 // states
50 const unsigned short UNSENT = 0;
51 const unsigned short OPENED = 1;
52 const unsigned short HEADERS_RECEIVED = 2;
53 const unsigned short LOADING = 3;
54 const unsigned short DONE = 4;
55 readonly attribute unsigned short readyState;
56
57 // request
Ms2ger9fa75202014-11-09 10:37:0058 void open(ByteString method, USVString url);
59 void open(ByteString method, USVString url, boolean async, optional USVString? username = null, optional USVString? password = null);
Ms2ger33d43652013-04-04 11:45:1860 void setRequestHeader(ByteString name, ByteString value);
61 attribute unsigned long timeout;
62 attribute boolean withCredentials;
63 readonly attribute XMLHttpRequestUpload upload;
Ms2ger9fa75202014-11-09 10:37:0064 void send(optional (Document or BodyInit)? body = null);
Ms2ger33d43652013-04-04 11:45:1865 void abort();
66
67 // response
Ms2ger9fa75202014-11-09 10:37:0068 readonly attribute USVString responseURL;
Ms2ger33d43652013-04-04 11:45:1869 readonly attribute unsigned short status;
70 readonly attribute ByteString statusText;
71 ByteString? getResponseHeader(ByteString name);
72 ByteString getAllResponseHeaders();
73 void overrideMimeType(DOMString mime);
74 attribute XMLHttpRequestResponseType responseType;
75 readonly attribute any response;
Ms2ger9fa75202014-11-09 10:37:0076 readonly attribute USVString responseText;
77 [Exposed=Window] readonly attribute Document? responseXML;
Ms2ger33d43652013-04-04 11:45:1878};
79
Ms2ger9fa75202014-11-09 10:37:0080typedef (File or USVString) FormDataEntryValue;
81
82[Constructor(optional HTMLFormElement form)/*,
83 Exposed=(Window,Worker)*/]
Ms2ger33d43652013-04-04 11:45:1884interface FormData {
Ms2ger9fa75202014-11-09 10:37:0085 void append(USVString name, Blob value, optional USVString filename);
86 void append(USVString name, USVString value);
87 void delete(USVString name);
88 FormDataEntryValue? get(USVString name);
89 sequence<FormDataEntryValue> getAll(USVString name);
90 boolean has(USVString name);
91 void set(USVString name, Blob value, optional USVString filename);
92 void set(USVString name, USVString value);
93 /*iterable<USVString, FormDataEntryValue>;*/
94};
95
96[Constructor(DOMString type, optional ProgressEventInit eventInitDict)/*,
97 Exposed=(Window,Worker)*/]
98interface ProgressEvent : Event {
99 readonly attribute boolean lengthComputable;
100 readonly attribute unsigned long long loaded;
101 readonly attribute unsigned long long total;
102};
103
104dictionary ProgressEventInit : EventInit {
105 boolean lengthComputable = false;
106 unsigned long long loaded = 0;
107 unsigned long long total = 0;
Ms2ger33d43652013-04-04 11:45:18108};
109</script>
110<script>
111"use strict";
Aryeh Gregordb40b1e2017-04-24 15:00:33112var form = document.createElement("form");
113var idlArray = new IdlArray();
114
115function doTest(domIdl) {
116 idlArray.add_untested_idls(domIdl);
Ms2ger33d43652013-04-04 11:45:18117 [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
118 if (node.className == "untested") {
119 idlArray.add_untested_idls(node.textContent);
120 } else {
121 idlArray.add_idls(node.textContent);
122 }
123 });
124 idlArray.add_objects({
125 XMLHttpRequest: ['new XMLHttpRequest()'],
126 XMLHttpRequestUpload: ['(new XMLHttpRequest()).upload'],
127 FormData: ['new FormData()', 'new FormData(form)']
128 });
Aryeh Gregordb40b1e2017-04-24 15:00:33129 idlArray.test();
130}
131
132promise_test(function() {
133 return fetch("/interfaces/dom.idl").then(response => response.text())
134 .then(doTest);
135}, "Test driver");
Ms2ger33d43652013-04-04 11:45:18136</script>