| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 permissions->Set(0, Value::CreateStringValue("www.google.com")); | 209 permissions->Set(0, Value::CreateStringValue("www.google.com")); |
| 210 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 210 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); |
| 211 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission)); | 211 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission)); |
| 212 | 212 |
| 213 // Test permissions scheme. | 213 // Test permissions scheme. |
| 214 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); | 214 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
| 215 input_value->GetList(keys::kPermissions, &permissions); | 215 input_value->GetList(keys::kPermissions, &permissions); |
| 216 permissions->Set(0, Value::CreateStringValue("file:///C:/foo.txt")); | 216 permissions->Set(0, Value::CreateStringValue("file:///C:/foo.txt")); |
| 217 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); | 217 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); |
| 218 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissionScheme)); | 218 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissionScheme)); |
| 219 |
| 220 // Test invalid default locale. |
| 221 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); |
| 222 input_value->SetInteger(keys::kDefaultLocale, 42); |
| 223 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); |
| 224 EXPECT_EQ(errors::kInvalidDefaultLocale, error); |
| 219 } | 225 } |
| 220 | 226 |
| 221 TEST(ExtensionTest, InitFromValueValid) { | 227 TEST(ExtensionTest, InitFromValueValid) { |
| 222 #if defined(OS_WIN) | 228 #if defined(OS_WIN) |
| 223 FilePath path(FILE_PATH_LITERAL("C:\\foo")); | 229 FilePath path(FILE_PATH_LITERAL("C:\\foo")); |
| 224 #elif defined(OS_POSIX) | 230 #elif defined(OS_POSIX) |
| 225 FilePath path(FILE_PATH_LITERAL("/foo")); | 231 FilePath path(FILE_PATH_LITERAL("/foo")); |
| 226 #endif | 232 #endif |
| 227 Extension::ResetGeneratedIdCounter(); | 233 Extension::ResetGeneratedIdCounter(); |
| 228 | 234 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 manifest->Set(keys::kPermissions, ValueFromJSON( | 534 manifest->Set(keys::kPermissions, ValueFromJSON( |
| 529 "[\"tabs\", \"http://google.com/*\"]")); | 535 "[\"tabs\", \"http://google.com/*\"]")); |
| 530 manifest->Set(keys::kContentScripts, ValueFromJSON( | 536 manifest->Set(keys::kContentScripts, ValueFromJSON( |
| 531 "[{" | 537 "[{" |
| 532 " \"matches\": [\"http://*.google.com/*\"]," | 538 " \"matches\": [\"http://*.google.com/*\"]," |
| 533 " \"js\": [\"script.js\"]" | 539 " \"js\": [\"script.js\"]" |
| 534 "}]")); | 540 "}]")); |
| 535 EXPECT_TRUE(extension.InitFromValue(*manifest, false, &error)); | 541 EXPECT_TRUE(extension.InitFromValue(*manifest, false, &error)); |
| 536 EXPECT_EQ(Extension::PERMISSION_CLASS_FULL, extension.GetPermissionClass()); | 542 EXPECT_EQ(Extension::PERMISSION_CLASS_FULL, extension.GetPermissionClass()); |
| 537 } | 543 } |
| OLD | NEW |