Allow XMLHttpRequest withCredentials to be set prior to a call to open()
authorjarred@sencha.com <jarred@sencha.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Dec 2011 20:29:30 +0000 (20:29 +0000)
committerjarred@sencha.com <jarred@sencha.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Dec 2011 20:29:30 +0000 (20:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75194

Source/WebCore:

XMLHttpRequest.withCredentials attribute should be modifiable prior to the OPENED state per
the W3C spec. See http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-withcredentials-attribute

Reviewed by Alexey Proskuryakov.

Test: fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::setWithCredentials):
Prevent setting the value only after the OPENED state.

LayoutTests:

Reviewed by Alexey Proskuryakov.

* fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open-expected.txt: Added.
* fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open.html: Added.
Validate that XMLHttpRequest.withCredentials can be set prior to a call to open().

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

LayoutTests/ChangeLog
LayoutTests/fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open-expected.txt [new file with mode: 0644]
LayoutTests/fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/xml/XMLHttpRequest.cpp

index c8db576336e9d05629e212503af979dfd20f11ba..a6936fa35ca6b03f7d11bc618b0ddf3587d88e28 100644 (file)
@@ -1,3 +1,14 @@
+2011-12-24  Jarred Nicholls  <jarred@sencha.com>
+
+        Allow XMLHttpRequest withCredentials to be set prior to a call to open()
+        https://bugs.webkit.org/show_bug.cgi?id=75194
+
+        Reviewed by Alexey Proskuryakov.
+
+        * fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open-expected.txt: Added.
+        * fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open.html: Added.
+        Validate that XMLHttpRequest.withCredentials can be set prior to a call to open().
+
 2011-12-24  Ryosuke Niwa  <rniwa@webkit.org>
 
         Chromium CG Mac rebaseline after r103651.
diff --git a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open-expected.txt b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open-expected.txt
new file mode 100644 (file)
index 0000000..5a1dc33
--- /dev/null
@@ -0,0 +1,12 @@
+This tests that the XMLHttpRequest withCredentials attribute is modifiable prior to being in the OPENED state.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+xhr.withCredentials = true;
+xhr.open('GET', 'http://mydomain');
+PASS xhr.withCredentials is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open.html b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open.html
new file mode 100644 (file)
index 0000000..f3c7b9e
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../js/resources/js-test-pre.js"></script>
+    <script>
+        description('This tests that the XMLHttpRequest withCredentials attribute is modifiable prior to being in the OPENED state.');
+        var xhr;
+
+        xhr = new XMLHttpRequest();
+        evalAndLog("xhr.withCredentials = true;");
+        evalAndLog("xhr.open('GET', 'http://mydomain');");
+        shouldBeTrue('xhr.withCredentials');
+    </script>
+    <script src="../js/resources/js-test-post.js"></script>
+</head>
+<body>
+    <div id="description"></div>
+    <div id="console"></div>
+</body>
+</html>
index e9da4bece4ef885cf99b91350bc43a1ac789f99a..f74859b34fc2aef52980882cba11a7b29e62c78c 100644 (file)
@@ -1,3 +1,19 @@
+2011-12-24  Jarred Nicholls  <jarred@sencha.com>
+
+        Allow XMLHttpRequest withCredentials to be set prior to a call to open()
+        https://bugs.webkit.org/show_bug.cgi?id=75194
+
+        XMLHttpRequest.withCredentials attribute should be modifiable prior to the OPENED state per
+        the W3C spec. See http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-withcredentials-attribute
+
+        Reviewed by Alexey Proskuryakov.
+
+        Test: fast/xmlhttprequest/xmlhttprequest-withcredentials-before-open.html
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::setWithCredentials):
+        Prevent setting the value only after the OPENED state.
+
 2011-12-24  Andreas Kling  <awesomekling@apple.com>
 
         Remove empty inline RenderStyle destructor.
index 27b4191011d73aae5c5fefe2d9e87608a4d2b3db..21503fa97c97dd90fb87f26c34dab25cce6adf9b 100644 (file)
@@ -377,7 +377,7 @@ void XMLHttpRequest::callReadyStateChangeListener()
 
 void XMLHttpRequest::setWithCredentials(bool value, ExceptionCode& ec)
 {
-    if (m_state != OPENED || m_loader) {
+    if (m_state > OPENED || m_loader) {
         ec = INVALID_STATE_ERR;
         return;
     }