| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "googleurl/src/gurl.h" | 6 #include "googleurl/src/gurl.h" |
| 7 #include "net/base/data_url.h" | 7 #include "net/base/data_url.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 "text/plain", | 65 "text/plain", |
| 66 "US-ASCII", | 66 "US-ASCII", |
| 67 "hello world" }, | 67 "hello world" }, |
| 68 | 68 |
| 69 { "data:foo/bar;baz=1;charset=kk,boo", | 69 { "data:foo/bar;baz=1;charset=kk,boo", |
| 70 true, | 70 true, |
| 71 "foo/bar", | 71 "foo/bar", |
| 72 "kk", | 72 "kk", |
| 73 "boo" }, | 73 "boo" }, |
| 74 | 74 |
| 75 { "data:text/html,%3Chtml%3E%3Cbody%3E%3Cb%3Ehello%20world%3C%2Fb%3E%3C%2Fbo
dy%3E%3C%2Fhtml%3E", | 75 { "data:text/html,%3Chtml%3E%3Cbody%3E%3Cb%3Ehello%20world" |
| 76 "%3C%2Fb%3E%3C%2Fbody%3E%3C%2Fhtml%3E", |
| 76 true, | 77 true, |
| 77 "text/html", | 78 "text/html", |
| 78 "US-ASCII", | 79 "US-ASCII", |
| 79 "<html><body><b>hello world</b></body></html>" }, | 80 "<html><body><b>hello world</b></body></html>" }, |
| 80 | 81 |
| 81 { "data:text/html,<html><body><b>hello world</b></body></html>", | 82 { "data:text/html,<html><body><b>hello world</b></body></html>", |
| 82 true, | 83 true, |
| 83 "text/html", | 84 "text/html", |
| 84 "US-ASCII", | 85 "US-ASCII", |
| 85 "<html><body><b>hello world</b></body></html>" }, | 86 "<html><body><b>hello world</b></body></html>" }, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 116 // Other whitespace should also be removed from anything base-64 encoded. | 117 // Other whitespace should also be removed from anything base-64 encoded. |
| 117 { "data:;base64,aGVs bG8gd2 \n9ybGQ=", | 118 { "data:;base64,aGVs bG8gd2 \n9ybGQ=", |
| 118 true, | 119 true, |
| 119 "text/plain", | 120 "text/plain", |
| 120 "US-ASCII", | 121 "US-ASCII", |
| 121 "hello world" }, | 122 "hello world" }, |
| 122 | 123 |
| 123 // In base64 encoding, escaped whitespace should be stripped. | 124 // In base64 encoding, escaped whitespace should be stripped. |
| 124 // (This test was taken from acid3) | 125 // (This test was taken from acid3) |
| 125 // http://b/1054495 | 126 // http://b/1054495 |
| 126 { "data:text/javascript;base64,%20ZD%20Qg%0D%0APS%20An%20Zm91cic%0D%0A%207%2
0", | 127 { "data:text/javascript;base64,%20ZD%20Qg%0D%0APS%20An%20Zm91cic%0D%0A%207" |
| 128 "%20", |
| 127 true, | 129 true, |
| 128 "text/javascript", | 130 "text/javascript", |
| 129 "US-ASCII", | 131 "US-ASCII", |
| 130 "d4 = 'four';" }, | 132 "d4 = 'four';" }, |
| 131 | 133 |
| 132 // Only unescaped whitespace should be stripped in non-base64. | 134 // Only unescaped whitespace should be stripped in non-base64. |
| 133 // http://b/1157796 | 135 // http://b/1157796 |
| 134 { "data:img/png,A B %20 %0A C", | 136 { "data:img/png,A B %20 %0A C", |
| 135 true, | 137 true, |
| 136 "img/png", | 138 "img/png", |
| (...skipping 11 matching lines...) Expand all Loading... |
| 148 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data); | 150 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data); |
| 149 EXPECT_EQ(ok, tests[i].is_valid); | 151 EXPECT_EQ(ok, tests[i].is_valid); |
| 150 if (tests[i].is_valid) { | 152 if (tests[i].is_valid) { |
| 151 EXPECT_EQ(tests[i].mime_type, mime_type); | 153 EXPECT_EQ(tests[i].mime_type, mime_type); |
| 152 EXPECT_EQ(tests[i].charset, charset); | 154 EXPECT_EQ(tests[i].charset, charset); |
| 153 EXPECT_EQ(tests[i].data, data); | 155 EXPECT_EQ(tests[i].data, data); |
| 154 } | 156 } |
| 155 } | 157 } |
| 156 } | 158 } |
| 157 | 159 |
| OLD | NEW |