On request error, always fire events on the XMLHttpRequestUpload before the XMLHttpRequest

https://bugs.webkit.org/show_bug.cgi?id=119714

Reviewed by Alexey Proskuryakov.

Source/WebCore:

On request error, fire events on the XMLHttpRequestUpload object before the XMLHttpRequest
object as per the latest specification:
http://xhr.spec.whatwg.org/#request-error

This specification change was made in Sept 2010:
http://dev.w3.org/cvsweb/2006/webapi/XMLHttpRequest-2/Overview.src.html.diff?r1=1.138;r2=1.139;f=h

It addresses the following comment:
http://lists.w3.org/Archives/Public/public-webapps/2010JulSep/0777.html

IE10 and since recently Blink behave according to specification but WebKit was firing the
events on the XMLHttpRequest object BEFORE the XMLHttpRequestUpload object in case of
'network error' or 'abort error'. WebKit was however behaving according to specification
in case of 'timeout error', which was inconsistent.

Test: http/tests/xmlhttprequest/upload-request-error-event-order.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::networkError):
(WebCore::XMLHttpRequest::abortError):

LayoutTests:

Add a layout test to validate the order in which the events are fired in case
of a xhr request error. Also update an existing test which was relying on the
outdated firing order.

* http/tests/xmlhttprequest/simple-cross-origin-progress-events-expected.txt:
* http/tests/xmlhttprequest/simple-cross-origin-progress-events.html:
* http/tests/xmlhttprequest/upload-request-error-event-order-expected.txt: Added.
* http/tests/xmlhttprequest/upload-request-error-event-order.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154004 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7340ea89
2013-08-13 Christophe Dumez <ch.dumez@sisa.samsung.com>
On request error, always fire events on the XMLHttpRequestUpload before the XMLHttpRequest
https://bugs.webkit.org/show_bug.cgi?id=119714
Reviewed by Alexey Proskuryakov.
Add a layout test to validate the order in which the events are fired in case
of a xhr request error. Also update an existing test which was relying on the
outdated firing order.
* http/tests/xmlhttprequest/simple-cross-origin-progress-events-expected.txt:
* http/tests/xmlhttprequest/simple-cross-origin-progress-events.html:
* http/tests/xmlhttprequest/upload-request-error-event-order-expected.txt: Added.
* http/tests/xmlhttprequest/upload-request-error-event-order.html: Added.
2013-08-13 Gabor Abraham <abrhm@inf.u-szeged.hu>
[Qt] Unreviewed gardening. Rebase tests after r153901 and r153915. Skip failing tests.
......@@ -13,7 +13,7 @@ Response length: 0
Test 3: The URL is not allowed for cross-origin requests and at least one upload event is listened for before doing the send.
upload.onloadstart
upload.onerror (expected)
onerror (expected)
Response length: 0
upload.onerror (expected)
......@@ -103,12 +103,12 @@ function test3()
xhr.upload.onload = function() { log("FAIL: upload.onload") }
xhr.upload.onerror = function() {
log("upload.onerror (expected)")
if (window.testRunner)
testRunner.notifyDone();
}
xhr.onerror = function() {
log("onerror (expected)");
log("Response length: " + xhr.responseText.length);
if (window.testRunner)
testRunner.notifyDone();
}
xhr.onload = function() {
log("onload");
......
CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/resources/cross-site-progress-events.cgi. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
Test to validate the order in which the events are fired in case of a request error.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS actualOrder is "rsdone,upload.onerror,upload.onloadend,onerror,onloadend,"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/2012/WD-XMLHttpRequest-20121206/#request-error"/>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test to validate the order in which the events are fired in case of a request error.");
window.jsTestIsAsync = true;
expectedOrder = "rsdone,upload.onerror,upload.onloadend,onerror,onloadend,";
actualOrder = "";
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:8000/xmlhttprequest/resources/cross-site-progress-events.cgi", true);
xhr.setRequestHeader("Content-Type", "text/plain");
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
actualOrder += "rsdone,";
}
};
xhr.upload.onerror = function (evt) {
actualOrder += "upload.onerror,";
};
xhr.upload.onloadend = function () {
actualOrder += "upload.onloadend,";
};
xhr.onerror = function (evt) {
actualOrder += "onerror,";
};
xhr.onloadend = function () {
actualOrder += "onloadend,";
shouldBeEqualToString('actualOrder', '' + expectedOrder);
finishJSTest();
};
xhr.send("test");
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
2013-08-13 Christophe Dumez <ch.dumez@sisa.samsung.com>
On request error, always fire events on the XMLHttpRequestUpload before the XMLHttpRequest
https://bugs.webkit.org/show_bug.cgi?id=119714
Reviewed by Alexey Proskuryakov.
On request error, fire events on the XMLHttpRequestUpload object before the XMLHttpRequest
object as per the latest specification:
http://xhr.spec.whatwg.org/#request-error
This specification change was made in Sept 2010:
http://dev.w3.org/cvsweb/2006/webapi/XMLHttpRequest-2/Overview.src.html.diff?r1=1.138;r2=1.139;f=h
It addresses the following comment:
http://lists.w3.org/Archives/Public/public-webapps/2010JulSep/0777.html
IE10 and since recently Blink behave according to specification but WebKit was firing the
events on the XMLHttpRequest object BEFORE the XMLHttpRequestUpload object in case of
'network error' or 'abort error'. WebKit was however behaving according to specification
in case of 'timeout error', which was inconsistent.
Test: http/tests/xmlhttprequest/upload-request-error-event-order.html
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::networkError):
(WebCore::XMLHttpRequest::abortError):
2013-08-13 Christophe Dumez <ch.dumez@sisa.samsung.com>
Simplify RadioNodeList's anonymous indexed getter
......@@ -911,24 +911,24 @@ void XMLHttpRequest::genericError()
void XMLHttpRequest::networkError()
{
genericError();
m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));
if (!m_uploadComplete) {
m_uploadComplete = true;
if (m_upload && m_uploadEventsAllowed)
m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));
}
m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));
internalAbort();
}
void XMLHttpRequest::abortError()
{
genericError();
m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
if (!m_uploadComplete) {
m_uploadComplete = true;
if (m_upload && m_uploadEventsAllowed)
m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
}
m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
}
void XMLHttpRequest::dropProtection()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment