Commit 7046112f authored by rniwa@webkit.org's avatar rniwa@webkit.org

Check that XMLHttpRequest.response returns null or a json object as specified...

Check that XMLHttpRequest.response returns null or a json object as specified in the spec according to readyState value.
https://bugs.webkit.org/show_bug.cgi?id=120690

Reviewed by Darin Adler.

Merge https://chromium.googlesource.com/chromium/blink/+/d667a115b0fd8f5e11a24d8db44388a990abf543

* http/tests/xmlhttprequest/resources/test.json: Added.
* http/tests/xmlhttprequest/response-json-and-readystate-expected.txt: Added.
* http/tests/xmlhttprequest/response-json-and-readystate.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155067 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dbc108bd
2013-09-04 Ryosuke Niwa <rniwa@webkit.org>
Check that XMLHttpRequest.response returns null or a json object as specified in the spec according to readyState value.
https://bugs.webkit.org/show_bug.cgi?id=120690
Reviewed by Darin Adler.
Merge https://chromium.googlesource.com/chromium/blink/+/d667a115b0fd8f5e11a24d8db44388a990abf543
* http/tests/xmlhttprequest/resources/test.json: Added.
* http/tests/xmlhttprequest/response-json-and-readystate-expected.txt: Added.
* http/tests/xmlhttprequest/response-json-and-readystate.html: Added.
2013-09-04 Csaba Osztrogonác <ossy@webkit.org>
Remove HTMLDialogElement layout tests after r154835
PASS Test response of XMLHttpRequest with responseType set to 'json' for various readyState.
<!DOCTYPE html>
<html>
<body>
<script src="../w3c/resources/testharness.js"></script>
<script src="../w3c/resources/testharnessreport.js"></script>
<script type="text/javascript">
var test = async_test("Test response of XMLHttpRequest with responseType set to 'json' for various readyState.");
test.step(function()
{
var xhr = new XMLHttpRequest;
xhr.responseType = "json";
assert_equals(xhr.responseType, "json", "xhr.responseType");
assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState");
assert_equals(xhr.response, null, "xhr.response");
var seenStates = [];
xhr.onreadystatechange = test.step_func(function() {
seenStates.push(xhr.readyState);
switch (xhr.readyState) {
case xhr.UNSENT:
assert_unreached('Unexpected readyState: UNSENT');
return;
case xhr.OPENED:
assert_equals(xhr.response, null, "xhr.response");
return;
case xhr.HEADERS_RECEIVED:
assert_equals(xhr.response, null, "xhr.response");
return;
case xhr.LOADING:
assert_equals(xhr.response, null, "xhr.response");
return;
case xhr.DONE:
assert_equals(xhr.status, 200, "xhr.status");
assert_equals(JSON.stringify(xhr.response),
'["a","b",2,{"3":3}]',
"Stringify result of xhr.response");
// Check that we saw all states.
assert_array_equals(seenStates,
[xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.LOADING, xhr.DONE]);
test.done();
return;
default:
assert_unreached('Unexpected readyState: ' + xhr.readyState)
return;
}
});
xhr.open('GET', 'resources/test.json', true);
xhr.send();
});
</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