Commit 45d0c725 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

[URL] Do not run update steps when URLSearchParam is created

See https://github.com/whatwg/url/issues/350 and
https://github.com/whatwg/url/issues/18.

Bug: 776344
Change-Id: I7881add2fc5b858874da42cef7b14a9e8ee10262
Reviewed-on: https://chromium-review.googlesource.com/756537
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarTakeshi Yoshino <tyoshino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515937}
parent 545c7449
This is a testharness.js-based test.
PASS Serialize space
PASS Serialize empty value
PASS Serialize empty name
PASS Serialize empty name and value
PASS Serialize +
PASS Serialize =
PASS Serialize &
PASS Serialize *-._
PASS Serialize %
PASS Serialize \0
PASS Serialize 💩
PASS URLSearchParams.toString
FAIL URLSearchParams connected to URL assert_equals: expected "http://www.example.com/?a=b,c" but got "http://www.example.com/?a=b%2Cc"
Harness: the test ran to completion.
...@@ -111,7 +111,7 @@ void DOMURL::UpdateSearchParams(const String& query_string) { ...@@ -111,7 +111,7 @@ void DOMURL::UpdateSearchParams(const String& query_string) {
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK_EQ(search_params_->UrlObject(), this); DCHECK_EQ(search_params_->UrlObject(), this);
#endif #endif
search_params_->SetInput(query_string); search_params_->SetInputWithoutUpdate(query_string);
} }
} // namespace blink } // namespace blink
...@@ -82,14 +82,13 @@ URLSearchParams* URLSearchParams::Create(const Vector<Vector<String>>& init, ...@@ -82,14 +82,13 @@ URLSearchParams* URLSearchParams::Create(const Vector<Vector<String>>& init,
} }
instance->AppendWithoutUpdate(pair[0], pair[1]); instance->AppendWithoutUpdate(pair[0], pair[1]);
} }
instance->RunUpdateSteps();
return instance; return instance;
} }
URLSearchParams::URLSearchParams(const String& query_string, DOMURL* url_object) URLSearchParams::URLSearchParams(const String& query_string, DOMURL* url_object)
: url_object_(url_object) { : url_object_(url_object) {
if (!query_string.IsEmpty()) if (!query_string.IsEmpty())
SetInput(query_string); SetInputWithoutUpdate(query_string);
} }
URLSearchParams* URLSearchParams::Create( URLSearchParams* URLSearchParams::Create(
...@@ -100,7 +99,6 @@ URLSearchParams* URLSearchParams::Create( ...@@ -100,7 +99,6 @@ URLSearchParams* URLSearchParams::Create(
return instance; return instance;
for (const auto& item : init) for (const auto& item : init)
instance->AppendWithoutUpdate(item.first, item.second); instance->AppendWithoutUpdate(item.first, item.second);
instance->RunUpdateSteps();
return instance; return instance;
} }
...@@ -131,7 +129,7 @@ static String DecodeString(String input) { ...@@ -131,7 +129,7 @@ static String DecodeString(String input) {
return DecodeURLEscapeSequences(input.Replace('+', ' ')); return DecodeURLEscapeSequences(input.Replace('+', ' '));
} }
void URLSearchParams::SetInput(const String& query_string) { void URLSearchParams::SetInputWithoutUpdate(const String& query_string) {
params_.clear(); params_.clear();
size_t start = 0; size_t start = 0;
...@@ -157,7 +155,6 @@ void URLSearchParams::SetInput(const String& query_string) { ...@@ -157,7 +155,6 @@ void URLSearchParams::SetInput(const String& query_string) {
} }
start = name_value_end + 1; start = name_value_end + 1;
} }
RunUpdateSteps();
} }
String URLSearchParams::toString() const { String URLSearchParams::toString() const {
......
...@@ -50,7 +50,7 @@ class CORE_EXPORT URLSearchParams final : public ScriptWrappable, ...@@ -50,7 +50,7 @@ class CORE_EXPORT URLSearchParams final : public ScriptWrappable,
bool has(const String&) const; bool has(const String&) const;
void set(const String& name, const String& value); void set(const String& name, const String& value);
void sort(); void sort();
void SetInput(const String&); void SetInputWithoutUpdate(const String&);
// Internal helpers // Internal helpers
scoped_refptr<EncodedFormData> ToEncodedFormData() const; scoped_refptr<EncodedFormData> ToEncodedFormData() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment