Bug 1478743 part 3. Remove bogus clearing of the response when xhr.overrideMimeType throws. r=baku

This commit is contained in:
Boris Zbarsky 2018-07-30 11:51:52 -04:00
Родитель ced4737fec
Коммит f44ce81c0a
5 изменённых файлов: 15 добавлений и 9 удалений

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

@ -3104,7 +3104,6 @@ XMLHttpRequestMainThread::OverrideMimeType(const nsAString& aMimeType,
if (mState == XMLHttpRequest_Binding::LOADING ||
mState == XMLHttpRequest_Binding::DONE) {
ResetResponse();
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE);
return;
}

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

@ -17,10 +17,10 @@ function onWindowLoad() {
function runTest() {
var testFunctions = [
function() { testOverMimeTypeThrowsDuringReadyState(3, "application/xml"); },
function() { testOverMimeTypeThrowsDuringReadyState(3, "application/xml;charset=Shift-JIS"); },
function() { testOverMimeTypeThrowsDuringReadyState(4, "application/xml"); },
function() { testOverMimeTypeThrowsDuringReadyState(4, "application/xml;charset=Shift-JIS"); },
function() { testOverMimeTypeThrowsDuringReadyState(3, "text/plain"); },
function() { testOverMimeTypeThrowsDuringReadyState(3, "text/plain;charset=Shift-JIS"); },
function() { testOverMimeTypeThrowsDuringReadyState(4, "text/plain"); },
function() { testOverMimeTypeThrowsDuringReadyState(4, "text/plain;charset=Shift-JIS"); },
];
function nextTest() {
@ -47,8 +47,9 @@ function runTest() {
}
}
if (xhr.readyState === 4) {
is(xhr.responseXML, null, "responseXML was not null" +
" for readyState=" + readyState + ", mimeType=" + mimeType);
isnot(xhr.responseXML, null, "responseXML was null" +
" for readyState=" + readyState +
", mimeType=" + mimeType);
nextTest();
}
}

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

@ -633267,7 +633267,7 @@
"testharness"
],
"xhr/overridemimetype-done-state.any.js": [
"bbdf30a044795788f81e6e7addbdc3355fe93fa4",
"5924cec26f0bf551a7d37969a62941fc88c177f1",
"testharness"
],
"xhr/overridemimetype-edge-cases.window.js": [
@ -633755,7 +633755,7 @@
"testharness"
],
"xhr/responsetype.any.js": [
"8c5d86795c3a88e485990a31e95619b77ab0360c",
"eda46254f0b786635b91fdd7f2b63992f2f9ad5d",
"testharness"
],
"xhr/responseurl.html": [

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

@ -7,10 +7,13 @@ var test = async_test();
var client = new XMLHttpRequest();
client.onreadystatechange = test.step_func( function() {
if (client.readyState !== 4) return;
var text = client.responseText;
assert_not_equals(text, "");
assert_throws("InvalidStateError", function() { client.overrideMimeType('application/xml;charset=Shift-JIS'); });
if (GLOBAL.isWindow()) {
assert_equals(client.responseXML, null);
}
assert_equals(client.responseText, text);
test.done();
});
client.open("GET", "resources/status.py?type="+encodeURIComponent('text/plain;charset=iso-8859-1')+'&content=%3Cmsg%3E%83%65%83%58%83%67%3C%2Fmsg%3E');

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

@ -85,6 +85,8 @@ types.forEach(function(type) {
xhr.open('get', '/');
xhr.onreadystatechange = this.step_func(function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
var text = xhr.responseText;
assert_not_equals(text, "");
if (isIgnoredType(type)) {
xhr.responseType = type;
} else {
@ -93,6 +95,7 @@ types.forEach(function(type) {
});
}
assert_equals(xhr.responseType, "");
assert_equals(xhr.responseText, text);
this.done();
}
});