https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 100fc93516d33821fc0ba3087614329e24a9b360 authored by James Graham on 17 April 2014, 12:28:31 UTC
Improve cleanup for websockets unload tests
Tip revision: 100fc93
responsetype.html
<!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>
back to top