forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponsetype.html
42 lines (41 loc) · 1.27 KB
/
responsetype.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<meta charset="utf-8">
<title>XHR2 `responseType` property tests</title>
<meta name=viewport content="width=device-width">
<link rel="stylesheet" href="/resources/testharness.css">
<link rel="author" title="Mathias Bynens" href="http://mathiasbynens.be/">
<link rel="help" href="http://www.w3.org/TR/XMLHttpRequest/#the-responsetype-attribute">
<link rel="help" href="http://xhr.spec.whatwg.org/#the-responsetype-attribute">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Description</h1>
<p>This test validates that the XHR2 <code>reponseType</code> property is supported and accepts all the proper values.</p>
<div id="log"></div>
<script>
(function() {
function testType(type) {
if (typeof XMLHttpRequest == 'undefined') {
return false;
}
var xhr = new XMLHttpRequest();
xhr.open('get', '/', true);
try {
xhr.responseType = type;
} catch(error) {
return false;
}
return 'response' in xhr && xhr.responseType == type;
};
var types = ['', 'json', 'document', 'arraybuffer', 'blob', 'text'];
types.forEach(function(type) {
test(
function() {
assert_true(
testType(type)
);
},
'xhr.responseType = \'' + type + '\''
);
});
}());
</script>