diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 078223d671f0..4fc0a7c19867 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -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; } diff --git a/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html b/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html index bdbbf1591539..0491fe2fca1c 100644 --- a/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html +++ b/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html @@ -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(); } } diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 8f392ff46009..ea5951e22f18 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -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": [ diff --git a/testing/web-platform/tests/xhr/overridemimetype-done-state.any.js b/testing/web-platform/tests/xhr/overridemimetype-done-state.any.js index ca9fbaa7e9ac..bdf49e1ca52e 100644 --- a/testing/web-platform/tests/xhr/overridemimetype-done-state.any.js +++ b/testing/web-platform/tests/xhr/overridemimetype-done-state.any.js @@ -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'); diff --git a/testing/web-platform/tests/xhr/responsetype.any.js b/testing/web-platform/tests/xhr/responsetype.any.js index 17788e4782ce..88bd9189ebed 100644 --- a/testing/web-platform/tests/xhr/responsetype.any.js +++ b/testing/web-platform/tests/xhr/responsetype.any.js @@ -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(); } });