Title: [156103] trunk/LayoutTests
Revision
156103
Author
[email protected]
Date
2013-09-19 10:57:24 -0700 (Thu, 19 Sep 2013)

Log Message

Add XHR tests checking readyState transition when abort() is invoked in various states
https://bugs.webkit.org/show_bug.cgi?id=121585

Reviewed by Alexey Proskuryakov.

Merge https://chromium.googlesource.com/chromium/blink/+/2d854757576db590745cfb78e11ca428a1aac342

* http/tests/xmlhttprequest/readystatechange-and-abort-expected.txt: Added.
* http/tests/xmlhttprequest/readystatechange-and-abort.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (156102 => 156103)


--- trunk/LayoutTests/ChangeLog	2013-09-19 17:52:38 UTC (rev 156102)
+++ trunk/LayoutTests/ChangeLog	2013-09-19 17:57:24 UTC (rev 156103)
@@ -1,3 +1,15 @@
+2013-09-19  Ryosuke Niwa  <[email protected]>
+
+        Add XHR tests checking readyState transition when abort() is invoked in various states
+        https://bugs.webkit.org/show_bug.cgi?id=121585
+
+        Reviewed by Alexey Proskuryakov.
+
+        Merge https://chromium.googlesource.com/chromium/blink/+/2d854757576db590745cfb78e11ca428a1aac342
+
+        * http/tests/xmlhttprequest/readystatechange-and-abort-expected.txt: Added.
+        * http/tests/xmlhttprequest/readystatechange-and-abort.html: Added.
+
 2013-09-19  Manuel Rego Casasnovas  <[email protected]>
 
         Unreviewed. Fix typo in layout test description introduced in r155974.

Added: trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort-expected.txt (0 => 156103)


--- trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort-expected.txt	2013-09-19 17:57:24 UTC (rev 156103)
@@ -0,0 +1,8 @@
+
+PASS Test onreadystatechange invocation when abort()-ed in UNSENT state. 
+PASS Test onreadystatechange invocation when abort()-ed in OPENED state. 
+PASS Test onreadystatechange invocation when abort()-ed right after calling send(). 
+PASS Test onreadystatechange invocation when abort()-ed in HEADERS_RECEIVED state. 
+PASS Test onreadystatechange invocation when abort()-ed in LOADING state. 
+PASS Test onreadystatechange invocation when abort()-ed in DONE state. 
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort.html (0 => 156103)


--- trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort.html	2013-09-19 17:57:24 UTC (rev 156103)
@@ -0,0 +1,164 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<script type="text/_javascript_">
+test(function()
+{
+    var xhr = new XMLHttpRequest;
+    xhr._onreadystatechange_ = this.step_func(function() {
+        assert_unreached("Received readystatechange event unexpectedly: readyState=" + xhr.readyState)
+    });
+    xhr.abort();
+    assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abort() call");
+}, "Test onreadystatechange invocation when abort()-ed in UNSENT state.");
+
+test(function()
+{
+    var xhr = new XMLHttpRequest;
+    var seenStates = [];
+    xhr._onreadystatechange_ = this.step_func(function() {
+        seenStates.push(xhr.readyState);
+
+        switch (xhr.readyState) {
+        case xhr.OPENED:
+            return;
+
+        case xhr.UNSENT:
+        case xhr.HEADERS_RECEIVED:
+        case xhr.LOADING:
+        case xhr.DONE:
+        default:
+            assert_unreached("Unexpected readyState: " + xhr.readyState);
+            return;
+        }
+    });
+    xhr.open("GET", "resources/test.ogv", true);
+    xhr.abort();
+    assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abort() call");
+    assert_array_equals(seenStates, [xhr.OPENED]);
+}, "Test onreadystatechange invocation when abort()-ed in OPENED state.");
+
+test(function()
+{
+    var xhr = new XMLHttpRequest;
+    var seenStates = [];
+    xhr._onreadystatechange_ = this.step_func(function() {
+        seenStates.push(xhr.readyState);
+
+        switch (xhr.readyState) {
+        case xhr.OPENED:
+        case xhr.DONE:
+            return;
+
+        case xhr.UNSENT:
+        case xhr.HEADERS_RECEIVED:
+        case xhr.LOADING:
+        default:
+            assert_unreached("Unexpected readyState: " + xhr.readyState);
+            return;
+        }
+    });
+    xhr.open("GET", "resources/test.ogv", true);
+    xhr.send();
+    xhr.abort();
+    assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abort() call");
+    assert_array_equals(seenStates, [xhr.OPENED, xhr.DONE]);
+}, "Test onreadystatechange invocation when abort()-ed right after calling send().");
+
+var abortInHeadersReceivedTest = async_test("Test onreadystatechange invocation when abort()-ed in HEADERS_RECEIVED state.");
+abortInHeadersReceivedTest.step(function()
+{
+    var xhr = new XMLHttpRequest;
+    var seenStates = [];
+    xhr._onreadystatechange_ = abortInHeadersReceivedTest.step_func(function() {
+        seenStates.push(xhr.readyState);
+
+        switch (xhr.readyState) {
+        case xhr.OPENED:
+        case xhr.DONE:
+            return;
+
+        case xhr.HEADERS_RECEIVED:
+            xhr.abort();
+            assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abort() call");
+            assert_array_equals(seenStates, [xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.DONE]);
+            abortInHeadersReceivedTest.done();
+            return;
+
+        case xhr.UNSENT:
+        case xhr.LOADING:
+        default:
+            assert_unreached("Unexpected readyState: " + xhr.readyState)
+            return;
+        }
+    });
+    xhr.open("GET", "resources/test.ogv", true);
+    xhr.send();
+});
+
+var abortInLoadingTest = async_test("Test onreadystatechange invocation when abort()-ed in LOADING state.");
+abortInLoadingTest.step(function()
+{
+    var xhr = new XMLHttpRequest;
+    var seenStates = [];
+    xhr._onreadystatechange_ = abortInLoadingTest.step_func(function() {
+        seenStates.push(xhr.readyState);
+
+        switch (xhr.readyState) {
+        case xhr.OPENED:
+        case xhr.HEADERS_RECEIVED:
+        case xhr.DONE:
+            return;
+
+        case xhr.LOADING:
+            xhr.abort();
+            assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abort() call");
+            assert_array_equals(seenStates, [xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.LOADING, xhr.DONE]);
+            abortInLoadingTest.done();
+            return;
+
+        case xhr.UNSENT:
+        default:
+            assert_unreached("Unexpected readyState: " + xhr.readyState)
+            return;
+        }
+    });
+    xhr.open("GET", "resources/test.ogv", true);
+    xhr.send();
+});
+
+var abortInDoneTest = async_test("Test onreadystatechange invocation when abort()-ed in DONE state.");
+abortInDoneTest.step(function()
+{
+    var xhr = new XMLHttpRequest;
+    var seenStates = [];
+    xhr._onreadystatechange_ = abortInDoneTest.step_func(function() {
+        seenStates.push(xhr.readyState);
+
+        switch (xhr.readyState) {
+        case xhr.OPENED:
+        case xhr.HEADERS_RECEIVED:
+        case xhr.LOADING:
+            return;
+
+        case xhr.DONE:
+            xhr.abort();
+            assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abort() call");
+            assert_array_equals(seenStates, [xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.LOADING, xhr.DONE]);
+            abortInDoneTest.done();
+            return;
+
+        case xhr.UNSENT:
+        default:
+            assert_unreached("Unexpected readyState: " + xhr.readyState)
+            return;
+        }
+    });
+    xhr.open("GET", "resources/test.ogv", true);
+    xhr.send();
+});
+</script>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to