зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset ff7dbda6a6d0 (bug 1207233)
This commit is contained in:
Родитель
28d0598039
Коммит
c33672a846
|
@ -30,7 +30,6 @@
|
|||
#include "mozilla/dom/StructuredCloneTags.h"
|
||||
#include "mozilla/dom/SubtleCryptoBinding.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/dom/WebCryptoCommon.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
|
@ -396,7 +395,7 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
|
|||
return ReadStructuredCloneImageData(aCx, aReader);
|
||||
}
|
||||
|
||||
if (aTag == SCTAG_DOM_WEBCRYPTO_KEY || aTag == SCTAG_DOM_URLSEARCHPARAMS) {
|
||||
if (aTag == SCTAG_DOM_WEBCRYPTO_KEY) {
|
||||
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
|
@ -405,20 +404,11 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
|
|||
// Prevent the return value from being trashed by a GC during ~nsRefPtr.
|
||||
JS::Rooted<JSObject*> result(aCx);
|
||||
{
|
||||
if (aTag == SCTAG_DOM_WEBCRYPTO_KEY) {
|
||||
RefPtr<CryptoKey> key = new CryptoKey(global);
|
||||
if (!key->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = key->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_URLSEARCHPARAMS) {
|
||||
RefPtr<URLSearchParams> usp = new URLSearchParams(global);
|
||||
if (!usp->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = usp->WrapObject(aCx, nullptr);
|
||||
}
|
||||
RefPtr<CryptoKey> key = new CryptoKey(global);
|
||||
if (!key->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = key->WrapObject(aCx, nullptr);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -514,15 +504,6 @@ StructuredCloneHolder::WriteFullySerializableObjects(JSContext* aCx,
|
|||
}
|
||||
}
|
||||
|
||||
// Handle URLSearchParams cloning
|
||||
{
|
||||
URLSearchParams* usp = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(URLSearchParams, aObj, usp))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_URLSEARCHPARAMS, 0) &&
|
||||
usp->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Key cloning
|
||||
{
|
||||
CryptoKey* key = nullptr;
|
||||
|
|
|
@ -54,9 +54,6 @@ enum StructuredCloneTags {
|
|||
|
||||
SCTAG_DOM_DIRECTORY,
|
||||
|
||||
// This tag is used by both main thread and workers.
|
||||
SCTAG_DOM_URLSEARCHPARAMS,
|
||||
|
||||
SCTAG_DOM_MAX
|
||||
};
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include "mozilla/dom/URLSearchParamsBinding.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsStringStream.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -302,7 +300,6 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(URLSearchParams)
|
|||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(URLSearchParams)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -447,103 +444,5 @@ URLSearchParams::GetValueAtIndex(uint32_t aIndex) const
|
|||
return mParams->GetValueAtIndex(aIndex);
|
||||
}
|
||||
|
||||
// Helper functions for structured cloning
|
||||
inline bool
|
||||
ReadString(JSStructuredCloneReader* aReader, nsString& aString)
|
||||
{
|
||||
MOZ_ASSERT(aReader);
|
||||
|
||||
bool read;
|
||||
uint32_t nameLength, zero;
|
||||
read = JS_ReadUint32Pair(aReader, &nameLength, &zero);
|
||||
if (!read) {
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(zero == 0);
|
||||
aString.SetLength(nameLength);
|
||||
size_t charSize = sizeof(nsString::char_type);
|
||||
read = JS_ReadBytes(aReader, (void*) aString.BeginWriting(),
|
||||
nameLength * charSize);
|
||||
if (!read) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool
|
||||
WriteString(JSStructuredCloneWriter* aWriter, const nsString& aString)
|
||||
{
|
||||
MOZ_ASSERT(aWriter);
|
||||
|
||||
size_t charSize = sizeof(nsString::char_type);
|
||||
return JS_WriteUint32Pair(aWriter, aString.Length(), 0) &&
|
||||
JS_WriteBytes(aWriter, aString.get(), aString.Length() * charSize);
|
||||
}
|
||||
|
||||
bool
|
||||
URLParams::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
|
||||
{
|
||||
const uint32_t& nParams = mParams.Length();
|
||||
if (!JS_WriteUint32Pair(aWriter, nParams, 0)) {
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < nParams; ++i) {
|
||||
if (!WriteString(aWriter, mParams[i].mKey) ||
|
||||
!WriteString(aWriter, mParams[i].mValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
URLParams::ReadStructuredClone(JSStructuredCloneReader* aReader)
|
||||
{
|
||||
MOZ_ASSERT(aReader);
|
||||
|
||||
DeleteAll();
|
||||
|
||||
uint32_t nParams, zero;
|
||||
nsAutoString key, value;
|
||||
if (!JS_ReadUint32Pair(aReader, &nParams, &zero)) {
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(zero == 0);
|
||||
for (uint32_t i = 0; i < nParams; ++i) {
|
||||
if (!ReadString(aReader, key) || !ReadString(aReader, value)) {
|
||||
return false;
|
||||
}
|
||||
Append(key, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
URLSearchParams::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
|
||||
{
|
||||
return mParams->WriteStructuredClone(aWriter);
|
||||
}
|
||||
|
||||
bool
|
||||
URLSearchParams::ReadStructuredClone(JSStructuredCloneReader* aReader)
|
||||
{
|
||||
return mParams->ReadStructuredClone(aReader);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
URLSearchParams::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
||||
nsACString& aContentType, nsACString& aCharset)
|
||||
{
|
||||
aContentType.AssignLiteral("application/x-www-form-urlencoded");
|
||||
aCharset.AssignLiteral("UTF-8");
|
||||
|
||||
nsAutoString serialized;
|
||||
Serialize(serialized);
|
||||
NS_ConvertUTF16toUTF8 converted(serialized);
|
||||
*aContentLength = converted.Length();
|
||||
return NS_NewCStringInputStream(aBody, converted);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -7,14 +7,12 @@
|
|||
#ifndef mozilla_dom_URLSearchParams_h
|
||||
#define mozilla_dom_URLSearchParams_h
|
||||
|
||||
#include "js/StructuredClone.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIXMLHttpRequest.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -110,12 +108,6 @@ public:
|
|||
return mParams[aIndex].mValue;
|
||||
}
|
||||
|
||||
bool
|
||||
ReadStructuredClone(JSStructuredCloneReader* aReader);
|
||||
|
||||
bool
|
||||
WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
|
||||
|
||||
private:
|
||||
void DecodeString(const nsACString& aInput, nsAString& aOutput);
|
||||
void ConvertString(const nsACString& aInput, nsAString& aOutput);
|
||||
|
@ -130,19 +122,17 @@ private:
|
|||
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
|
||||
};
|
||||
|
||||
class URLSearchParams final : public nsIXHRSendable,
|
||||
class URLSearchParams final : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
~URLSearchParams();
|
||||
|
||||
public:
|
||||
NS_DECL_NSIXHRSENDABLE
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(URLSearchParams)
|
||||
|
||||
URLSearchParams(nsISupports* aParent,
|
||||
URLSearchParamsObserver* aObserver=nullptr);
|
||||
URLSearchParamsObserver* aObserver);
|
||||
|
||||
URLSearchParams(nsISupports* aParent,
|
||||
const URLSearchParams& aOther);
|
||||
|
@ -199,12 +189,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ReadStructuredClone(JSStructuredCloneReader* aReader);
|
||||
|
||||
bool
|
||||
WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
|
||||
|
||||
private:
|
||||
void AppendInternal(const nsAString& aName, const nsAString& aValue);
|
||||
|
||||
|
|
|
@ -102,8 +102,6 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
|||
void send(FormData data);
|
||||
[Throws]
|
||||
void send(InputStream data);
|
||||
[Throws]
|
||||
void send(URLSearchParams data);
|
||||
|
||||
[Throws]
|
||||
void abort();
|
||||
|
|
|
@ -19,7 +19,6 @@ namespace dom {
|
|||
|
||||
class Blob;
|
||||
class FormData;
|
||||
class URLSearchParams;
|
||||
class XMLHttpRequestUpload;
|
||||
|
||||
class XMLHttpRequest : public XMLHttpRequestEventTarget
|
||||
|
@ -89,9 +88,6 @@ public:
|
|||
virtual void
|
||||
Send(JSContext* aCx, Blob& aBlob, ErrorResult& aRv) = 0;
|
||||
|
||||
virtual void
|
||||
Send(JSContext* aCx, URLSearchParams& aURLSearchParams, ErrorResult& aRv) = 0;
|
||||
|
||||
virtual void
|
||||
Send(JSContext* aCx, nsIDocument& aDoc, ErrorResult& aRv) = 0;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/FetchUtil.h"
|
||||
#include "mozilla/dom/FormData.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
|
@ -2218,15 +2217,6 @@ GetRequestBodyInternal(nsIInputStream* aStream, nsIInputStream** aResult,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetRequestBodyInternal(URLSearchParams* aURLSearchParams,
|
||||
nsIInputStream** aResult, uint64_t* aContentLength,
|
||||
nsACString& aContentType, nsACString& aCharset)
|
||||
{
|
||||
return aURLSearchParams->GetSendInfo(aResult, aContentLength,
|
||||
aContentType, aCharset);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetRequestBodyInternal(nsIXHRSendable* aSendable, nsIInputStream** aResult,
|
||||
uint64_t* aContentLength, nsACString& aContentType,
|
||||
|
@ -2407,12 +2397,6 @@ XMLHttpRequestMainThread::GetRequestBody(nsIVariant* aVariant,
|
|||
return GetRequestBodyInternal(value.mFormData, aResult, aContentLength,
|
||||
aContentType, aCharset);
|
||||
}
|
||||
case XMLHttpRequestMainThread::RequestBody::eURLSearchParams:
|
||||
{
|
||||
MOZ_ASSERT(value.mURLSearchParams);
|
||||
return GetRequestBodyInternal(value.mURLSearchParams, aResult,
|
||||
aContentLength, aContentType, aCharset);
|
||||
}
|
||||
case XMLHttpRequestMainThread::RequestBody::eInputStream:
|
||||
{
|
||||
return GetRequestBodyInternal(value.mStream, aResult, aContentLength,
|
||||
|
|
|
@ -56,7 +56,6 @@ namespace dom {
|
|||
class Blob;
|
||||
class BlobSet;
|
||||
class FormData;
|
||||
class URLSearchParams;
|
||||
class XMLHttpRequestUpload;
|
||||
|
||||
// A helper for building up an ArrayBuffer object's data
|
||||
|
@ -264,11 +263,6 @@ private:
|
|||
{
|
||||
mValue.mBlob = &aBlob;
|
||||
}
|
||||
explicit RequestBody(mozilla::dom::URLSearchParams& aURLSearchParams) :
|
||||
mType(eURLSearchParams)
|
||||
{
|
||||
mValue.mURLSearchParams = &aURLSearchParams;
|
||||
}
|
||||
explicit RequestBody(nsIDocument* aDocument) : mType(eDocument)
|
||||
{
|
||||
mValue.mDocument = aDocument;
|
||||
|
@ -294,8 +288,7 @@ private:
|
|||
eDocument,
|
||||
eDOMString,
|
||||
eFormData,
|
||||
eInputStream,
|
||||
eURLSearchParams
|
||||
eInputStream
|
||||
};
|
||||
union Value {
|
||||
const ArrayBuffer* mArrayBuffer;
|
||||
|
@ -305,7 +298,6 @@ private:
|
|||
const nsAString* mString;
|
||||
FormData* mFormData;
|
||||
nsIInputStream* mStream;
|
||||
URLSearchParams* mURLSearchParams;
|
||||
};
|
||||
|
||||
Type GetType() const
|
||||
|
@ -376,12 +368,6 @@ public:
|
|||
aRv = Send(RequestBody(aBlob));
|
||||
}
|
||||
|
||||
virtual void Send(JSContext* /*aCx*/, URLSearchParams& aURLSearchParams,
|
||||
ErrorResult& aRv) override
|
||||
{
|
||||
aRv = Send(RequestBody(aURLSearchParams));
|
||||
}
|
||||
|
||||
virtual void
|
||||
Send(JSContext* /*aCx*/, nsIDocument& aDoc, ErrorResult& aRv) override
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "mozilla/dom/FormData.h"
|
||||
#include "mozilla/dom/ProgressEvent.h"
|
||||
#include "mozilla/dom/StructuredCloneHolder.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -2167,39 +2166,6 @@ XMLHttpRequestWorker::Send(JSContext* aCx, FormData& aBody, ErrorResult& aRv)
|
|||
SendInternal(sendRunnable, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
XMLHttpRequestWorker::Send(JSContext* aCx, URLSearchParams& aBody,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
if (mCanceled) {
|
||||
aRv.ThrowUncatchableException();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mProxy) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
if (!GetOrCreateDOMReflector(aCx, &aBody, &value)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<SendRunnable> sendRunnable =
|
||||
new SendRunnable(mWorkerPrivate, mProxy, EmptyString());
|
||||
|
||||
sendRunnable->Write(aCx, value, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SendInternal(sendRunnable, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
XMLHttpRequestWorker::Send(JSContext* aCx, const ArrayBuffer& aBody,
|
||||
ErrorResult& aRv)
|
||||
|
|
|
@ -175,9 +175,6 @@ public:
|
|||
virtual void
|
||||
Send(JSContext* aCx, const ArrayBufferView& aBody, ErrorResult& aRv) override;
|
||||
|
||||
virtual void
|
||||
Send(JSContext* aCx, URLSearchParams& aBody, ErrorResult& aRv) override;
|
||||
|
||||
virtual void
|
||||
Send(JSContext* aCx, nsIDocument& aDoc, ErrorResult& aRv) override
|
||||
{
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
[setrequestheader-content-type.htm]
|
||||
type: testharness
|
||||
[ReadableStream request respects setRequestHeader("")]
|
||||
expected: FAIL
|
||||
|
||||
[ReadableStream request with under type sends no Content-Type without setRequestHeader() call]
|
||||
expected: FAIL
|
||||
|
||||
[ReadableStream request keeps setRequestHeader() Content-Type and charset]
|
||||
expected: FAIL
|
|
@ -9,229 +9,19 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
function request(inputGenerator, headersToSend, expectedType, title) {
|
||||
function request(value) {
|
||||
test(function() {
|
||||
try {
|
||||
var toSend = inputGenerator();
|
||||
} catch(e) {
|
||||
assert_unreached("Skipping test as could not create a " + inputGenerator.name.replace("_", "") + "; ");
|
||||
}
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("POST", "resources/inspect-headers.py?filter_name=Content-Type", false)
|
||||
for(header in headersToSend) {
|
||||
if (headersToSend.hasOwnProperty(header)) {
|
||||
client.setRequestHeader(header, headersToSend[header]);
|
||||
}
|
||||
}
|
||||
client.send(toSend)
|
||||
|
||||
var responseType = client.responseText.replace("\n", "").replace("; ", ";").toLowerCase(); // don't care about case or space after semicolon for charset
|
||||
if (expectedType === undefined || expectedType === null) {
|
||||
assert_equals(responseType, "");
|
||||
} else if (expectedType instanceof RegExp) {
|
||||
if (!expectedType.ignoreCase) expectedType = new RegExp(expectedType, "i"); // always ignore case; the regex itself will have to remember to handle the optional space after the semicolon for charset
|
||||
assert_regexp_match(responseType, expectedType);
|
||||
} else {
|
||||
expectedType = "content-type: " + String(expectedType ? expectedType.trim().replace("; ", ";") : expectedType).toLowerCase()
|
||||
assert_equals(responseType, expectedType);
|
||||
}
|
||||
}, title)
|
||||
client.setRequestHeader('Content-Type', value)
|
||||
client.send("")
|
||||
assert_equals(client.responseText, 'content-type: '+ String(value ? value.trim() : value).toLowerCase()+'\n' )
|
||||
}, document.title + " (" + value + ")")
|
||||
}
|
||||
request(
|
||||
function _String() { return ""; },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'setRequestHeader("") sends a blank string'
|
||||
)
|
||||
request(
|
||||
function _String() { return ""; },
|
||||
{"Content-Type": " "},
|
||||
" ",
|
||||
'setRequestHeader(" ") sends the string " "'
|
||||
)
|
||||
request(
|
||||
function _String() { return ""; },
|
||||
{"Content-Type": null},
|
||||
"null",
|
||||
'setRequestHeader(null) sends the string "null"'
|
||||
)
|
||||
request(
|
||||
function _String() { return ""; },
|
||||
{"Content-Type": undefined},
|
||||
"undefined",
|
||||
'setRequestHeader(undefined) sends the string "undefined"'
|
||||
)
|
||||
request(
|
||||
function _String() { return "test"; },
|
||||
{},
|
||||
"text/plain;charset=UTF-8",
|
||||
'String request has correct default Content-Type of "text/plain;charset=UTF-8"'
|
||||
)
|
||||
request(
|
||||
function _String() { return "test()"; },
|
||||
{"Content-Type": "text/javascript;charset=ASCII"},
|
||||
"text/javascript;charset=UTF-8",
|
||||
"String request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8"
|
||||
)
|
||||
request(
|
||||
function _XMLDocument() { return new DOMParser().parseFromString("<xml/>", "application/xml"); },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'XML Document request respects setRequestHeader("")'
|
||||
)
|
||||
request(
|
||||
function _XMLDocument() { return new DOMParser().parseFromString("<xml/>", "application/xml"); },
|
||||
{},
|
||||
"application/xml;charset=UTF-8",
|
||||
'XML Document request has correct default Content-Type of "application/xml;charset=UTF-8"'
|
||||
)
|
||||
request(
|
||||
function _XMLDocument() { return new DOMParser().parseFromString("<xml/>", "application/xml"); },
|
||||
{"Content-Type": "application/xhtml+xml;charset=ASCII"},
|
||||
"application/xhtml+xml;charset=UTF-8",
|
||||
"XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8"
|
||||
)
|
||||
request(
|
||||
function _HTMLDocument() { return new DOMParser().parseFromString("<html></html>", "text/html"); },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'HTML Document request respects setRequestHeader("")'
|
||||
)
|
||||
request(
|
||||
function _HTMLDocument() { return new DOMParser().parseFromString("<html></html>", "text/html"); },
|
||||
{},
|
||||
"text/html;charset=UTF-8",
|
||||
'HTML Document request has correct default Content-Type of "text/html;charset=UTF-8"'
|
||||
)
|
||||
request(
|
||||
function _HTMLDocument() { return new DOMParser().parseFromString("<html></html>", "text/html"); },
|
||||
{"Content-Type": "text/html+junk;charset=ASCII"},
|
||||
"text/html+junk;charset=UTF-8",
|
||||
"HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8"
|
||||
)
|
||||
request(
|
||||
function _Blob() { return new Blob(["test"]); },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'Blob request respects setRequestHeader("") to be specified'
|
||||
)
|
||||
request(
|
||||
function _Blob() { return new Blob(["test"]); },
|
||||
{},
|
||||
undefined,
|
||||
"Blob request with unset type sends no Content-Type without setRequestHeader() call"
|
||||
)
|
||||
request(
|
||||
function _Blob() { return new Blob(["test"]); },
|
||||
{"Content-Type": "application/xml;charset=ASCII"},
|
||||
"application/xml;charset=ASCII",
|
||||
"Blob request with unset type keeps setRequestHeader() Content-Type and charset"
|
||||
)
|
||||
request(
|
||||
function _Blob() { return new Blob(["<xml/>"], {type : "application/xml;charset=ASCII"}); },
|
||||
{},
|
||||
"application/xml;charset=ASCII",
|
||||
"Blob request with set type uses that it for Content-Type unless setRequestHeader()"
|
||||
)
|
||||
request(
|
||||
function _Blob() { return new Blob(["<xml/>"], {type : "application/xml;charset=UTF8"}); },
|
||||
{"Content-Type": "application/xml+junk;charset=ASCII"},
|
||||
"application/xml+junk;charset=ASCII",
|
||||
"Blob request with set type keeps setRequestHeader() Content-Type and charset"
|
||||
)
|
||||
request(
|
||||
function _ArrayBuffer() { return new ArrayBuffer(10); },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'ArrayBuffer request respects setRequestHeader("")'
|
||||
)
|
||||
request(
|
||||
function _ArrayBuffer() { return new ArrayBuffer(10); },
|
||||
{},
|
||||
undefined,
|
||||
"ArrayBuffer request sends no Content-Type without setRequestHeader() call"
|
||||
)
|
||||
request(
|
||||
function _ArrayBuffer() { return new ArrayBuffer(10); },
|
||||
{"Content-Type": "application/xml;charset=ASCII"},
|
||||
"application/xml;charset=ASCII",
|
||||
"ArrayBuffer request keeps setRequestHeader() Content-Type and charset"
|
||||
)
|
||||
request(
|
||||
function _Uint8Array() { return new Uint8Array(new ArrayBuffer(10)); },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'ArrayBufferView request respects setRequestHeader("")'
|
||||
)
|
||||
request(
|
||||
function _Uint8Array() { return new Uint8Array(new ArrayBuffer(10)); },
|
||||
{},
|
||||
undefined,
|
||||
"ArrayBufferView request sends no Content-Type without setRequestHeader() call"
|
||||
)
|
||||
request(
|
||||
function _Uint8Array() { return new Uint8Array(new ArrayBuffer(10)); },
|
||||
{"Content-Type": "application/xml;charset=ASCII"},
|
||||
"application/xml;charset=ASCII",
|
||||
"ArrayBufferView request keeps setRequestHeader() Content-Type and charset"
|
||||
)
|
||||
request(
|
||||
function _FormData() { return new FormData(); },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'FormData request respects setRequestHeader("")'
|
||||
)
|
||||
request(
|
||||
function _FormData() { return new FormData(); },
|
||||
{},
|
||||
/multipart\/form-data;boundary=(.*)/,
|
||||
'FormData request has correct default Content-Type of "multipart\/form-data;boundary=_"'
|
||||
)
|
||||
request(
|
||||
function _FormData() { return new FormData(); },
|
||||
{"Content-Type": "application/xml;charset=ASCII"},
|
||||
"application/xml;charset=ASCII",
|
||||
"FormData request keeps setRequestHeader() Content-Type and charset"
|
||||
)
|
||||
request(
|
||||
function _URLSearchParams() { return new URLSearchParams("q=testQ&topic=testTopic") },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'URLSearchParams respects setRequestHeader("")'
|
||||
)
|
||||
request(
|
||||
function _URLSearchParams() { return new URLSearchParams("q=testQ&topic=testTopic") },
|
||||
{},
|
||||
"application/x-www-form-urlencoded;charset=UTF-8",
|
||||
'URLSearchParams request has correct default Content-Type of "application/x-www-form-urlencoded;charset=UTF-8"'
|
||||
)
|
||||
request(
|
||||
function _URLSearchParams() { return new URLSearchParams("q=testQ&topic=testTopic") },
|
||||
{"Content-Type": "application/xml;charset=ASCII"},
|
||||
"application/xml;charset=UTF-8",
|
||||
"URLSearchParams request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8"
|
||||
// the default Content-Type for URLSearchParams has a charset specified (utf-8) in
|
||||
// https://fetch.spec.whatwg.org/#bodyinit, so the user's must be changed to match it
|
||||
// as per https://xhr.spec.whatwg.org/#the-send%28%29-method step 4.
|
||||
)
|
||||
request(
|
||||
function _ReadableStream() { return new ReadableStream() },
|
||||
{"Content-Type": ""},
|
||||
"",
|
||||
'ReadableStream request respects setRequestHeader("")'
|
||||
)
|
||||
request(
|
||||
function _ReadableStream() { return new ReadableStream() },
|
||||
{},
|
||||
undefined,
|
||||
"ReadableStream request with under type sends no Content-Type without setRequestHeader() call"
|
||||
)
|
||||
request(
|
||||
function _ReadableStream() { return new ReadableStream() },
|
||||
{"Content-Type": "application/xml;charset=ASCII"},
|
||||
"application/xml;charset=ASCII",
|
||||
"ReadableStream request keeps setRequestHeader() Content-Type and charset"
|
||||
)
|
||||
request("")
|
||||
request(" ")
|
||||
request(null)
|
||||
request(undefined)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -215,14 +215,6 @@ URLSearchParams::NotifyObserver()
|
|||
NS_NOTREACHED("Unexpected call to URLSearchParams::NotifyObserver");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
URLSearchParams::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
||||
nsACString& aContentType, nsACString& aCharset)
|
||||
{
|
||||
NS_NOTREACHED("Unexpected call to URLSearchParams::GetSendInfo");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче