https://github.com/web-platform-tests/wpt
Raw File
Tip revision: e46d835e8e757a910dadc70f4f6e6b581fac2af4 authored by James Graham on 16 October 2013, 16:59:22 UTC
Add rewriten path for web idl parser
Tip revision: e46d835
data-uri-basic.htm
<!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/li[2] following::ul/li[3] following::ul/li[4] following::ul/li[5]" />
<link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-send()-method" data-tested-assertations="following::ul/li[10]/dl/dt[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 responseText base64", 'GET', "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D", 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 statusText", 'GET', "data:text/plain,Hello, World!", function (client) {
    assert_equals(client.statusText, "OK");
  });
  do_test("GET Content-Type", 'GET', "data:text/plain,Hello, World!", function (client) {
    assert_equals(client.getResponseHeader('Content-Type'), 'text/plain');
  });
  do_test("GET Content-Type with param", 'GET', "data:text/html;charset=utf-8,<p>Hello, World!", function (client) {
    assert_equals(client.getResponseHeader('Content-Type'), 'text/html;charset=utf-8');
  });
  do_test("GET getAllResponseHeaders", 'GET', "data:text/plain,Hello, World!", function (client) {
    assert_equals(client.getAllResponseHeaders(), '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>
back to top