Chromium Code Reviews| 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) { |