Bug 1636761 - Make URLSearchParams not structured-cloneable, r=asuth,webidl

Differential Revision: https://phabricator.services.mozilla.com/D182825
This commit is contained in:
edgul 2024-01-30 10:43:58 +00:00
parent f5c07f1154
commit 5266c6f856
5 changed files with 1 additions and 80 deletions

View File

@ -222,11 +222,6 @@ const serializable = [
["DOMMatrixReadOnly", ["Window", "Worker"], () => new DOMMatrixReadOnly()],
["ImageBitmap", ["Window", "Worker"], makeImageBitmap],
["RTCCertificate", ["Window"], generateCertificate],
[
"URLSearchParams",
["Window", "Worker", "WorkerDebugger"],
() => new URLSearchParams(),
],
["VideoFrame", ["Window", "DedicatedWorker"], makeVideoFrame],
];

View File

@ -171,60 +171,6 @@ void URLSearchParams::Sort(ErrorResult& aRv) {
NotifyObserver();
}
bool URLSearchParams::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 (!StructuredCloneHolder::WriteString(aWriter,
mParams->GetKeyAtIndex(i)) ||
!StructuredCloneHolder::WriteString(aWriter,
mParams->GetValueAtIndex(i))) {
return false;
}
}
return true;
}
bool URLSearchParams::ReadStructuredClone(JSStructuredCloneReader* aReader) {
MOZ_ASSERT(aReader);
DeleteAll();
uint32_t nParams, zero;
nsAutoString key, value;
if (!JS_ReadUint32Pair(aReader, &nParams, &zero) || zero != 0) {
return false;
}
for (uint32_t i = 0; i < nParams; ++i) {
if (!StructuredCloneHolder::ReadString(aReader, key) ||
!StructuredCloneHolder::ReadString(aReader, value)) {
return false;
}
Append(key, value);
}
return true;
}
bool URLSearchParams::WriteStructuredClone(
JSContext* aCx, JSStructuredCloneWriter* aWriter) const {
return WriteStructuredClone(aWriter);
}
// static
already_AddRefed<URLSearchParams> URLSearchParams::ReadStructuredClone(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader) {
RefPtr<URLSearchParams> params = new URLSearchParams(aGlobal);
if (!params->ReadStructuredClone(aReader)) {
return nullptr;
}
return params.forget();
}
// contentTypeWithCharset can be set to the contentType or
// contentType+charset based on what the spec says.
// See: https://fetch.spec.whatwg.org/#concept-bodyinit-extract

View File

@ -96,22 +96,11 @@ class URLSearchParams final : public nsISupports, public nsWrapperCache {
void Stringify(nsString& aRetval) const { Serialize(aRetval); }
static already_AddRefed<URLSearchParams> ReadStructuredClone(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader);
bool WriteStructuredClone(JSContext* aCx,
JSStructuredCloneWriter* aWriter) const;
nsresult GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
nsACString& aContentTypeWithCharset,
nsACString& aCharset) const;
private:
bool ReadStructuredClone(JSStructuredCloneReader* aReader);
bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
void AppendInternal(const nsAString& aName, const nsAString& aValue);
void DeleteAll();

View File

@ -13,8 +13,7 @@
* http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0.
*/
[Exposed=(Window,Worker,WorkerDebugger),
Serializable]
[Exposed=(Window,Worker,WorkerDebugger)]
interface URLSearchParams {
[Throws]
constructor(optional (sequence<sequence<USVString>> or

View File

@ -1,8 +0,0 @@
[historical.any.worker.html]
[URLSearchParams: no structured serialize/deserialize support]
expected: FAIL
[historical.any.html]
[URLSearchParams: no structured serialize/deserialize support]
expected: FAIL