Skip to content

Commit

Permalink
merging data: test files, fixing some wrong pass conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hallvord R. M. Steen committed Sep 10, 2014
1 parent 58df0e3 commit be18bc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 58 deletions.
55 changes: 0 additions & 55 deletions XMLHttpRequest/data-uri-basic.htm

This file was deleted.

11 changes: 8 additions & 3 deletions XMLHttpRequest/data-uri.htm
Expand Up @@ -8,9 +8,9 @@
<div id="log"></div>

<script>
function do_test(method, uri, charset, namePostfix) {
function do_test(method, uri, charset, testNamePostfix) {
if (typeof charset === 'undefined' || charset === null) charset = 'text/plain';
var test = async_test("XHR method " + method + " with charset " + charset+(namePostfix||''));
var test = async_test("XHR method " + method + " with charset " + charset+(testNamePostfix||''));
test.step(function() {
var client = new XMLHttpRequest();
client.onreadystatechange = test.step_func(function () {
Expand All @@ -22,14 +22,18 @@
// error per <http://fetch.spec.whatwg.org/#basic-fetch>.
if (method.toUpperCase() !== 'GET') {
assert_equals(client.status, 0);
assert_equals(client.responseText, null);
assert_equals(client.responseText, '');
assert_equals(client.statusText, 'OK');
test.done();
return;
}

assert_equals(client.responseText, "Hello, World!");
assert_equals(client.status, 200);
assert_equals(client.getResponseHeader('Content-Type'), charset);
var allHeaders = client.getAllResponseHeaders();
assert_regexp_match(allHeaders, /content\-type\:/i, 'getAllResponseHeaders() includes Content-Type');
assert_regexp_match(allHeaders, /content\-length\:/i, 'getAllResponseHeaders() includes Content-Length');
test.done();
});
client.open(method, uri);
Expand All @@ -39,6 +43,7 @@
do_test('GET', "data:text/plain,Hello, World!");
do_test('GET', "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==", undefined, " (base64)");
do_test('GET', "data:text/html,Hello, World!", 'text/html');
do_test('GET', "data:text/html;charset=UTF-8,Hello, World!", 'text/html;charset=UTF-8');
do_test('GET', "data:image/png,Hello, World!", 'image/png');
do_test('POST', "data:text/plain,Hello, World!");
do_test('PUT', "data:text/plain,Hello, World!");
Expand Down

0 comments on commit be18bc2

Please sign in to comment.