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) {
#if DCHECK_IS_ON()
DCHECK_EQ(search_params_->UrlObject(), this);
#endif
search_params_->SetInput(query_string);
search_params_->SetInputWithoutUpdate(query_string);
}
} // namespace blink
......@@ -82,14 +82,13 @@ URLSearchParams* URLSearchParams::Create(const Vector<Vector<String>>& init,
}
instance->AppendWithoutUpdate(pair[0], pair[1]);
}
instance->RunUpdateSteps();
return instance;
}
URLSearchParams::URLSearchParams(const String& query_string, DOMURL* url_object)
: url_object_(url_object) {
if (!query_string.IsEmpty())
SetInput(query_string);
SetInputWithoutUpdate(query_string);
}
URLSearchParams* URLSearchParams::Create(
......@@ -100,7 +99,6 @@ URLSearchParams* URLSearchParams::Create(
return instance;
for (const auto& item : init)
instance->AppendWithoutUpdate(item.first, item.second);
instance->RunUpdateSteps();
return instance;
}
......@@ -131,7 +129,7 @@ static String DecodeString(String input) {
return DecodeURLEscapeSequences(input.Replace('+', ' '));
}
void URLSearchParams::SetInput(const String& query_string) {
void URLSearchParams::SetInputWithoutUpdate(const String& query_string) {
params_.clear();
size_t start = 0;
......@@ -157,7 +155,6 @@ void URLSearchParams::SetInput(const String& query_string) {
}
start = name_value_end + 1;
}
RunUpdateSteps();
}
String URLSearchParams::toString() const {
......
......@@ -50,7 +50,7 @@ class CORE_EXPORT URLSearchParams final : public ScriptWrappable,
bool has(const String&) const;
void set(const String& name, const String& value);
void sort();
void SetInput(const String&);
void SetInputWithoutUpdate(const String&);
// Internal helpers
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