[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

ap at apple.com ap at apple.com
Wed Dec 22 11:19:43 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 532e5a1a04a2a015f69f9b7d322fe827190f146c
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jul 19 18:46:08 2010 +0000

            Reviewed by Darin Adler.
    
            https://bugs.webkit.org/show_bug.cgi?id=40996
            Progress event should not be fired during synchronous XMLHttpRequest
    
            https://bugs.webkit.org/show_bug.cgi?id=17502
            Assertion failure when trying to restart a sync XMLHttpRequest as an async one from onreadystatechange
    
            Tests: http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events.html
                   http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html
    
            * xml/XMLHttpRequest.cpp:
            (WebCore::XMLHttpRequest::callReadyStateChangeListener): We now only dispatch readystatechange
            event for synchronous requests in states UNSENT, OPENED and DONE. I'm not sure what exactly
            the spec draft says about readystatechange for sync requests, but this seems to be the most
            logical and backwards compatible behavior.
            (WebCore::XMLHttpRequest::didReceiveData): Don't dispatch progress events for sync requests.
            Note that we already don't dispatch upload progress events for those.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63680 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e48f723..df85a32 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,37 @@
+2010-07-19  Alexey Proskuryakov  <ap at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=40996
+        Progress event should not be fired during synchronous XMLHttpRequest
+
+        https://bugs.webkit.org/show_bug.cgi?id=17502
+        Assertion failure when trying to restart a sync XMLHttpRequest as an async one from onreadystatechange
+
+        * fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt: There is one less
+        event dispatched now.
+
+        * http/tests/xmlhttprequest/infoOnProgressEvent-expected.txt:
+        * http/tests/xmlhttprequest/infoOnProgressEvent.html:
+        * http/tests/xmlhttprequest/xmlhttprequest-no-content-length-onProgress.html:
+        Changed to use async requests, since sync ones no longer cause progress event dispatch.
+
+        * http/tests/xmlhttprequest/resources/access-control-basic-post-fail-non-simple.cgi: Added.
+        A script that only allows simple cross-origin requests.
+
+        * http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress-expected.txt:
+        * http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress.html:
+        Removed synchronous case (incorrectly called asynchronous in test comments).
+
+        * http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events.html: Added.
+        Added a test that logs progress and readystatechange events.
+
+        * http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure-expected.txt: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html: Added.
+        Aded a test for assertion failure. The problem no longer occurs since we don't fire events
+        in intermediate states.
+
 2010-07-19  Csaba Osztrogonác  <ossy at webkit.org>
 
         Unreviewed.
diff --git a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt
index 2811673..8cc27c0 100644
--- a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt
+++ b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt
@@ -1,6 +1,5 @@
 CONSOLE MESSAGE: line 0: 
 CONSOLE MESSAGE: line 0: 
-CONSOLE MESSAGE: line 0: 
 This tests that having infinite recursion in XMLHttpRequest event handler does not crash. 
 PASS
 
diff --git a/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent-expected.txt b/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent-expected.txt
index 0084597..e689f8b 100644
--- a/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent-expected.txt
+++ b/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent-expected.txt
@@ -1,16 +1,7 @@
 Test case for bug 13596: Implement .onprogress handler on XMLHttpRequest objects to support progressive download content length information
 
-You should see type, bubble, cancelable, eventPhase, target and current target for synchronous and asynchronous cases
+You should see type, bubble, cancelable, eventPhase, target and current target.
 
-Synchronous case:
-Type: progress
-Bubble: false
-Cancelable: true
-EventPhase: 2
-Target: [object XMLHttpRequest]
-Current target: [object XMLHttpRequest]
-
-Asynchronous case:
 Type: progress
 Bubble: false
 Cancelable: true
diff --git a/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent.html b/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent.html
index 680d48e..f284ce3 100644
--- a/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent.html
+++ b/LayoutTests/http/tests/xmlhttprequest/infoOnProgressEvent.html
@@ -2,7 +2,7 @@
 <head/>
 <body>
 <p> Test case for bug 13596: Implement .onprogress handler on XMLHttpRequest objects to support progressive download content length information </p>
-<p> You should see type, bubble, cancelable, eventPhase, target and current target for synchronous and asynchronous cases </p>
+<p> You should see type, bubble, cancelable, eventPhase, target and current target.</p>
 <script type="text/javascript">
 function log (msg)
 {
@@ -23,7 +23,7 @@ function onProgress(e) {
     log("Target: " + e.target);
     log("Current target: " + e.currentTarget);
     e.currentTarget.onprogress = null;
-    if (shouldNotify && window.layoutTestController)
+    if (window.layoutTestController)
         layoutTestController.notifyDone();
 }
 
@@ -38,23 +38,10 @@ if (window.layoutTestController) {
     layoutTestController.waitUntilDone();
 }
 
-log("Synchronous case:");
-
-// Test synchronous
 var req = new XMLHttpRequest();
 req.onprogress = onProgress;
-req.open("GET", "resources/1251.html", false);
+req.open("GET", "resources/1251.html", true);
 req.send(null);
-
-insertNewLine();
-log("Asynchronous case:");
-
-// Test asynchronous
-var req2 = new XMLHttpRequest();
-req2.onprogress = onProgress;
-req2.open("GET", "resources/1251.html", true);
-shouldNotify = true;
-req2.send(null);
 </script>
 </body>
 </html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/resources/access-control-basic-post-fail-non-simple.cgi b/LayoutTests/http/tests/xmlhttprequest/resources/access-control-basic-post-fail-non-simple.cgi
new file mode 100755
index 0000000..7c34aca
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/resources/access-control-basic-post-fail-non-simple.cgi
@@ -0,0 +1,11 @@
+#!/usr/bin/perl -wT
+use strict;
+
+my $request;
+
+if ($ENV{'REQUEST_METHOD'} eq "POST") {
+    print "Content-Type: text/plain\n";
+    print "Access-Control-Allow-Credentials: true\n";
+    print "Access-Control-Allow-Origin: http://127.0.0.1:8000\n\n";
+    print "FAIL: Cross-domain access allowed.\n";
+}
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress-expected.txt b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress-expected.txt
index 9d0446e..20f14ef 100644
--- a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress-expected.txt
+++ b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress-expected.txt
@@ -2,10 +2,8 @@ Test case for Bug 18655: [XHR] OnProgress needs more test case
 
 This test verify that addEventListener("progress", XXX, XXX) works as expected.
 
-You should see PASSED 4 times.
+You should see PASSED 2 times.
 
 PASSED (1)
 PASSED (2)
-PASSED (3)
-PASSED (4)
 
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress.html b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress.html
index 6328e9a..f17d53a 100644
--- a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress.html
+++ b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-addEventListener-onProgress.html
@@ -5,7 +5,7 @@
 <body>
 <p> Test case for Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=18655">18655</a>: [XHR] OnProgress needs more test case </p>
 <p> This test verify that addEventListener("progress", XXX, XXX) works as expected. </p>
-<p> You should see PASSED 4 times. </p>
+<p> You should see PASSED 2 times. </p>
 <script type="text/javascript">
 var count = 1;
 
@@ -17,7 +17,7 @@ function log(msg)
 
 function onProgress(e) {
     log("PASSED (" + count + ")");
-    if (++count > 4 && window.layoutTestController)
+    if (++count > 2 && window.layoutTestController)
         layoutTestController.notifyDone();
 }
 
@@ -26,22 +26,6 @@ if (window.layoutTestController) {
     layoutTestController.dumpAsText();
 }
 
-// Asynchronous case
-
-// Test for capture phase 
-var req = new XMLHttpRequest();
-req.addEventListener("progress", onProgress, true);
-req.open("GET", "resources/1251.html", false);
-req.send(null);
-
-// Test for bubble phase 
-var req2 = new XMLHttpRequest();
-req2.addEventListener("progress", onProgress, false);
-req2.open("GET", "resources/1251.html", false);
-req2.send(null);
-
-// Synchronous case
-
 // Test for capture phase 
 var req3 = new XMLHttpRequest();
 req3.addEventListener("progress", onProgress, true);
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-length-onProgress.html b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-length-onProgress.html
index 57ae032..de96dcd 100644
--- a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-length-onProgress.html
+++ b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-no-content-length-onProgress.html
@@ -10,6 +10,17 @@
 <p id="shouldBeCalled"> FAILED </p>
 <p id="shouldNotBeCalled"> PASSED </p>
 <script type="text/javascript">
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+var count = 0;
+function checkDone() {
+    if (++count == 2 && window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
 function onProgressPassed(e) {
     document.getElementById("shouldBeCalled").innerHTML = "PASSED";
 }
@@ -18,24 +29,19 @@ function onProgressFailed(e) {
     document.getElementById("shouldNotBeCalled").innerHTML = "FAILED";
 }
 
-if (window.layoutTestController) {
-    layoutTestController.dumpAsText();
-    layoutTestController.waitUntilDone();
-}
-
 var req = new XMLHttpRequest();
 req.onprogress = onProgressPassed;
+req.onload = checkDone;
 // Test that onProgress is called on a normal file
-req.open("GET", "resource/1251.html", false);
+req.open("GET", "resource/1251.html", true);
 req.send(null);
 
 // If content length is not given, it should not be called
-req.onprogress = onProgressFailed;
-req.open("GET", "resources/noContentLength.asis", false);
-req.send(null);
-
-if (window.layoutTestController)
-    layoutTestController.notifyDone();
+var req2 = new XMLHttpRequest();
+req2.onprogress = onProgressFailed;
+req2.onload = checkDone;
+req2.open("GET", "resources/noContentLength.asis", true);
+req2.send(null);
 
 </script>
 </body>
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt
new file mode 100644
index 0000000..245d3c0
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt
@@ -0,0 +1,22 @@
+CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
+Test for:
+
+bug 40996: Progress event should not be fired during synchronous XMLHttpRequest;
+bug 17502: Assertion failure when trying to restart a sync XMLHttpRequest as an async one from onreadystatechange.
+ Step 1: Same origin request
+readystatechange 4
+load
+
+Step 2: Cross origin request, disallowed
+readystatechange 4
+error
+Error: NETWORK_ERR: XMLHttpRequest Exception 101
+
+Step 3: Cross origin request, allowed
+readystatechange 4
+load
+
+Step 4: Cross origin request, check that preflight isn't attempted
+readystatechange 4
+load
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events.html b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events.html
new file mode 100644
index 0000000..7b28eec
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events.html
@@ -0,0 +1,55 @@
+<p> Test for: <ul><li><a href="https://bugs.webkit.org/show_bug.cgi?id=40996">bug 40996<a>: Progress event should not be fired during synchronous XMLHttpRequest;</li>
+<li><a href="https://bugs.webkit.org/show_bug.cgi?id=17502">bug 17502<a>: Assertion failure when trying to restart a sync XMLHttpRequest as an async one from onreadystatechange.</li></ul>
+<pre id=log></pre>
+
+<script type="text/javascript">
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(message)
+{
+    document.getElementById("log").innerHTML += message + "\n";
+}
+
+function test(url)
+{
+    try {
+        var xhr = new XMLHttpRequest();
+        xhr.open("POST", url, false);
+        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+
+        xhr.addEventListener("loadstart", function () { log("loadstart"); }, true);
+        xhr.addEventListener("readystatechange", function () { log("readystatechange " + xhr.readyState); }, true);
+        xhr.addEventListener("progress", function () { log("progress"); }, true);
+        xhr.addEventListener("load", function () { log("load"); }, true);
+        xhr.addEventListener("error", function () { log("error"); }, true);
+        xhr.addEventListener("loadend", function () { log("loadend"); }, true);
+
+        xhr.upload.addEventListener("loadstart", function () { log("upload.loadstart"); }, true);
+        xhr.upload.addEventListener("readystatechange", function () { log("upload.readystatechange"); }, true); // No such event on upload object, but let's add a listener anyway.
+        xhr.upload.addEventListener("progress", function () { log("upload.progress"); }, true);
+        xhr.upload.addEventListener("load", function () { log("upload.load"); }, true);
+        xhr.upload.addEventListener("error", function () { log("upload.error"); }, true);
+        xhr.upload.addEventListener("loadend", function () { log("upload.loadend"); }, true);
+
+        xhr.send("foobar");
+    } catch (ex) {
+        log(ex);
+    }
+}
+
+
+log("Step 1: Same origin request");
+test("xmlhttprequest-sync-vs-async-assertion-failure.html");
+
+log("\nStep 2: Cross origin request, disallowed");
+test("http://localhost:8000/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html");
+
+log("\nStep 3: Cross origin request, allowed");
+test("http://localhost:8000/xmlhttprequest/resources/access-control-basic-allow.cgi");
+
+log("\nStep 4: Cross origin request, check that preflight isn't attempted");
+test("http://localhost:8000/xmlhttprequest/resources/access-control-basic-post-fail-non-simple.cgi");
+</script>
+
+</body></html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure-expected.txt b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure-expected.txt
new file mode 100644
index 0000000..a56ad8a
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure-expected.txt
@@ -0,0 +1,3 @@
+You should see "PASS" once:
+
+PASS
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html
new file mode 100644
index 0000000..4e712d2
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html
@@ -0,0 +1,36 @@
+<html><head></head><body>
+
+<p>You should see "PASS" once:</p>
+
+<script type="text/javascript">
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var xhr;
+
+if (window.XMLHttpRequest) {
+    xhr = new XMLHttpRequest();
+} else {
+    try {
+        xhr = new ActiveXObject("Msxml2.XMLHTTP");
+    } catch (ex) {
+        xhr = new ActiveXObject("Microsoft.XMLHTTP");
+    }
+}
+
+xhr.open("GET", "resources/1251.html", false);
+xhr.onreadystatechange = function () {
+    try {
+        xhr.open("GET", "resources/1251.html", true);
+        xhr.send(null);
+    } catch (ex) {
+    }
+}
+
+xhr.send(null);
+
+document.write("PASS");
+
+</script>
+
+</body></html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4017923..eb4cb40 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-07-19  Alexey Proskuryakov  <ap at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=40996
+        Progress event should not be fired during synchronous XMLHttpRequest
+
+        https://bugs.webkit.org/show_bug.cgi?id=17502
+        Assertion failure when trying to restart a sync XMLHttpRequest as an async one from onreadystatechange
+
+        Tests: http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events.html
+               http/tests/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::callReadyStateChangeListener): We now only dispatch readystatechange
+        event for synchronous requests in states UNSENT, OPENED and DONE. I'm not sure what exactly
+        the spec draft says about readystatechange for sync requests, but this seems to be the most
+        logical and backwards compatible behavior.
+        (WebCore::XMLHttpRequest::didReceiveData): Don't dispatch progress events for sync requests.
+        Note that we already don't dispatch upload progress events for those.
+
 2010-07-19  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Simon Fraser.
diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp
index 8762bb5..3e76407 100644
--- a/WebCore/xml/XMLHttpRequest.cpp
+++ b/WebCore/xml/XMLHttpRequest.cpp
@@ -283,7 +283,8 @@ void XMLHttpRequest::callReadyStateChangeListener()
         timelineAgent->willChangeXHRReadyState(m_url.string(), m_state);
 #endif
 
-    m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);
+    if (m_async || (m_state <= OPENED || m_state == DONE))
+        m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);
 
 #if ENABLE(INSPECTOR)
     if (callTimelineAgentOnReadyStateChange && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
@@ -978,8 +979,10 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
         long long expectedLength = m_response.expectedContentLength();
         m_receivedLength += len;
 
-        bool lengthComputable = expectedLength && m_receivedLength <= expectedLength;
-        m_progressEventThrottle.dispatchProgressEvent(lengthComputable, static_cast<unsigned>(m_receivedLength), static_cast<unsigned>(expectedLength));
+        if (m_async) {
+            bool lengthComputable = expectedLength && m_receivedLength <= expectedLength;
+            m_progressEventThrottle.dispatchProgressEvent(lengthComputable, static_cast<unsigned>(m_receivedLength), static_cast<unsigned>(expectedLength));
+        }
 
         if (m_state != LOADING)
             changeState(LOADING);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list