Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp

Issue 2889033002: Better header value parsing for Server-Timing. (Closed)
Patch Set: only convert duation token to string and then to double if it was parsed Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
diff --git a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
index c4b37f672c695172756405d8957f929c233b2506..d923950bf1759f5cefe55a97af105f81551b8487 100644
--- a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
+++ b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
@@ -477,18 +477,6 @@ TEST(HTTPParsersTest, ParseMultipartHeadersContentCharset) {
EXPECT_EQ("utf-8", response.TextEncodingName());
}
-TEST(HTTPParsersTest, CheckDoubleQuotedString) {
- EXPECT_EQ(CheckDoubleQuotedString(""), "");
- EXPECT_EQ(CheckDoubleQuotedString("\""), "\"");
- EXPECT_EQ(CheckDoubleQuotedString("\"\""), "");
- EXPECT_EQ(CheckDoubleQuotedString("foo"), "foo");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo"), "\"foo");
- EXPECT_EQ(CheckDoubleQuotedString("foo\""), "foo\"");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo\""), "foo");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo\"bar\""), "foo\"bar");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo\\bar\""), "foobar");
-}
-
void testServerTimingHeader(const char* headerValue,
Vector<Vector<String>> expectedResults) {
std::unique_ptr<ServerTimingHeaderVector> results =
@@ -974,6 +962,27 @@ TEST(HTTPParsersTest, ParseServerTimingHeader) {
{{"metric1", "12.3", "description1"},
{"metric2", "45.6", "description2"},
{"metric3", "78.9", "description3"}});
+
+ // quoted-string
+ testServerTimingHeader("metric;\"\"", {{"metric", "0", ""}});
+ testServerTimingHeader("metric;\"\"\"", {{"metric", "0", ""}});
+ testServerTimingHeader("metric;\"\\\"\"", {{"metric", "0", "\""}});
+ testServerTimingHeader("metric;\"\\\\\"\"", {{"metric", "0", "\\"}});
+ testServerTimingHeader("metric;\"\\\\\\\"\"", {{"metric", "0", "\\\""}});
+
+ // optional whitespace (OWS)
+ testServerTimingHeader("metric1\t=\t1", {{"metric1", "1", ""}});
+ testServerTimingHeader("metric1\t;\tdescription",
+ {{"metric1", "0", "description"}});
+ testServerTimingHeader("metric1\t,\tmetric2",
+ {{"metric1", "0", ""}, {"metric2", "0", ""}});
+ testServerTimingHeader(
+ "metric1\t;\t\"description\"\t, metric2",
+ {{"metric1", "0", "description"}, {"metric2", "0", ""}});
+ testServerTimingHeader(
+ "\tmetric1\t=\t1\t;\tdescription1\t,\tmetric2\t"
+ "=\t2\t;\tdescription2\t",
+ {{"metric1", "1", "description1"}, {"metric2", "2", "description2"}});
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698