Bug 1538456 - Don't fire an XHR HEADERS_RECEIVED event in the event of a network error; r=baku

Don't fire an XHR HEADERS_RECEIVED event in the event of a network error

Differential Revision: https://phabricator.services.mozilla.com/D25831

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Wisniewski 2019-04-03 05:19:06 +00:00
Родитель 0b813bfe94
Коммит 78b73b590c
6 изменённых файлов: 12 добавлений и 16 удалений

Просмотреть файл

@ -34,7 +34,7 @@ var url_connection_error = url_200.replace(/^(\w+:\/\/[^/]+?)(:\d+)?\//, "$1:954
var tests = [
["200 OK", url_200, [1, 2, 3, 4, "load"], null],
["404 Not Found", url_404, [1, 2, 3, 4, "load"], null],
["connection error", url_connection_error, [1, 2, 4, "error"], null],
["connection error", url_connection_error, [1, 4, "error"], null],
["abort() call on readyState = 1", url_200, [1, 4], null, doAbort1],
["abort() call on readyState = 2", url_200, [1, 2, 4], doAbort2],
];

Просмотреть файл

@ -760,15 +760,9 @@ function* runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
if (!res.sendThrew) {
if (test.username || test.password) {
is(res.events.join(","),
"opening,rs1,sending,loadstart,rs4,error,loadend",
"wrong events in test for " + test.toSource());
} else {
is(res.events.join(","),
"opening,rs1,sending,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + test.toSource());
}
is(res.events.join(","),
"opening,rs1,sending,loadstart,rs4,error,loadend",
"wrong events in test for " + test.toSource());
}
is(res.progressEvents, 0,
"wrong events in test for " + test.toSource());
@ -908,7 +902,7 @@ function* runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,loadstart,rs2,rs4,error,loadend",
"opening,rs1,sending,loadstart,rs4,error,loadend",
"wrong events in test for " + test.toSource());
is(res.progressEvents, 0,
"wrong events in test for " + test.toSource());
@ -1474,7 +1468,7 @@ function* runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,loadstart,rs2,rs4,error,loadend",
"opening,rs1,sending,loadstart,rs4,error,loadend",
"wrong events in test for " + test.toSource());
is(res.progressEvents, 0,
"wrong progressevents in test for " + test.toSource());

Просмотреть файл

@ -573,7 +573,7 @@ function* runTest() {
is(res.responseText, "",
"wrong responseText in test for " + testName);
is(res.events.join(","),
"opening,rs1,sending,loadstart,rs2,rs4,error,loadend",
"opening,rs1,sending,loadstart,rs4,error,loadend",
"wrong events in test for " + testName);
is(res.progressEvents, 0,
"wrong events in test for " + testName);

Просмотреть файл

@ -148,7 +148,7 @@ function* runTest() {
is(res.statusText, "", "wrong status text for " + allowOrigin);
is(res.responseXML, null, "should have no XML for " + allowOrigin);
is(res.events.join(","),
"opening,rs1,sending,loadstart,rs2,rs4,error,loadend",
"opening,rs1,sending,loadstart,rs4,error,loadend",
"wrong events in test for " + allowOrigin);
is(res.progressEvents, 0,
"wrong events in test for " + allowOrigin);

Просмотреть файл

@ -1807,7 +1807,9 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request) {
}
mFlagParseBody = true;
ChangeState(XMLHttpRequest_Binding::HEADERS_RECEIVED);
if (mErrorLoad == ErrorType::eOK) {
ChangeState(XMLHttpRequest_Binding::HEADERS_RECEIVED);
}
ResetResponse();

Просмотреть файл

@ -22,7 +22,7 @@
xhr.addEventListener("loadend", function() {
test.step(function() {
// no progress events due to CORS failure
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,12,true)", 2, 4, "upload.error(0,0,false)", "upload.loadend(0,0,false)", "error(0,0,false)", "loadend(0,0,false)"]);
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,12,true)", 4, "upload.error(0,0,false)", "upload.loadend(0,0,false)", "error(0,0,false)", "loadend(0,0,false)"]);
test.done();
});
});