| <!doctype html> | |
| <meta charset=utf-8> | |
| <title>XMLHttpRequest: basic data uri</title> | |
| <script src="/resources/testharness.js"></script> | |
| <script src="/resources/testharnessreport.js"></script> | |
| <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#data:-urls-and-http" data-tested-assertations="/following::ul[1] /following::ul[2]" /> | |
| <div id="log"></div> | |
| <script> | |
| function do_test(name, method, uri, func) { | |
| var test = async_test(name); | |
| test.step(function() { | |
| var client = new XMLHttpRequest(); | |
| client.onreadystatechange = test.step_func(function () { | |
| if (client.readyState !== 4) return; | |
| func(client); | |
| test.done(); | |
| }); | |
| client.open(method, uri); | |
| client.send(null); | |
| }); | |
| } | |
| do_test("GET responseText", 'GET', "data:text/plain,Hello, World!", function (client) { | |
| assert_equals(client.responseText, "Hello, World!") | |
| }); | |
| do_test("GET status", 'GET', "data:text/plain,Hello, World!", function (client) { | |
| assert_equals(client.status, 200); | |
| }); | |
| do_test("GET Content-Type", 'GET', "data:text/plain,Hello, World!", function (client) { | |
| assert_equals(client.getResponseHeader('Content-Type'), 'text/plain'); | |
| }); | |
| do_test("POST responseText", 'POST', "data:text/plain,Hello, World!", function (client) { | |
| assert_equals(client.responseText, null); | |
| }); | |
| do_test("POST status", 'POST', "data:text/plain,Hello, World!", function (client) { | |
| assert_equals(client.status, 501); | |
| }); | |
| </script> |