Bug 1397151 - Remove the support for moz-chunk-text type in XHR, r=smaug

This commit is contained in:
Andrea Marchesini 2017-09-22 07:18:49 +02:00
parent 2071ba4680
commit b49b5f31c9
9 changed files with 10 additions and 118 deletions

View File

@ -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)

View File

@ -23,7 +23,6 @@ enum XMLHttpRequestResponseType {
"text",
// Mozilla-specific stuff
"moz-chunked-text",
"moz-chunked-arraybuffer",
};

View File

@ -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);

View File

@ -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");

View File

@ -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();
}

View File

@ -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;

View File

@ -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");
}

View File

@ -1,8 +1,5 @@
[historical.html]
type: testharness
[Support for responseType = moz-chunked-text]
expected: FAIL
[Support for responseType = moz-chunked-arraybuffer]
expected: FAIL

View File

@ -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"],