From cd0e94ceb1031a76dc8e9f70bb9cdab691fb8866 Mon Sep 17 00:00:00 2001 From: JustOff Date: Wed, 13 Mar 2019 21:22:29 +0200 Subject: Construct URLSearchParams from record<> --- dom/url/URLSearchParams.cpp | 8 +++++++- dom/url/URLSearchParams.h | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'dom/url') diff --git a/dom/url/URLSearchParams.cpp b/dom/url/URLSearchParams.cpp index 8303272e17..ad23460f38 100644 --- a/dom/url/URLSearchParams.cpp +++ b/dom/url/URLSearchParams.cpp @@ -327,7 +327,7 @@ URLSearchParams::WrapObject(JSContext* aCx, JS::Handle aGivenProto) /* static */ already_AddRefed URLSearchParams::Constructor(const GlobalObject& aGlobal, - const USVStringSequenceSequenceOrUSVString& aInit, + const USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString& aInit, ErrorResult& aRv) { RefPtr sp = @@ -351,6 +351,12 @@ URLSearchParams::Constructor(const GlobalObject& aGlobal, } sp->Append(item[0], item[1]); } + } else if (aInit.IsUSVStringUSVStringRecord()) { + const Record& record = + aInit.GetAsUSVStringUSVStringRecord(); + for (auto& entry : record.Entries()) { + sp->Append(entry.mKey, entry.mValue); + } } else { MOZ_CRASH("This should not happen."); } diff --git a/dom/url/URLSearchParams.h b/dom/url/URLSearchParams.h index 5eef1b1a95..9fefd78dde 100644 --- a/dom/url/URLSearchParams.h +++ b/dom/url/URLSearchParams.h @@ -20,7 +20,7 @@ namespace mozilla { namespace dom { class URLSearchParams; -class USVStringSequenceSequenceOrUSVString; +class USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString; class URLSearchParamsObserver : public nsISupports { @@ -148,7 +148,7 @@ public: static already_AddRefed Constructor(const GlobalObject& aGlobal, - const USVStringSequenceSequenceOrUSVString& aInit, + const USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString& aInit, ErrorResult& aRv); void ParseInput(const nsACString& aInput); -- cgit v1.2.3