2007-10-27 Julien <julien.chaffraix@gmail.com>
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Oct 2007 18:51:25 +0000 (18:51 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Oct 2007 18:51:25 +0000 (18:51 +0000)
        Reviewed by Alexey.

        http://bugs.webkit.org/show_bug.cgi?id=13141
        XMLHttpRequest should set readyState to 0 after abort()

        Test: http/tests/xmlhttprequest/xmlhttprequest-abort-readyState.html

        * xml/XMLHttpRequest.cpp:
        (WebCore::XMLHttpRequest::open):
        (WebCore::XMLHttpRequest::abort):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27151 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/xmlhttprequest-html-response-encoding.html
LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/xml/XMLHttpRequest.cpp

index 3a9c527417ea89780bd4fe1e0603ac7b99e08a7f..f9c6caad2bcf4c418d0a1ade0fa778134d66ef7b 100644 (file)
@@ -1,3 +1,14 @@
+2007-10-27  Julien  <julien.chaffraix@gmail.com>
+
+        Reviewed by Alexey.
+
+        http://bugs.webkit.org/show_bug.cgi?id=13141
+        XMLHttpRequest should set readyState to 0 after abort()
+
+        * fast/dom/xmlhttprequest-html-response-encoding.html: correct malformed page
+        * http/tests/xmlhttprequest/xmlhttprequest-abord-readyState-expect.txt: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-abort-readyState.html: Added.
+
 2007-10-27  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index 7a91c40e10958cced7653684c1cd9197691f8320..4c6c92d3d076dbd0c3f66bc9b170b0870ea9904b 100644 (file)
@@ -1,6 +1,7 @@
 <html>
 <head>
 <title>Test XmlHttpRequest response encoding handling</title>
+</head>
 <body>
 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=14288">bug 14288</a>:
 XMLHttpRequest doesn't use a correct content type for file:// URLs.</p>
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState-expected.txt b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState-expected.txt
new file mode 100644 (file)
index 0000000..12e836b
--- /dev/null
@@ -0,0 +1,9 @@
+Test bug 13141 : XMLHttpRequest should set readyState to 0 after abort()
+
+Should see "PASS" four times:
+
+PASS
+PASS
+PASS
+PASS
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState.html b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState.html
new file mode 100644 (file)
index 0000000..cf4b9ba
--- /dev/null
@@ -0,0 +1,67 @@
+<html>
+<head></head>
+<body>
+
+<p>Test bug 13141 : XMLHttpRequest should set readyState to 0 after abort() </p>
+<p>Should see "PASS" four times:</p>
+<div id="ans"></div>
+
+<script type="text/javascript">
+function log(message) {
+    document.getElementById("ans").appendChild(document.createTextNode(message));
+    document.getElementById("ans").appendChild(document.createElement("br"));
+}
+
+// Used to detect if a readystate event is dispatched
+function catchReadystateEventAbort() {
+    log("FAILED (readystate event send)");
+}
+
+function test(num)
+{
+    var xhr;
+
+    if (window.XMLHttpRequest) {
+        xhr = new XMLHttpRequest();
+    } else {
+        try {
+            xhr = new ActiveXObject("Msxml2.XMLHTTP");
+        } catch (ex) {
+            xhr = new ActiveXObject("Microsoft.XMLHTTP");
+        }
+    }
+
+    xhr.onreadystatechange = function () {
+        if (this.readyState == num) {
+            ++finishedTests;
+            this.onreadystatechange = catchReadystateEventAbort;
+            this.abort();
+            if (this.readyState == 0)
+                log("PASS");
+            else
+                log("FAILED");
+        }
+        
+        if (finishedTests == 4 && window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+
+    xhr.open("GET", "resources/1251.html", true);
+    if (num != 1)
+        xhr.send(null);
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+var finishedTests = 0;
+
+for (i = 1; i < 5; i++) {
+    test(i);
+}
+
+</script>
+</body>
+</html>
index d7990fbbb1160ce9f82710e28e9beb69b680047f..05e4a394fea03fff1c6200cc9f8a5d1341b5e2f6 100644 (file)
@@ -1,3 +1,16 @@
+2007-10-27  Julien  <julien.chaffraix@gmail.com>
+
+        Reviewed by Alexey.
+
+        http://bugs.webkit.org/show_bug.cgi?id=13141
+        XMLHttpRequest should set readyState to 0 after abort()
+        
+        Test: http/tests/xmlhttprequest/xmlhttprequest-abort-readyState.html
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::open):
+        (WebCore::XMLHttpRequest::abort):
+
 2007-10-27  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index 3cb563512de9f797e701347b32e132dbe9e0d3c1..aa6e78ec343a195c22354b5b969ab128eefe67e6 100644 (file)
@@ -334,7 +334,7 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
     m_createdDocument = false;
     m_responseXML = 0;
 
-    changeState(Uninitialized);
+    ASSERT(m_state == Uninitialized);
 
     if (!urlMatchesDocumentDomain(url)) {
         ec = PERMISSION_DENIED;
@@ -478,6 +478,8 @@ void XMLHttpRequest::abort()
 
     if (hadLoader)
         dropProtection();
+
+    m_state = Uninitialized;
 }
 
 void XMLHttpRequest::dropProtection()