Title: [155067] trunk/LayoutTests
Revision
155067
Author
[email protected]
Date
2013-09-04 15:01:48 -0700 (Wed, 04 Sep 2013)

Log Message

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (155066 => 155067)


--- trunk/LayoutTests/ChangeLog	2013-09-04 21:59:27 UTC (rev 155066)
+++ trunk/LayoutTests/ChangeLog	2013-09-04 22:01:48 UTC (rev 155067)
@@ -1,3 +1,16 @@
+2013-09-04  Ryosuke Niwa  <[email protected]>
+
+        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  <[email protected]>
 
         Remove HTMLDialogElement layout tests after r154835

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/test.json (0 => 155067)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/test.json	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/test.json	2013-09-04 22:01:48 UTC (rev 155067)
@@ -0,0 +1 @@
+["a","b",2,{"3":3}]

Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-json-and-readystate-expected.txt (0 => 155067)


--- trunk/LayoutTests/http/tests/xmlhttprequest/response-json-and-readystate-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-json-and-readystate-expected.txt	2013-09-04 22:01:48 UTC (rev 155067)
@@ -0,0 +1,3 @@
+
+PASS Test response of XMLHttpRequest with responseType set to 'json' for various readyState. 
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-json-and-readystate.html (0 => 155067)


--- trunk/LayoutTests/http/tests/xmlhttprequest/response-json-and-readystate.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-json-and-readystate.html	2013-09-04 22:01:48 UTC (rev 155067)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<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>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to