From b49b5f31c9183d0f512d00867b8b406fab0289fc Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Fri, 22 Sep 2017 07:18:49 +0200 Subject: [PATCH] Bug 1397151 - Remove the support for moz-chunk-text type in XHR, r=smaug --- dom/base/domerr.msg | 4 +- dom/webidl/XMLHttpRequest.webidl | 1 - dom/xhr/XMLHttpRequestMainThread.cpp | 26 ++------ dom/xhr/tests/test_XHR.html | 2 - dom/xhr/tests/test_html_in_xhr.html | 17 +---- dom/xhr/tests/test_xhr_progressevents.html | 1 - dom/xhr/tests/xhr2_worker.js | 65 +------------------ .../meta/XMLHttpRequest/historical.html.ini | 3 - toolkit/components/telemetry/Histograms.json | 9 --- 9 files changed, 10 insertions(+), 118 deletions(-) diff --git a/dom/base/domerr.msg b/dom/base/domerr.msg index 42ac0fb62117..63508791d5f9 100644 --- a/dom/base/domerr.msg +++ b/dom/base/domerr.msg @@ -161,6 +161,6 @@ DOM4_MSG_DEF(InvalidStateError, "XMLHttpRequest state must be OPENED.", NS_ERROR DOM4_MSG_DEF(InvalidStateError, "XMLHttpRequest must not be sending.", NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_SENDING) DOM4_MSG_DEF(InvalidStateError, "XMLHttpRequest state must not be LOADING or DONE.", NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE) DOM4_MSG_DEF(InvalidStateError, "responseXML is only available if responseType is '' or 'document'.", NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSEXML) -DOM4_MSG_DEF(InvalidStateError, "responseText is only available if responseType is '', 'document', or 'moz-chunked-text'.", NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSETEXT) -DOM4_MSG_DEF(InvalidStateError, "synchronous XMLHttpRequests do not support 'moz-chunked-text' or 'moz-chunked-arraybuffer' responseType.", NS_ERROR_DOM_INVALID_STATE_XHR_CHUNKED_RESPONSETYPES_UNSUPPORTED_FOR_SYNC) +DOM4_MSG_DEF(InvalidStateError, "responseText is only available if responseType is '' or 'document'.", NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSETEXT) +DOM4_MSG_DEF(InvalidStateError, "synchronous XMLHttpRequests do not support 'moz-chunked-arraybuffer' responseType.", NS_ERROR_DOM_INVALID_STATE_XHR_CHUNKED_RESPONSETYPES_UNSUPPORTED_FOR_SYNC) DOM4_MSG_DEF(InvalidAccessError, "synchronous XMLHttpRequests do not support timeout and responseType.", NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC) diff --git a/dom/webidl/XMLHttpRequest.webidl b/dom/webidl/XMLHttpRequest.webidl index d903cd1088aa..569e3e28d3cf 100644 --- a/dom/webidl/XMLHttpRequest.webidl +++ b/dom/webidl/XMLHttpRequest.webidl @@ -23,7 +23,6 @@ enum XMLHttpRequestResponseType { "text", // Mozilla-specific stuff - "moz-chunked-text", "moz-chunked-arraybuffer", }; diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 1ab885668405..7531cb189ec6 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -501,8 +501,7 @@ XMLHttpRequestMainThread::DetectCharset() if (mResponseType != XMLHttpRequestResponseType::_empty && mResponseType != XMLHttpRequestResponseType::Text && - mResponseType != XMLHttpRequestResponseType::Json && - mResponseType != XMLHttpRequestResponseType::Moz_chunked_text) { + mResponseType != XMLHttpRequestResponseType::Json) { return NS_OK; } @@ -607,18 +606,11 @@ XMLHttpRequestMainThread::GetResponseText(XMLHttpRequestStringSnapshot& aSnapsho aSnapshot.Reset(); if (mResponseType != XMLHttpRequestResponseType::_empty && - mResponseType != XMLHttpRequestResponseType::Text && - mResponseType != XMLHttpRequestResponseType::Moz_chunked_text) { + mResponseType != XMLHttpRequestResponseType::Text) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSETEXT); return; } - if (mResponseType == XMLHttpRequestResponseType::Moz_chunked_text && - !mInLoadProgressEvent) { - aSnapshot.SetVoid(); - return; - } - if (mState != State::loading && mState != State::done) { return; } @@ -722,16 +714,13 @@ XMLHttpRequestMainThread::SetResponseType(XMLHttpRequestResponseType aResponseTy } if (mFlagSynchronous && - (aResponseType == XMLHttpRequestResponseType::Moz_chunked_text || - aResponseType == XMLHttpRequestResponseType::Moz_chunked_arraybuffer)) { + aResponseType == XMLHttpRequestResponseType::Moz_chunked_arraybuffer) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_XHR_CHUNKED_RESPONSETYPES_UNSUPPORTED_FOR_SYNC); return; } // We want to get rid of this moz-only types. Bug 1335365. - if (aResponseType == XMLHttpRequestResponseType::Moz_chunked_text) { - Telemetry::Accumulate(Telemetry::MOZ_CHUNKED_TEXT_IN_XHR, 1); - } else if (aResponseType == XMLHttpRequestResponseType::Moz_chunked_arraybuffer) { + if (aResponseType == XMLHttpRequestResponseType::Moz_chunked_arraybuffer) { Telemetry::Accumulate(Telemetry::MOZ_CHUNKED_ARRAYBUFFER_IN_XHR, 1); } @@ -755,7 +744,6 @@ XMLHttpRequestMainThread::GetResponse(JSContext* aCx, switch (mResponseType) { case XMLHttpRequestResponseType::_empty: case XMLHttpRequestResponseType::Text: - case XMLHttpRequestResponseType::Moz_chunked_text: { DOMString str; GetResponseText(str, aRv); @@ -1396,8 +1384,7 @@ XMLHttpRequestMainThread::DispatchProgressEvent(DOMEventTargetHelper* aTarget, mInLoadProgressEvent = false; // clear chunked responses after every progress event - if (mResponseType == XMLHttpRequestResponseType::Moz_chunked_text || - mResponseType == XMLHttpRequestResponseType::Moz_chunked_arraybuffer) { + if (mResponseType == XMLHttpRequestResponseType::Moz_chunked_arraybuffer) { mResponseBody.Truncate(); TruncateResponseText(); mResultArrayBuffer = nullptr; @@ -1703,8 +1690,7 @@ XMLHttpRequestMainThread::StreamReaderFunc(nsIInputStream* in, } } else if (xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::_empty || xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Text || - xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Json || - xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Moz_chunked_text) { + xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Json) { NS_ASSERTION(!xmlHttpRequest->mResponseXML, "We shouldn't be parsing a doc here"); rv = xmlHttpRequest->AppendToResponseText(fromRawSegment, count); diff --git a/dom/xhr/tests/test_XHR.html b/dom/xhr/tests/test_XHR.html index 15c29c7ca72f..58a34f578eac 100644 --- a/dom/xhr/tests/test_XHR.html +++ b/dom/xhr/tests/test_XHR.html @@ -129,7 +129,6 @@ checkSetResponseType(xhr, "document"); checkSetResponseType(xhr, "arraybuffer"); checkSetResponseType(xhr, "blob"); checkSetResponseType(xhr, "json"); -checkSetResponseType(xhr, "moz-chunked-text"); checkSetResponseType(xhr, "moz-chunked-arraybuffer"); checkOpenThrows(xhr, "GET", "file_XHR_pass2.txt", false); @@ -142,7 +141,6 @@ checkSetResponseTypeThrows(xhr, "document"); checkSetResponseTypeThrows(xhr, "arraybuffer"); checkSetResponseTypeThrows(xhr, "blob"); checkSetResponseTypeThrows(xhr, "json"); -checkSetResponseTypeThrows(xhr, "moz-chunked-text"); checkSetResponseTypeThrows(xhr, "moz-chunked-arraybuffer"); xhr.send(null); checkSetResponseTypeThrows(xhr, "document"); diff --git a/dom/xhr/tests/test_html_in_xhr.html b/dom/xhr/tests/test_html_in_xhr.html index ccfb719474d6..33864e44ed0f 100644 --- a/dom/xhr/tests/test_html_in_xhr.html +++ b/dom/xhr/tests/test_html_in_xhr.html @@ -74,26 +74,11 @@ function testNonParsingText() { if (this.readyState == 4) { is(this.responseText.indexOf("\u042E"), -1, "Honored meta in text mode."); is(this.responseText.indexOf("\uFFFD"), 29, "Honored meta in text mode 2."); - testChunkedText(); - } - } - xhr.open("GET", "file_html_in_xhr2.html"); - xhr.responseType = "text"; - xhr.send(); -} - -function testChunkedText() { - xhr = new XMLHttpRequest(); - xhr.onprogress = function() { - is(this.responseText.indexOf("\u042E"), -1, "Honored meta in chunked text mode."); - } - xhr.onreadystatechange = function() { - if (this.readyState == 4) { testSyncXHR(); } } xhr.open("GET", "file_html_in_xhr2.html"); - xhr.responseType = "moz-chunked-text"; + xhr.responseType = "text"; xhr.send(); } diff --git a/dom/xhr/tests/test_xhr_progressevents.html b/dom/xhr/tests/test_xhr_progressevents.html index c1b43c345602..2586a3a90129 100644 --- a/dom/xhr/tests/test_xhr_progressevents.html +++ b/dom/xhr/tests/test_xhr_progressevents.html @@ -135,7 +135,6 @@ function* runTests() { { type: "document", text: true, nodata: true }, { type: "json", text: true, nodata: true }, { type: "", text: true }, - { type: "moz-chunked-text", text: true, chunked: true }, { type: "moz-chunked-arraybuffer", text: false, chunked: true }, ]; var responseType; diff --git a/dom/xhr/tests/xhr2_worker.js b/dom/xhr/tests/xhr2_worker.js index d355020c93b1..93dab612fa19 100644 --- a/dom/xhr/tests/xhr2_worker.js +++ b/dom/xhr/tests/xhr2_worker.js @@ -96,68 +96,5 @@ onmessage = function(event) { throw new Error("'document' type not working correctly"); } - // Make sure setting responseType before open or after send fails. - var exception; - - xhr = new XMLHttpRequest(); - xhr.open("GET", url); - xhr.responseType = "text"; - xhr.onload = function(event) { - if (event.target.response != refText) { - throw new Error("Bad response!"); - } - - xhr = new XMLHttpRequest(); - xhr.open("GET", url); - xhr.responseType = "moz-chunked-text"; - - var lastIndex = 0; - xhr.onprogress = function(event) { - if (refText.substr(lastIndex, xhr.response.length) != xhr.response) { - throw new Error("Bad chunk!"); - } - - lastIndex += xhr.response.length; - }; - - xhr.onload = function(event) { - if (lastIndex != refText.length) { - throw new Error("Didn't see all the data!"); - } - - setTimeout(function() { - if (xhr.response !== null) { - throw new Error("Should have gotten null response outside of event!"); - } - postMessage("done"); - }, 0); - } - - xhr.send(null); - }; - xhr.send(); - - exception = null; - - try { - xhr.responseType = "arraybuffer"; - } - catch(e) { - exception = e; - } - - if (!exception) { - throw new Error("Failed to throw when setting responseType after " + - "calling send()"); - } - - if (exception.name != "InvalidStateError") { - throw new Error("Unexpected error when setting responseType after " + - "calling send()"); - } - - if (exception.code != DOMException.INVALID_STATE_ERR) { - throw new Error("Unexpected error code when setting responseType after " + - "calling send()"); - } + postMessage("done"); } diff --git a/testing/web-platform/meta/XMLHttpRequest/historical.html.ini b/testing/web-platform/meta/XMLHttpRequest/historical.html.ini index ad3e49b967c0..10ee7f520b69 100644 --- a/testing/web-platform/meta/XMLHttpRequest/historical.html.ini +++ b/testing/web-platform/meta/XMLHttpRequest/historical.html.ini @@ -1,8 +1,5 @@ [historical.html] type: testharness - [Support for responseType = moz-chunked-text] - expected: FAIL - [Support for responseType = moz-chunked-arraybuffer] expected: FAIL diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index fc95df148393..3748905116e0 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -12963,15 +12963,6 @@ "bug_numbers": [1331804], "description": "The time a given main thread runnable took to run (in milliseconds). The key comes from the runnables nsINamed::name value." }, - "MOZ_CHUNKED_TEXT_IN_XHR": { - "record_in_processes": ["main", "content"], - "alert_emails": ["amarchesini@mozilla.com"], - "expires_in_version": "58", - "kind": "boolean", - "bug_numbers": [1335365], - "releaseChannelCollection": "opt-out", - "description": "XMLHttpRequest.responseType set to moz-chunked-text" - }, "MOZ_CHUNKED_ARRAYBUFFER_IN_XHR": { "record_in_processes": ["main", "content"], "alert_emails": ["amarchesini@mozilla.com"],