Bug 608939 - XMLHttpRequest.statusText and getAllResponseHeaders shouldn't throw, r=sicking, a=sicking

--HG--
extra : rebase_source : 5dc42964f6a216c4f10127d0ad74fe52674601d7
This commit is contained in:
Olli Pettay 2010-11-11 23:39:14 +02:00
Родитель 70c2a075f7
Коммит da61055435
4 изменённых файлов: 32 добавлений и 15 удалений

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

@ -1321,15 +1321,15 @@ nsXMLHttpRequest::GetStatusText(nsACString& aStatusText)
nsresult status;
mChannel->GetStatus(&status);
if (NS_FAILED(status)) {
return NS_ERROR_NOT_AVAILABLE;
return NS_OK;
}
}
}
rv = httpChannel->GetResponseStatusText(aStatusText);
httpChannel->GetResponseStatusText(aStatusText);
}
return rv;
return NS_OK;
}
/* void abort (); */
@ -1388,23 +1388,21 @@ nsXMLHttpRequest::GetAllResponseHeaders(char **_retval)
*_retval = nsnull;
if (mState & XML_HTTP_REQUEST_USE_XSITE_AC) {
*_retval = ToNewCString(EmptyString());
return NS_OK;
}
nsCOMPtr<nsIHttpChannel> httpChannel = GetCurrentHttpChannel();
if (httpChannel) {
nsHeaderVisitor *visitor = new nsHeaderVisitor();
if (!visitor)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(visitor);
nsRefPtr<nsHeaderVisitor> visitor = new nsHeaderVisitor();
nsresult rv = httpChannel->VisitResponseHeaders(visitor);
if (NS_SUCCEEDED(rv))
*_retval = ToNewCString(visitor->Headers());
NS_RELEASE(visitor);
return rv;
}
if (!*_retval) {
*_retval = ToNewCString(EmptyString());
}
return NS_OK;

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

@ -648,7 +648,7 @@ function runTest() {
is(res.didFail, true,
"should have failed in test for " + test.toSource());
is(res.status, 0, "wrong status in test for " + test.toSource());
is(res.statusText, undefined, "wrong status in test for " + test.toSource());
is(res.statusText, "", "wrong status in test for " + test.toSource());
is(res.responseXML, null,
"wrong responseXML in test for " + test.toSource());
is(res.responseText, "",
@ -788,7 +788,7 @@ function runTest() {
is(res.didFail, true,
"should have failed in test for " + test.toSource());
is(res.status, 0, "wrong status in test for " + test.toSource());
is(res.statusText, undefined, "wrong status in test for " + test.toSource());
is(res.statusText, "", "wrong status in test for " + test.toSource());
is(res.responseXML, null,
"wrong responseXML in test for " + test.toSource());
is(res.responseText, "",
@ -1057,7 +1057,7 @@ function runTest() {
is(res.didFail, true,
"should have failed in test for " + test.toSource());
is(res.status, 0, "wrong status in test for " + test.toSource());
is(res.statusText, undefined, "wrong status in test for " + test.toSource());
is(res.statusText, "", "wrong status in test for " + test.toSource());
is(res.responseXML, null,
"wrong responseXML in test for " + test.toSource());
is(res.responseText, "",

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

@ -149,7 +149,7 @@ function runTest() {
is(res.didFail, true, "should have failed for " + allowOrigin);
is(res.responseText, "", "should have no text for " + allowOrigin);
is(res.status, 0, "should have no status for " + allowOrigin);
is(res.statusText, undefined, "wrong status text for " + allowOrigin);
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",

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

@ -90,6 +90,25 @@ ok(u8v[0] == 0xaa && u8v[1] == 0xee && u8v[2] == 0x00 && u8v[3] == 0x03, "wrong
is(i32v[1], -1, "wrong value, expected -1 (0xffffffff)");
is(u32v[0], 0xbbbbbbbb, "wrong value, expected 0xbbbbbbbb");
var client = new XMLHttpRequest();
client.onreadystatechange = function() {
if(client.readyState == 4) {
try {
is(client.responseXML, null, "responseXML should be null.");
is(client.responseText, "", "responseText should be empty string.");
is(client.status, 0, "status should be 0.");
is(client.statusText, "", "statusText should be empty string.");
is(client.getAllResponseHeaders(), "",
"getAllResponseHeaders() should return empty string.");
} catch(ex) {
ok(false, "Shouldn't throw! [" + ex + "]");
}
}
}
client.open("GET", "file_XHR_pass1.xml", true);
client.send();
client.abort();
</script>
</pre>
</body>