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