Bug 853162 - Remove XMLHttpRequest.sendAsBinary() interface. r=smaug

Should use send(Blob) instead. Thanks to Ms2ger for help fixing test failures.
This commit is contained in:
Dirkjan Ochtman 2015-02-08 17:01:44 +01:00
parent f2248a4f53
commit d0f22d9629
9 changed files with 8 additions and 82 deletions

View File

@ -38,6 +38,5 @@ DEPRECATED_OPERATION(ShowModalDialog)
DEPRECATED_OPERATION(Window_Content)
DEPRECATED_OPERATION(SyncXMLHttpRequest)
DEPRECATED_OPERATION(DataContainerEvent)
DEPRECATED_OPERATION(SendAsBinary)
DEPRECATED_OPERATION(Window_Controllers)
DEPRECATED_OPERATION(ImportXULIntoContent)

View File

@ -68,7 +68,7 @@ interface nsIXMLHttpRequestUpload : nsIXMLHttpRequestEventTarget {
* you're aware of all the security implications. And then think twice about
* it.
*/
[scriptable, uuid(704e91dc-a3f6-4e4d-9f5f-4bb85159aeb7)]
[scriptable, uuid(6f54214c-7175-498d-9d2d-0429e38c2869)]
interface nsIXMLHttpRequest : nsISupports
{
/**
@ -210,15 +210,6 @@ interface nsIXMLHttpRequest : nsISupports
*/
void send([optional] in nsIVariant body);
/**
* A variant of the send() method used to send binary data.
*
* @param body The request body as a DOM string. The string data will be
* converted to a single-byte string by truncation (i.e., the
* high-order byte of each character will be discarded).
*/
void sendAsBinary(in DOMString body);
/**
* Sets a HTTP request header for HTTP requests. You must call open
* before setting the request headers.

View File

@ -2350,60 +2350,6 @@ nsXMLHttpRequest::ChangeStateToDone()
}
}
NS_IMETHODIMP
nsXMLHttpRequest::SendAsBinary(const nsAString &aBody)
{
ErrorResult rv;
SendAsBinary(aBody, rv);
return rv.ErrorCode();
}
void
nsXMLHttpRequest::SendAsBinary(const nsAString &aBody,
ErrorResult& aRv)
{
char *data = static_cast<char*>(NS_Alloc(aBody.Length() + 1));
if (!data) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
if (GetOwner() && GetOwner()->GetExtantDoc()) {
GetOwner()->GetExtantDoc()->WarnOnceAbout(nsIDocument::eSendAsBinary);
}
nsAString::const_iterator iter, end;
aBody.BeginReading(iter);
aBody.EndReading(end);
char *p = data;
while (iter != end) {
if (*iter & 0xFF00) {
NS_Free(data);
aRv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR);
return;
}
*p++ = static_cast<char>(*iter++);
}
*p = '\0';
nsCOMPtr<nsIInputStream> stream;
aRv = NS_NewByteInputStream(getter_AddRefs(stream), data, aBody.Length(),
NS_ASSIGNMENT_ADOPT);
if (aRv.Failed()) {
NS_Free(data);
return;
}
nsCOMPtr<nsIWritableVariant> variant = new nsVariant();
aRv = variant->SetAsISupports(stream);
if (aRv.Failed()) {
return;
}
aRv = Send(variant);
}
static nsresult
GetRequestBody(nsIDOMDocument* aDoc, nsIInputStream** aResult,
uint64_t* aContentLength, nsACString& aContentType,

View File

@ -488,7 +488,6 @@ public:
}
aRv = Send(RequestBody(aStream));
}
void SendAsBinary(const nsAString& aBody, ErrorResult& aRv);
void Abort();

View File

@ -97,7 +97,13 @@ function updateProgress(e, data, testName) {
function sendData(s) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "progressserver.sjs?send");
xhr.sendAsBinary(s);
// The Blob constructor encodes String elements as UTF-8;
// for straight bytes, manually convert to ArrayBuffer first
var buffer = new Uint8Array(s.length);
for (var i = 0; i < s.length; ++i) {
buffer[i] = s.charCodeAt(i) & 0xff;
};
xhr.send(new Blob([buffer]));
}
function closeConn() {

View File

@ -153,8 +153,6 @@ SyncXMLHttpRequestWarning=Synchronous XMLHttpRequest on the main thread is depre
ImplicitMetaViewportTagFallback=No meta-viewport tag found. Please explicitly specify one to prevent unexpected behavioural changes in future versions. For more help https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag
# LOCALIZATION NOTE: Do not translate "DataContainerEvent" or "CustomEvent"
DataContainerEventWarning=Use of DataContainerEvent is deprecated. Use CustomEvent instead.
# LOCALIZATION NOTE: Do not translate "sendAsBinary" or "send(Blob data)"
SendAsBinaryWarning=The non-standard sendAsBinary method is deprecated and will soon be removed. Use the standard send(Blob data) method instead.
# LOCALIZATION NOTE: Do not translate "window.controllers"
Window_ControllersWarning=window.controllers is deprecated. Do not use it for UA detection.
ImportXULIntoContentWarning=Importing XUL nodes into a content document is deprecated. This functionality may be removed soon.

View File

@ -140,8 +140,6 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
[ChromeOnly, Exposed=Window]
readonly attribute MozChannel? channel;
[Throws]
void sendAsBinary(DOMString body);
[Throws, ChromeOnly, Exposed=Window]
any getInterface(IID iid);

View File

@ -2213,14 +2213,6 @@ XMLHttpRequest::Send(const ArrayBufferView& aBody, ErrorResult& aRv)
return Send(obj, aRv);
}
void
XMLHttpRequest::SendAsBinary(const nsAString& aBody, ErrorResult& aRv)
{
NS_NOTYETIMPLEMENTED("Implement me!");
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return;
}
void
XMLHttpRequest::Abort(ErrorResult& aRv)
{

View File

@ -178,9 +178,6 @@ public:
void
Send(const ArrayBufferView& aBody, ErrorResult& aRv);
void
SendAsBinary(const nsAString& aBody, ErrorResult& aRv);
void
Abort(ErrorResult& aRv);