Commit 7ff93d98 authored by Takeshi Yoshino's avatar Takeshi Yoshino Committed by Commit Bot

Pass the test function to async_test() directly in a XHR layout test

Bug: 
Change-Id: Ib3b20abc3e21e02bca2aa597342ad9907c1b23aa
Reviewed-on: https://chromium-review.googlesource.com/571252Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Takeshi Yoshino <tyoshino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486722}
parent b9fc0761
<html>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
......@@ -7,12 +5,11 @@
// scheme and then the access to data: resources are handled as same origin
// access.
var test = async_test("Test parsing a data URL. US-ASCII into DOMString");
test.step(function() {
async_test(t => {
var xhr = new XMLHttpRequest;
xhr.responseType = 'text';
xhr.open('GET', 'data:text/html,Foobar', true);
xhr.onreadystatechange = test.step_func(function() {
xhr.onreadystatechange = t.step_func(function() {
if (xhr.readyState != xhr.DONE)
return;
......@@ -21,17 +18,16 @@ test.step(function() {
assert_equals(xhr.getAllResponseHeaders(), 'content-type: text/html\r\n', 'getAllResponseheaders()');
assert_equals(xhr.response, 'Foobar', 'response');
test.done();
t.done();
});
xhr.send();
});
}, "Test parsing a data URL. US-ASCII into DOMString");
var testArrayBuffer = async_test("Test parsing a data URL. Binary into ArrayBuffer");
testArrayBuffer.step(function() {
async_test(t => {
var xhr = new XMLHttpRequest;
xhr.responseType = 'arraybuffer';
xhr.open('GET', 'data:text/html;base64,AAEC/w%3D%3D', true);
xhr.onreadystatechange = testArrayBuffer.step_func(function() {
xhr.onreadystatechange = t.step_func(function() {
if (xhr.readyState != xhr.DONE)
return;
......@@ -43,17 +39,16 @@ testArrayBuffer.step(function() {
assert_equals(view[2], 0x02, 'view[2]')
assert_equals(view[3], 0xff, 'view[3]')
testArrayBuffer.done();
t.done();
});
xhr.send();
});
}, "Test parsing a data URL. Binary into ArrayBuffer");
var testUtf8 = async_test("Test parsing a data URL. UTF-8 data into DOMString.");
testUtf8.step(function() {
async_test(t => {
var xhr = new XMLHttpRequest;
xhr.responseType = 'text';
xhr.open('GET', 'data:text/html;charset=utf-8;base64,5paH5a2X', true);
xhr.onreadystatechange = testUtf8.step_func(function() {
xhr.onreadystatechange = t.step_func(function() {
if (xhr.readyState != xhr.DONE)
return;
......@@ -61,43 +56,39 @@ testUtf8.step(function() {
assert_equals(xhr.getAllResponseHeaders(), 'content-type: text/html;charset=utf-8\r\n', 'getAllResponseheaders()');
assert_equals(xhr.response, '\u6587\u5b57', 'response');
testUtf8.done();
t.done();
});
xhr.send();
});
}, "Test parsing a data URL. UTF-8 data into DOMString.");
var testUtf8Blob = async_test("Test parsing a data URL. UTF-8 data into Blob.");
testUtf8Blob.step(function() {
async_test(t => {
var xhr = new XMLHttpRequest;
xhr.responseType = 'blob';
xhr.open('GET', 'data:text/html;charset=utf-8;base64,5paH5a2X', true);
xhr.onreadystatechange = testUtf8Blob.step_func(function() {
xhr.onreadystatechange = t.step_func(function() {
if (xhr.readyState != xhr.DONE)
return;
assert_equals(xhr.status, 0, 'status');
assert_equals(xhr.response, null, 'response');
testUtf8Blob.done();
t.done();
});
xhr.send();
});
}, "Test parsing a data URL. UTF-8 data into Blob.");
var testBad = async_test("Test parsing a data URL. Invalid Base64 data.");
testBad.step(function() {
async_test(t => {
var xhr = new XMLHttpRequest;
xhr.responseType = 'text';
xhr.open('GET', 'data:text/html;base64,***', true);
xhr.onreadystatechange = testBad.step_func(function() {
xhr.onreadystatechange = t.step_func(function() {
if (xhr.readyState != xhr.DONE)
return;
assert_not_equals(xhr.status, 200, 'status');
testBad.done();
t.done();
});
xhr.send();
});
}, "Test parsing a data URL. Invalid Base64 data.");
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment