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

Side by Side Diff: net/base/data_url_unittest.cc

Issue 23835019: Support URL fragment resolution againt non-hierarchical schemes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix net & webview tag tests Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "net/base/data_url.h" 6 #include "net/base/data_url.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 9
10 namespace { 10 namespace {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 "", 95 "",
96 "" }, 96 "" },
97 97
98 // invalid base64 content 98 // invalid base64 content
99 { "data:;base64,aGVs_-_-", 99 { "data:;base64,aGVs_-_-",
100 false, 100 false,
101 "", 101 "",
102 "", 102 "",
103 "" }, 103 "" },
104 104
105 // Spaces should be removed from non-text data URLs (we already tested 105 // Whitespace should be removed from non-text data URLs (we already tested
106 // spaces above). 106 // spaces above).
107 { "data:image/fractal,a b c d e f g", 107 { "data:image/fractal,a\tb\tc\td\te\tf\tg",
108 true, 108 true,
109 "image/fractal", 109 "image/fractal",
110 "US-ASCII", 110 "US-ASCII",
111 "abcdefg" }, 111 "abcdefg" },
112 112
113 // Spaces should also be removed from anything base-64 encoded 113 // Spaces should also be removed from anything base-64 encoded
114 { "data:;base64,aGVs bG8gd2 9ybGQ=", 114 { "data:;base64,aGVs bG8gd2 9ybGQ=",
115 true, 115 true,
116 "text/plain", 116 "text/plain",
117 "US-ASCII", 117 "US-ASCII",
(...skipping 11 matching lines...) Expand all
129 // http://b/1054495 129 // http://b/1054495
130 { "data:text/javascript;base64,%20ZD%20Qg%0D%0APS%20An%20Zm91cic%0D%0A%207" 130 { "data:text/javascript;base64,%20ZD%20Qg%0D%0APS%20An%20Zm91cic%0D%0A%207"
131 "%20", 131 "%20",
132 true, 132 true,
133 "text/javascript", 133 "text/javascript",
134 "US-ASCII", 134 "US-ASCII",
135 "d4 = 'four';" }, 135 "d4 = 'four';" },
136 136
137 // Only unescaped whitespace should be stripped in non-base64. 137 // Only unescaped whitespace should be stripped in non-base64.
138 // http://b/1157796 138 // http://b/1157796
139 { "data:img/png,A B %20 %0A C", 139 { "data:img/png,A\t\nB\n\r%20\t\r%0A\r\tC",
140 true, 140 true,
141 "img/png", 141 "img/png",
142 "US-ASCII", 142 "US-ASCII",
143 "AB \nC" }, 143 "AB \nC" },
144 144
145 { "data:text/plain;charset=utf-8;base64,SGVsbMO2", 145 { "data:text/plain;charset=utf-8;base64,SGVsbMO2",
146 true, 146 true,
147 "text/plain", 147 "text/plain",
148 "utf-8", 148 "utf-8",
149 "Hell\xC3\xB6" }, 149 "Hell\xC3\xB6" },
(...skipping 18 matching lines...) Expand all
168 for (size_t i = 0; i < arraysize(tests); ++i) { 168 for (size_t i = 0; i < arraysize(tests); ++i) {
169 std::string mime_type; 169 std::string mime_type;
170 std::string charset; 170 std::string charset;
171 std::string data; 171 std::string data;
172 bool ok = 172 bool ok =
173 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data); 173 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data);
174 EXPECT_EQ(ok, tests[i].is_valid); 174 EXPECT_EQ(ok, tests[i].is_valid);
175 if (tests[i].is_valid) { 175 if (tests[i].is_valid) {
176 EXPECT_EQ(tests[i].mime_type, mime_type); 176 EXPECT_EQ(tests[i].mime_type, mime_type);
177 EXPECT_EQ(tests[i].charset, charset); 177 EXPECT_EQ(tests[i].charset, charset);
178 EXPECT_EQ(tests[i].data, data); 178 EXPECT_EQ(tests[i].data, data) << i;
179 } 179 }
180 } 180 }
181 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698