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/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "chrome/browser/extensions/extension.h" | 7 #include "chrome/browser/extensions/extension.h" |
8 #include "chrome/browser/extensions/extension_error_reporter.h" | 8 #include "chrome/browser/extensions/extension_error_reporter.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/json_value_serializer.h" | 10 #include "chrome/common/json_value_serializer.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 .AppendASCII("good") | 31 .AppendASCII("good") |
32 .AppendASCII("extension1") | 32 .AppendASCII("extension1") |
33 .AppendASCII("1") | 33 .AppendASCII("1") |
34 .AppendASCII(Extension::kManifestFilename); | 34 .AppendASCII(Extension::kManifestFilename); |
35 | 35 |
36 JSONFileValueSerializer serializer(extensions_path); | 36 JSONFileValueSerializer serializer(extensions_path); |
37 scoped_ptr<DictionaryValue> valid_value( | 37 scoped_ptr<DictionaryValue> valid_value( |
38 static_cast<DictionaryValue*>(serializer.Deserialize(&error))); | 38 static_cast<DictionaryValue*>(serializer.Deserialize(&error))); |
39 ASSERT_TRUE(valid_value.get()); | 39 ASSERT_TRUE(valid_value.get()); |
40 ASSERT_EQ("", error); | 40 ASSERT_EQ("", error); |
41 ASSERT_TRUE(extension.InitFromValue(*valid_value, true, &error)); | 41 ASSERT_TRUE(extension.InitFromValue(*valid_value, &error)); |
42 ASSERT_EQ("", error); | 42 ASSERT_EQ("", error); |
43 | 43 |
44 scoped_ptr<DictionaryValue> input_value; | 44 scoped_ptr<DictionaryValue> input_value; |
45 | 45 |
46 // Test missing and invalid ids | 46 // Test missing and invalid ids |
47 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 47 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
48 input_value->Remove(Extension::kIdKey, NULL); | |
49 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | |
50 EXPECT_EQ(Extension::kInvalidIdError, error); | |
51 | |
52 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | |
53 input_value->SetInteger(Extension::kIdKey, 42); | 48 input_value->SetInteger(Extension::kIdKey, 42); |
54 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 49 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
55 EXPECT_EQ(Extension::kInvalidIdError, error); | 50 EXPECT_EQ(Extension::kInvalidIdError, error); |
56 | 51 |
57 // Test missing and invalid versions | 52 // Test missing and invalid versions |
58 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 53 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
59 input_value->Remove(Extension::kVersionKey, NULL); | 54 input_value->Remove(Extension::kVersionKey, NULL); |
60 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 55 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
61 EXPECT_EQ(Extension::kInvalidVersionError, error); | 56 EXPECT_EQ(Extension::kInvalidVersionError, error); |
62 | 57 |
63 input_value->SetInteger(Extension::kVersionKey, 42); | 58 input_value->SetInteger(Extension::kVersionKey, 42); |
64 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 59 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
65 EXPECT_EQ(Extension::kInvalidVersionError, error); | 60 EXPECT_EQ(Extension::kInvalidVersionError, error); |
66 | 61 |
67 // Test missing and invalid names | 62 // Test missing and invalid names |
68 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 63 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
69 input_value->Remove(Extension::kNameKey, NULL); | 64 input_value->Remove(Extension::kNameKey, NULL); |
70 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 65 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
71 EXPECT_EQ(Extension::kInvalidNameError, error); | 66 EXPECT_EQ(Extension::kInvalidNameError, error); |
72 | 67 |
73 input_value->SetInteger(Extension::kNameKey, 42); | 68 input_value->SetInteger(Extension::kNameKey, 42); |
74 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 69 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
75 EXPECT_EQ(Extension::kInvalidNameError, error); | 70 EXPECT_EQ(Extension::kInvalidNameError, error); |
76 | 71 |
77 // Test invalid description | 72 // Test invalid description |
78 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 73 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
79 input_value->SetInteger(Extension::kDescriptionKey, 42); | 74 input_value->SetInteger(Extension::kDescriptionKey, 42); |
80 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 75 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
81 EXPECT_EQ(Extension::kInvalidDescriptionError, error); | 76 EXPECT_EQ(Extension::kInvalidDescriptionError, error); |
82 | 77 |
83 // Test invalid user scripts list | 78 // Test invalid user scripts list |
84 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 79 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
85 input_value->SetInteger(Extension::kContentScriptsKey, 42); | 80 input_value->SetInteger(Extension::kContentScriptsKey, 42); |
86 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 81 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
87 EXPECT_EQ(Extension::kInvalidContentScriptsListError, error); | 82 EXPECT_EQ(Extension::kInvalidContentScriptsListError, error); |
88 | 83 |
89 // Test invalid user script item | 84 // Test invalid user script item |
90 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 85 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
91 ListValue* content_scripts = NULL; | 86 ListValue* content_scripts = NULL; |
92 input_value->GetList(Extension::kContentScriptsKey, &content_scripts); | 87 input_value->GetList(Extension::kContentScriptsKey, &content_scripts); |
93 ASSERT_FALSE(NULL == content_scripts); | 88 ASSERT_FALSE(NULL == content_scripts); |
94 content_scripts->Set(0, Value::CreateIntegerValue(42)); | 89 content_scripts->Set(0, Value::CreateIntegerValue(42)); |
95 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 90 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
96 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidContentScriptError)); | 91 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidContentScriptError)); |
97 | 92 |
98 // Test missing and invalid matches array | 93 // Test missing and invalid matches array |
99 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 94 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
100 input_value->GetList(Extension::kContentScriptsKey, &content_scripts); | 95 input_value->GetList(Extension::kContentScriptsKey, &content_scripts); |
101 DictionaryValue* user_script = NULL; | 96 DictionaryValue* user_script = NULL; |
102 content_scripts->GetDictionary(0, &user_script); | 97 content_scripts->GetDictionary(0, &user_script); |
103 user_script->Remove(Extension::kMatchesKey, NULL); | 98 user_script->Remove(Extension::kMatchesKey, NULL); |
104 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 99 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
105 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); | 100 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); |
106 | 101 |
107 user_script->Set(Extension::kMatchesKey, Value::CreateIntegerValue(42)); | 102 user_script->Set(Extension::kMatchesKey, Value::CreateIntegerValue(42)); |
108 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 103 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
109 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); | 104 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); |
110 | 105 |
111 ListValue* matches = new ListValue; | 106 ListValue* matches = new ListValue; |
112 user_script->Set(Extension::kMatchesKey, matches); | 107 user_script->Set(Extension::kMatchesKey, matches); |
113 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 108 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
114 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchCountError)); | 109 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchCountError)); |
115 | 110 |
116 // Test invalid match element | 111 // Test invalid match element |
117 matches->Set(0, Value::CreateIntegerValue(42)); | 112 matches->Set(0, Value::CreateIntegerValue(42)); |
118 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 113 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
119 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchError)); | 114 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchError)); |
120 | 115 |
121 // Test missing and invalid files array | 116 // Test missing and invalid files array |
122 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 117 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
123 input_value->GetList(Extension::kContentScriptsKey, &content_scripts); | 118 input_value->GetList(Extension::kContentScriptsKey, &content_scripts); |
124 content_scripts->GetDictionary(0, &user_script); | 119 content_scripts->GetDictionary(0, &user_script); |
125 user_script->Remove(Extension::kJsKey, NULL); | 120 user_script->Remove(Extension::kJsKey, NULL); |
126 user_script->Remove(Extension::kCssKey, NULL); | 121 user_script->Remove(Extension::kCssKey, NULL); |
127 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 122 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
128 EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); | 123 EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); |
129 | 124 |
130 user_script->Set(Extension::kJsKey, Value::CreateIntegerValue(42)); | 125 user_script->Set(Extension::kJsKey, Value::CreateIntegerValue(42)); |
131 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 126 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
132 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError)); | 127 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError)); |
133 | 128 |
134 user_script->Set(Extension::kCssKey, new ListValue); | 129 user_script->Set(Extension::kCssKey, new ListValue); |
135 user_script->Set(Extension::kJsKey, new ListValue); | 130 user_script->Set(Extension::kJsKey, new ListValue); |
136 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 131 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
137 EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); | 132 EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); |
138 user_script->Remove(Extension::kCssKey, NULL); | 133 user_script->Remove(Extension::kCssKey, NULL); |
139 | 134 |
140 ListValue* files = new ListValue; | 135 ListValue* files = new ListValue; |
141 user_script->Set(Extension::kJsKey, files); | 136 user_script->Set(Extension::kJsKey, files); |
142 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 137 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
143 EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); | 138 EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); |
144 | 139 |
145 // Test invalid file element | 140 // Test invalid file element |
146 files->Set(0, Value::CreateIntegerValue(42)); | 141 files->Set(0, Value::CreateIntegerValue(42)); |
147 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 142 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
148 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsError)); | 143 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsError)); |
149 | 144 |
150 user_script->Remove(Extension::kJsKey, NULL); | 145 user_script->Remove(Extension::kJsKey, NULL); |
151 // Test the css element | 146 // Test the css element |
152 user_script->Set(Extension::kCssKey, Value::CreateIntegerValue(42)); | 147 user_script->Set(Extension::kCssKey, Value::CreateIntegerValue(42)); |
153 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 148 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
154 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidCssListError)); | 149 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidCssListError)); |
155 | 150 |
156 // Test invalid file element | 151 // Test invalid file element |
157 ListValue* css_files = new ListValue; | 152 ListValue* css_files = new ListValue; |
158 user_script->Set(Extension::kCssKey, css_files); | 153 user_script->Set(Extension::kCssKey, css_files); |
159 css_files->Set(0, Value::CreateIntegerValue(42)); | 154 css_files->Set(0, Value::CreateIntegerValue(42)); |
160 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 155 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
161 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidCssError)); | 156 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidCssError)); |
162 | 157 |
163 // Test missing and invalid permissions array | 158 // Test missing and invalid permissions array |
164 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 159 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
165 EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error)); | 160 EXPECT_TRUE(extension.InitFromValue(*input_value, &error)); |
166 ListValue* permissions = NULL; | 161 ListValue* permissions = NULL; |
167 input_value->GetList(Extension::kPermissionsKey, &permissions); | 162 input_value->GetList(Extension::kPermissionsKey, &permissions); |
168 ASSERT_FALSE(NULL == permissions); | 163 ASSERT_FALSE(NULL == permissions); |
169 | 164 |
170 permissions = new ListValue; | 165 permissions = new ListValue; |
171 input_value->Set(Extension::kPermissionsKey, permissions); | 166 input_value->Set(Extension::kPermissionsKey, permissions); |
172 EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error)); | 167 EXPECT_TRUE(extension.InitFromValue(*input_value, &error)); |
173 const std::vector<std::string>* error_vector = | 168 const std::vector<std::string>* error_vector = |
174 ExtensionErrorReporter::GetInstance()->GetErrors(); | 169 ExtensionErrorReporter::GetInstance()->GetErrors(); |
175 const std::string log_error = error_vector->at(error_vector->size() - 1); | 170 const std::string log_error = error_vector->at(error_vector->size() - 1); |
176 EXPECT_TRUE(MatchPattern(log_error, | 171 EXPECT_TRUE(MatchPattern(log_error, |
177 Extension::kInvalidPermissionCountWarning)); | 172 Extension::kInvalidPermissionCountWarning)); |
178 | 173 |
179 input_value->Set(Extension::kPermissionsKey, Value::CreateIntegerValue(9)); | 174 input_value->Set(Extension::kPermissionsKey, Value::CreateIntegerValue(9)); |
180 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 175 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
181 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionsError)); | 176 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionsError)); |
182 | 177 |
183 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 178 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
184 input_value->GetList(Extension::kPermissionsKey, &permissions); | 179 input_value->GetList(Extension::kPermissionsKey, &permissions); |
185 permissions->Set(0, Value::CreateIntegerValue(24)); | 180 permissions->Set(0, Value::CreateIntegerValue(24)); |
186 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 181 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
187 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionError)); | 182 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionError)); |
188 | 183 |
189 permissions->Set(0, Value::CreateStringValue("www.google.com")); | 184 permissions->Set(0, Value::CreateStringValue("www.google.com")); |
190 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 185 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
191 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionError)); | 186 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionError)); |
192 | 187 |
193 // Test permissions scheme. | 188 // Test permissions scheme. |
194 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 189 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
195 input_value->GetList(Extension::kPermissionsKey, &permissions); | 190 input_value->GetList(Extension::kPermissionsKey, &permissions); |
196 permissions->Set(0, Value::CreateStringValue("file:///C:/foo.txt")); | 191 permissions->Set(0, Value::CreateStringValue("file:///C:/foo.txt")); |
197 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 192 EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); |
198 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionSchemeError)); | 193 EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionSchemeError)); |
199 } | 194 } |
200 | 195 |
201 TEST(ExtensionTest, InitFromValueValid) { | 196 TEST(ExtensionTest, InitFromValueValid) { |
202 #if defined(OS_WIN) | 197 #if defined(OS_WIN) |
203 FilePath path(FILE_PATH_LITERAL("C:\\foo")); | 198 FilePath path(FILE_PATH_LITERAL("C:\\foo")); |
204 #elif defined(OS_POSIX) | 199 #elif defined(OS_POSIX) |
205 FilePath path(FILE_PATH_LITERAL("/foo")); | 200 FilePath path(FILE_PATH_LITERAL("/foo")); |
206 #endif | 201 #endif |
207 Extension extension(path); | 202 Extension extension(path); |
208 std::string error; | 203 std::string error; |
209 DictionaryValue input_value; | 204 DictionaryValue input_value; |
210 | 205 |
211 // Test minimal extension | 206 // Test minimal extension |
212 input_value.SetString(Extension::kIdKey, | 207 input_value.SetString(Extension::kIdKey, |
213 "00123456789ABCDEF0123456789ABCDEF0123456"); | 208 "00123456789ABCDEF0123456789ABCDEF0123456"); |
214 input_value.SetString(Extension::kVersionKey, "1.0.0.0"); | 209 input_value.SetString(Extension::kVersionKey, "1.0.0.0"); |
215 input_value.SetString(Extension::kNameKey, "my extension"); | 210 input_value.SetString(Extension::kNameKey, "my extension"); |
216 | 211 |
217 EXPECT_TRUE(extension.InitFromValue(input_value, true, &error)); | 212 EXPECT_TRUE(extension.InitFromValue(input_value, &error)); |
218 EXPECT_EQ("", error); | 213 EXPECT_EQ("", error); |
219 EXPECT_EQ("00123456789abcdef0123456789abcdef0123456", extension.id()); | 214 EXPECT_EQ("00123456789abcdef0123456789abcdef0123456", extension.id()); |
220 EXPECT_EQ("1.0.0.0", extension.VersionString()); | 215 EXPECT_EQ("1.0.0.0", extension.VersionString()); |
221 EXPECT_EQ("my extension", extension.name()); | 216 EXPECT_EQ("my extension", extension.name()); |
222 EXPECT_EQ("chrome-extension://00123456789abcdef0123456789abcdef0123456/", | 217 EXPECT_EQ("chrome-extension://00123456789abcdef0123456789abcdef0123456/", |
223 extension.url().spec()); | 218 extension.url().spec()); |
224 EXPECT_EQ(path.value(), extension.path().value()); | 219 EXPECT_EQ(path.value(), extension.path().value()); |
225 } | 220 } |
226 | 221 |
227 TEST(ExtensionTest, GetResourceURLAndPath) { | 222 TEST(ExtensionTest, GetResourceURLAndPath) { |
228 #if defined(OS_WIN) | 223 #if defined(OS_WIN) |
229 FilePath path(FILE_PATH_LITERAL("C:\\foo")); | 224 FilePath path(FILE_PATH_LITERAL("C:\\foo")); |
230 #elif defined(OS_POSIX) | 225 #elif defined(OS_POSIX) |
231 FilePath path(FILE_PATH_LITERAL("/foo")); | 226 FilePath path(FILE_PATH_LITERAL("/foo")); |
232 #endif | 227 #endif |
233 Extension extension(path); | 228 Extension extension(path); |
234 DictionaryValue input_value; | 229 DictionaryValue input_value; |
235 input_value.SetString(Extension::kIdKey, | 230 input_value.SetString(Extension::kIdKey, |
236 "00123456789ABCDEF0123456789ABCDEF0123456"); | 231 "00123456789ABCDEF0123456789ABCDEF0123456"); |
237 input_value.SetString(Extension::kVersionKey, "1.0.0.0"); | 232 input_value.SetString(Extension::kVersionKey, "1.0.0.0"); |
238 input_value.SetString(Extension::kNameKey, "my extension"); | 233 input_value.SetString(Extension::kNameKey, "my extension"); |
239 EXPECT_TRUE(extension.InitFromValue(input_value, true, NULL)); | 234 EXPECT_TRUE(extension.InitFromValue(input_value, NULL)); |
240 | 235 |
241 EXPECT_EQ(extension.url().spec() + "bar/baz.js", | 236 EXPECT_EQ(extension.url().spec() + "bar/baz.js", |
242 Extension::GetResourceURL(extension.url(), "bar/baz.js").spec()); | 237 Extension::GetResourceURL(extension.url(), "bar/baz.js").spec()); |
243 EXPECT_EQ(extension.url().spec() + "baz.js", | 238 EXPECT_EQ(extension.url().spec() + "baz.js", |
244 Extension::GetResourceURL(extension.url(), "bar/../baz.js").spec()); | 239 Extension::GetResourceURL(extension.url(), "bar/../baz.js").spec()); |
245 EXPECT_EQ(extension.url().spec() + "baz.js", | 240 EXPECT_EQ(extension.url().spec() + "baz.js", |
246 Extension::GetResourceURL(extension.url(), "../baz.js").spec()); | 241 Extension::GetResourceURL(extension.url(), "../baz.js").spec()); |
247 | 242 |
248 EXPECT_EQ(path.Append(FILE_PATH_LITERAL("bar")) | 243 EXPECT_EQ(path.Append(FILE_PATH_LITERAL("bar")) |
249 .Append(FILE_PATH_LITERAL("baz.js")).value(), | 244 .Append(FILE_PATH_LITERAL("baz.js")).value(), |
250 Extension::GetResourcePath(extension.path(), "bar/baz.js").value()); | 245 Extension::GetResourcePath(extension.path(), "bar/baz.js").value()); |
251 EXPECT_EQ(path.Append(FILE_PATH_LITERAL("baz.js")).value(), | 246 EXPECT_EQ(path.Append(FILE_PATH_LITERAL("baz.js")).value(), |
252 Extension::GetResourcePath(extension.path(), "bar/../baz.js") | 247 Extension::GetResourcePath(extension.path(), "bar/../baz.js") |
253 .value()); | 248 .value()); |
254 EXPECT_EQ(FilePath().value(), | 249 EXPECT_EQ(FilePath().value(), |
255 Extension::GetResourcePath(extension.path(), "../baz.js").value()); | 250 Extension::GetResourcePath(extension.path(), "../baz.js").value()); |
256 } | 251 } |
OLD | NEW |