Bug 461066: Test for loadend firing correctly in CORS tests. r=smaug

This commit is contained in:
Jonas Sicking 2011-03-28 13:18:55 -07:00
Родитель 7f14c5ec51
Коммит a95951e247
6 изменённых файлов: 28 добавлений и 29 удалений

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

@ -25,7 +25,7 @@ window.addEventListener("message", function(e) {
};
var xhr = new XMLHttpRequest();
for each(type in ["load", "abort", "error", "loadstart"]) {
for each(type in ["load", "abort", "error", "loadstart", "loadend"]) {
xhr.addEventListener(type, function(e) {
res.events.push(e.type);
}, false);
@ -48,10 +48,10 @@ window.addEventListener("message", function(e) {
}, false);
}
}
xhr.onload = xhr.onerror = function (event) {
if (event.type == "error") {
res.didFail = true;
}
xhr.onerror = function(e) {
res.didFail = true;
};
xhr.onloadend = function (event) {
res.status = xhr.status;
try {
res.statusText = xhr.statusText;

Двоичные данные
content/base/test/file_CrossSiteXHR_inner.jar

Двоичный файл не отображается.

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

@ -14,7 +14,7 @@ window.addEventListener("message", function(e) {\n\
};\n\
\n\
var xhr = new XMLHttpRequest();\n\
for each(type in ["load", "abort", "error", "loadstart"]) {\n\
for each(type in ["load", "abort", "error", "loadstart", "loadend"]) {\n\
xhr.addEventListener(type, function(e) {\n\
res.events.push(e.type);\n\
}, false);\n\
@ -37,26 +37,27 @@ window.addEventListener("message", function(e) {\n\
}, false);\n\
}\n\
}\n\
xhr.onload = function () {\n\
res.status = xhr.status;\n\
res.statusText = xhr.statusText;\n\
res.responseXML = xhr.responseXML ?\n\
(new XMLSerializer()).serializeToString(xhr.responseXML) :\n\
null;\n\
res.responseText = xhr.responseText;\n\
post(e, res);\n\
};\n\
xhr.onerror = function () {\n\
xhr.onerror = function(e) {\n\
res.didFail = true;\n\
};\n\
xhr.onloadend = function (event) {\n\
res.status = xhr.status;\n\
try {\n\
res.statusText = xhr.statusText;\n\
} catch (e) {\n\
delete(res.statusText);\n\
}\n\
res.responseXML = xhr.responseXML ?\n\
(new XMLSerializer()).serializeToString(xhr.responseXML) :\n\
null;\n\
res.responseText = xhr.responseText;\n\
\n\
res.responseHeaders = {};\n\
for (responseHeader in req.responseHeaders) {\n\
res.responseHeaders[responseHeader] =\n\
xhr.getResponseHeader(responseHeader);\n\
}\n\
\n\
post(e, res);\n\
}\n\
\n\

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

@ -656,7 +656,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
else {
@ -665,7 +665,7 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
if (test.responseHeaders) {
@ -694,7 +694,7 @@ function runTest() {
"wrong responseText in test for " + test.toSource());
if (!res.sendThrew) {
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + test.toSource());
}
is(res.progressEvents, 0,
@ -822,7 +822,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
else {
@ -835,7 +835,7 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + test.toSource());
is(res.progressEvents, 0,
"wrong events in test for " + test.toSource());
@ -1091,7 +1091,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + test.toSource());
}
else {
@ -1104,7 +1104,7 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + test.toSource());
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + test.toSource());
is(res.progressEvents, 0,
"wrong progressevents in test for " + test.toSource());

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

@ -464,7 +464,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + testName);
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong events in test for " + testName);
}
else {
@ -476,15 +476,13 @@ function runTest() {
is(res.responseText, "",
"wrong responseText in test for " + testName);
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + testName);
is(res.progressEvents, 0,
"wrong events in test for " + testName);
}
}
SimpleTest.finish();
yield;

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

@ -133,7 +133,7 @@ function runTest() {
is(res.responseText, "<res>hello pass</res>\n",
"wrong responseText in test for " + allowOrigin);
is(res.events.join(","),
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load",
"opening,rs1,sending,rs1,loadstart,rs2,rs3,rs4,load,loadend",
"wrong responseText in test for " + allowOrigin);
}
@ -151,7 +151,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,rs1,loadstart,rs2,rs4,error",
"opening,rs1,sending,rs1,loadstart,rs2,rs4,error,loadend",
"wrong events in test for " + allowOrigin);
is(res.progressEvents, 0,
"wrong events in test for " + allowOrigin);