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

Unified Diff: net/base/data_url_unittest.cc

Issue 338503006: Allow data urls to have a fragment part. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check for "data" scheme Created 6 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
« net/base/data_url.cc ('K') | « net/base/data_url.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/data_url_unittest.cc
diff --git a/net/base/data_url_unittest.cc b/net/base/data_url_unittest.cc
index 43f881f7084e86a478970ca2082e00cdbdde519d..1b4e13d8ef971eda664c5f5efcad7bac720626ed 100644
--- a/net/base/data_url_unittest.cc
+++ b/net/base/data_url_unittest.cc
@@ -169,7 +169,49 @@ TEST(DataURLTest, Parse) {
"",
"" },
- // TODO(darin): add more interesting tests
+ // Bad scheme.
+ { ":text/plain;charset=utf-8;base64,SGVsbMO2",
+ false,
+ "",
+ "",
+ "" },
+
+ // Bad scheme.
+ { ":,",
+ false,
+ "",
+ "",
+ "" },
+
+ // Fragment base64 (valid).
+ { "data:text/html;base64,PCFkb2N0eXBlIGh0bWw+PHN0eWxlPmRpdiB7IGJhY2tncm91bmQtY29sb3I6IHJlZDsgd2lkdGg6IDIwMHB4OyBoZWlnaHQ6MjAwcHg7IH0gOnRhcmdldCB7IGJhY2tncm91bmQtY29sb3I6IGdyZWVuOyB9PC9zdHlsZT48ZGl2IGlkPSd0YXJnZXQnPjwvZGl2Pg==#target",
+ true,
+ "text/html",
+ "US-ASCII",
+ "<!doctype html><style>div { background-color: red; width: 200px; height:200px; } :target { background-color: green; }</style><div id='target'></div>" },
+
+ // Fragment (valid).
+ { "data:text/html,%3C!doctype%20html%3E%3Cstyle%3Ediv%20%7B%20background-color:%20red;%20width:%20200px;%20height:200px;%20%7D%20:target%20%7B%20background-color:%20green;%20%7D%3C/style%3E%3Cdiv%20id='target'%3E%3C/div%3E#target",
+ true,
+ "text/html",
+ "US-ASCII",
+ "<!doctype html><style>div { background-color: red; width: 200px; height:200px; } :target { background-color: green; }</style><div id='target'></div>" },
+
+ // Query base64 (valid).
+ { "data:text/html;base64,PCFkb2N0eXBlIGh0bWw+PHN0eWxlPmRpdiB7IGJhY2tncm91bmQtY29sb3I6IHJlZDsgd2lkdGg6IDIwMHB4OyBoZWlnaHQ6MjAwcHg7IH0gOnRhcmdldCB7IGJhY2tncm91bmQtY29sb3I6IGdyZWVuOyB9PC9zdHlsZT48ZGl2IGlkPSd0YXJnZXQnPjwvZGl2Pg==?foo=bar",
+ true,
+ "text/html",
+ "US-ASCII",
+ "<!doctype html><style>div { background-color: red; width: 200px; height:200px; } :target { background-color: green; }</style><div id='target'></div>" },
+
+ // Query (valid).
+ { "data:text/html,%3C!doctype%20html%3E%3Cstyle%3Ediv%20%7B%20background-color:%20red;%20width:%20200px;%20height:200px;%20%7D%20:target%20%7B%20background-color:%20green;%20%7D%3C/style%3E%3Cdiv%20id='target'%3E%3C/div%3E?foo=bar",
+ true,
+ "text/html",
+ "US-ASCII",
+ "<!doctype html><style>div { background-color: red; width: 200px; height:200px; } :target { background-color: green; }</style><div id='target'></div>" },
+
asanka 2014/06/16 17:45:48 Add a test case for an percent escaped '#'.
asanka 2014/06/16 17:45:48 Would you mind going through http://greenbytes.de/
Erik Dahlström (inactive) 2014/06/17 13:10:21 Will do.
Erik Dahlström (inactive) 2014/06/17 13:10:21 Done.
+ // TODO(darin): add more interesting tests
};
for (size_t i = 0; i < arraysize(tests); ++i) {
« net/base/data_url.cc ('K') | « net/base/data_url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698