OLD | NEW |
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 "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/extensions/api/commands/commands_handler.h" | 16 #include "chrome/common/extensions/api/commands/commands_handler.h" |
17 #include "chrome/common/extensions/api/extension_action/action_info.h" | 17 #include "chrome/common/extensions/api/extension_action/action_info.h" |
18 #include "chrome/common/extensions/command.h" | 18 #include "chrome/common/extensions/command.h" |
19 #include "chrome/common/extensions/extension_file_util.h" | 19 #include "chrome/common/extensions/extension_file_util.h" |
20 #include "chrome/common/extensions/extension_manifest_constants.h" | 20 #include "chrome/common/extensions/extension_manifest_constants.h" |
21 #include "chrome/common/extensions/extension_resource.h" | 21 #include "chrome/common/extensions/extension_resource.h" |
22 #include "chrome/common/extensions/features/feature.h" | 22 #include "chrome/common/extensions/features/feature.h" |
| 23 #include "chrome/common/extensions/manifest.h" |
23 #include "chrome/common/extensions/manifest_handler.h" | 24 #include "chrome/common/extensions/manifest_handler.h" |
24 #include "chrome/common/extensions/permissions/api_permission.h" | 25 #include "chrome/common/extensions/permissions/api_permission.h" |
25 #include "chrome/common/extensions/permissions/permission_set.h" | 26 #include "chrome/common/extensions/permissions/permission_set.h" |
26 #include "chrome/common/extensions/permissions/socket_permission.h" | 27 #include "chrome/common/extensions/permissions/socket_permission.h" |
27 #include "chrome/common/extensions/permissions/usb_device_permission.h" | 28 #include "chrome/common/extensions/permissions/usb_device_permission.h" |
28 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
29 #include "extensions/common/error_utils.h" | 30 #include "extensions/common/error_utils.h" |
30 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
31 #include "net/base/mime_sniffer.h" | 32 #include "net/base/mime_sniffer.h" |
32 #include "net/base/mock_host_resolver.h" | 33 #include "net/base/mock_host_resolver.h" |
33 #include "skia/ext/image_operations.h" | 34 #include "skia/ext/image_operations.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
35 #include "third_party/skia/include/core/SkBitmap.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
36 #include "ui/gfx/codec/png_codec.h" | 37 #include "ui/gfx/codec/png_codec.h" |
37 | 38 |
38 using content::SocketPermissionRequest; | 39 using content::SocketPermissionRequest; |
39 | 40 |
40 namespace keys = extension_manifest_keys; | 41 namespace keys = extension_manifest_keys; |
41 namespace values = extension_manifest_values; | 42 namespace values = extension_manifest_values; |
42 namespace errors = extension_manifest_errors; | 43 namespace errors = extension_manifest_errors; |
43 | 44 |
44 namespace extensions { | 45 namespace extensions { |
45 namespace { | 46 namespace { |
46 | 47 |
47 scoped_refptr<Extension> LoadManifestUnchecked( | 48 scoped_refptr<Extension> LoadManifestUnchecked( |
48 const std::string& dir, | 49 const std::string& dir, |
49 const std::string& test_file, | 50 const std::string& test_file, |
50 Extension::Location location, | 51 Manifest::Location location, |
51 int extra_flags, | 52 int extra_flags, |
52 std::string* error) { | 53 std::string* error) { |
53 FilePath path; | 54 FilePath path; |
54 PathService::Get(chrome::DIR_TEST_DATA, &path); | 55 PathService::Get(chrome::DIR_TEST_DATA, &path); |
55 path = path.AppendASCII("extensions") | 56 path = path.AppendASCII("extensions") |
56 .AppendASCII(dir) | 57 .AppendASCII(dir) |
57 .AppendASCII(test_file); | 58 .AppendASCII(test_file); |
58 | 59 |
59 JSONFileValueSerializer serializer(path); | 60 JSONFileValueSerializer serializer(path); |
60 scoped_ptr<Value> result(serializer.Deserialize(NULL, error)); | 61 scoped_ptr<Value> result(serializer.Deserialize(NULL, error)); |
61 if (!result.get()) | 62 if (!result.get()) |
62 return NULL; | 63 return NULL; |
63 | 64 |
64 scoped_refptr<Extension> extension = Extension::Create( | 65 scoped_refptr<Extension> extension = Extension::Create( |
65 path.DirName(), location, *static_cast<DictionaryValue*>(result.get()), | 66 path.DirName(), location, *static_cast<DictionaryValue*>(result.get()), |
66 extra_flags, error); | 67 extra_flags, error); |
67 return extension; | 68 return extension; |
68 } | 69 } |
69 | 70 |
70 static scoped_refptr<Extension> LoadManifest(const std::string& dir, | 71 static scoped_refptr<Extension> LoadManifest(const std::string& dir, |
71 const std::string& test_file, | 72 const std::string& test_file, |
72 Extension::Location location, | 73 Manifest::Location location, |
73 int extra_flags) { | 74 int extra_flags) { |
74 std::string error; | 75 std::string error; |
75 scoped_refptr<Extension> extension = LoadManifestUnchecked(dir, test_file, | 76 scoped_refptr<Extension> extension = LoadManifestUnchecked(dir, test_file, |
76 location, extra_flags, &error); | 77 location, extra_flags, &error); |
77 | 78 |
78 EXPECT_TRUE(extension) << test_file << ":" << error; | 79 EXPECT_TRUE(extension) << test_file << ":" << error; |
79 return extension; | 80 return extension; |
80 } | 81 } |
81 | 82 |
82 static scoped_refptr<Extension> LoadManifest(const std::string& dir, | 83 static scoped_refptr<Extension> LoadManifest(const std::string& dir, |
83 const std::string& test_file, | 84 const std::string& test_file, |
84 int extra_flags) { | 85 int extra_flags) { |
85 return LoadManifest(dir, test_file, Extension::INVALID, extra_flags); | 86 return LoadManifest(dir, test_file, Manifest::INVALID_LOCATION, extra_flags); |
86 } | 87 } |
87 | 88 |
88 static scoped_refptr<Extension> LoadManifest(const std::string& dir, | 89 static scoped_refptr<Extension> LoadManifest(const std::string& dir, |
89 const std::string& test_file) { | 90 const std::string& test_file) { |
90 return LoadManifest(dir, test_file, Extension::NO_FLAGS); | 91 return LoadManifest(dir, test_file, Extension::NO_FLAGS); |
91 } | 92 } |
92 | 93 |
93 static scoped_refptr<Extension> LoadManifestStrict( | 94 static scoped_refptr<Extension> LoadManifestStrict( |
94 const std::string& dir, | 95 const std::string& dir, |
95 const std::string& test_file) { | 96 const std::string& test_file) { |
(...skipping 11 matching lines...) Expand all Loading... |
107 } | 108 } |
108 ADD_FAILURE() << "Expected manifest in " << manifest | 109 ADD_FAILURE() << "Expected manifest in " << manifest |
109 << " to include a page_action section."; | 110 << " to include a page_action section."; |
110 return scoped_ptr<ActionInfo>(); | 111 return scoped_ptr<ActionInfo>(); |
111 } | 112 } |
112 | 113 |
113 static void LoadActionAndExpectError(const std::string& manifest, | 114 static void LoadActionAndExpectError(const std::string& manifest, |
114 const std::string& expected_error) { | 115 const std::string& expected_error) { |
115 std::string error; | 116 std::string error; |
116 scoped_refptr<Extension> extension = LoadManifestUnchecked("page_action", | 117 scoped_refptr<Extension> extension = LoadManifestUnchecked("page_action", |
117 manifest, Extension::INTERNAL, Extension::NO_FLAGS, &error); | 118 manifest, Manifest::INTERNAL, Extension::NO_FLAGS, &error); |
118 EXPECT_FALSE(extension); | 119 EXPECT_FALSE(extension); |
119 EXPECT_EQ(expected_error, error); | 120 EXPECT_EQ(expected_error, error); |
120 } | 121 } |
121 | 122 |
122 } | 123 } |
123 | 124 |
124 class ExtensionTest : public testing::Test { | 125 class ExtensionTest : public testing::Test { |
125 protected: | 126 protected: |
126 virtual void SetUp() OVERRIDE { | 127 virtual void SetUp() OVERRIDE { |
127 ManifestHandler::Register(extension_manifest_keys::kCommands, | 128 ManifestHandler::Register(extension_manifest_keys::kCommands, |
128 new CommandsHandler); | 129 new CommandsHandler); |
129 } | 130 } |
130 }; | 131 }; |
131 | 132 |
132 // We persist location values in the preferences, so this is a sanity test that | 133 // We persist location values in the preferences, so this is a sanity test that |
133 // someone doesn't accidentally change them. | 134 // someone doesn't accidentally change them. |
134 TEST_F(ExtensionTest, LocationValuesTest) { | 135 TEST_F(ExtensionTest, LocationValuesTest) { |
135 ASSERT_EQ(0, Extension::INVALID); | 136 ASSERT_EQ(0, Manifest::INVALID_LOCATION); |
136 ASSERT_EQ(1, Extension::INTERNAL); | 137 ASSERT_EQ(1, Manifest::INTERNAL); |
137 ASSERT_EQ(2, Extension::EXTERNAL_PREF); | 138 ASSERT_EQ(2, Manifest::EXTERNAL_PREF); |
138 ASSERT_EQ(3, Extension::EXTERNAL_REGISTRY); | 139 ASSERT_EQ(3, Manifest::EXTERNAL_REGISTRY); |
139 ASSERT_EQ(4, Extension::LOAD); | 140 ASSERT_EQ(4, Manifest::LOAD); |
140 ASSERT_EQ(5, Extension::COMPONENT); | 141 ASSERT_EQ(5, Manifest::COMPONENT); |
141 ASSERT_EQ(6, Extension::EXTERNAL_PREF_DOWNLOAD); | 142 ASSERT_EQ(6, Manifest::EXTERNAL_PREF_DOWNLOAD); |
142 ASSERT_EQ(7, Extension::EXTERNAL_POLICY_DOWNLOAD); | 143 ASSERT_EQ(7, Manifest::EXTERNAL_POLICY_DOWNLOAD); |
143 } | 144 } |
144 | 145 |
145 TEST_F(ExtensionTest, LocationPriorityTest) { | 146 TEST_F(ExtensionTest, LocationPriorityTest) { |
146 for (int i = 0; i < Extension::NUM_LOCATIONS; i++) { | 147 for (int i = 0; i < Manifest::NUM_LOCATIONS; i++) { |
147 Extension::Location loc = static_cast<Extension::Location>(i); | 148 Manifest::Location loc = static_cast<Manifest::Location>(i); |
148 | 149 |
149 // INVALID is not a valid location. | 150 // INVALID is not a valid location. |
150 if (loc == Extension::INVALID) | 151 if (loc == Manifest::INVALID_LOCATION) |
151 continue; | 152 continue; |
152 | 153 |
153 // Comparing a location that has no rank will hit a CHECK. Do a | 154 // Comparing a location that has no rank will hit a CHECK. Do a |
154 // compare with every valid location, to be sure each one is covered. | 155 // compare with every valid location, to be sure each one is covered. |
155 | 156 |
156 // Check that no install source can override a componenet extension. | 157 // Check that no install source can override a componenet extension. |
157 ASSERT_EQ(Extension::COMPONENT, | 158 ASSERT_EQ(Manifest::COMPONENT, |
158 Extension::GetHigherPriorityLocation(Extension::COMPONENT, loc)); | 159 Manifest::GetHigherPriorityLocation(Manifest::COMPONENT, loc)); |
159 ASSERT_EQ(Extension::COMPONENT, | 160 ASSERT_EQ(Manifest::COMPONENT, |
160 Extension::GetHigherPriorityLocation(loc, Extension::COMPONENT)); | 161 Manifest::GetHigherPriorityLocation(loc, Manifest::COMPONENT)); |
161 | 162 |
162 // Check that any source can override a user install. This might change | 163 // Check that any source can override a user install. This might change |
163 // in the future, in which case this test should be updated. | 164 // in the future, in which case this test should be updated. |
164 ASSERT_EQ(loc, | 165 ASSERT_EQ(loc, |
165 Extension::GetHigherPriorityLocation(Extension::INTERNAL, loc)); | 166 Manifest::GetHigherPriorityLocation(Manifest::INTERNAL, loc)); |
166 ASSERT_EQ(loc, | 167 ASSERT_EQ(loc, |
167 Extension::GetHigherPriorityLocation(loc, Extension::INTERNAL)); | 168 Manifest::GetHigherPriorityLocation(loc, Manifest::INTERNAL)); |
168 } | 169 } |
169 | 170 |
170 // Check a few interesting cases that we know can happen: | 171 // Check a few interesting cases that we know can happen: |
171 ASSERT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, | 172 ASSERT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, |
172 Extension::GetHigherPriorityLocation( | 173 Manifest::GetHigherPriorityLocation( |
173 Extension::EXTERNAL_POLICY_DOWNLOAD, | 174 Manifest::EXTERNAL_POLICY_DOWNLOAD, |
174 Extension::EXTERNAL_PREF)); | 175 Manifest::EXTERNAL_PREF)); |
175 | 176 |
176 ASSERT_EQ(Extension::EXTERNAL_PREF, | 177 ASSERT_EQ(Manifest::EXTERNAL_PREF, |
177 Extension::GetHigherPriorityLocation( | 178 Manifest::GetHigherPriorityLocation( |
178 Extension::INTERNAL, | 179 Manifest::INTERNAL, |
179 Extension::EXTERNAL_PREF)); | 180 Manifest::EXTERNAL_PREF)); |
180 } | 181 } |
181 | 182 |
182 TEST_F(ExtensionTest, GetResourceURLAndPath) { | 183 TEST_F(ExtensionTest, GetResourceURLAndPath) { |
183 scoped_refptr<Extension> extension = LoadManifestStrict("empty_manifest", | 184 scoped_refptr<Extension> extension = LoadManifestStrict("empty_manifest", |
184 "empty.json"); | 185 "empty.json"); |
185 EXPECT_TRUE(extension.get()); | 186 EXPECT_TRUE(extension.get()); |
186 | 187 |
187 EXPECT_EQ(extension->url().spec() + "bar/baz.js", | 188 EXPECT_EQ(extension->url().spec() + "bar/baz.js", |
188 Extension::GetResourceURL(extension->url(), "bar/baz.js").spec()); | 189 Extension::GetResourceURL(extension->url(), "bar/baz.js").spec()); |
189 EXPECT_EQ(extension->url().spec() + "baz.js", | 190 EXPECT_EQ(extension->url().spec() + "baz.js", |
190 Extension::GetResourceURL(extension->url(), | 191 Extension::GetResourceURL(extension->url(), |
191 "bar/../baz.js").spec()); | 192 "bar/../baz.js").spec()); |
192 EXPECT_EQ(extension->url().spec() + "baz.js", | 193 EXPECT_EQ(extension->url().spec() + "baz.js", |
193 Extension::GetResourceURL(extension->url(), "../baz.js").spec()); | 194 Extension::GetResourceURL(extension->url(), "../baz.js").spec()); |
194 | 195 |
195 // Test that absolute-looking paths ("/"-prefixed) are pasted correctly. | 196 // Test that absolute-looking paths ("/"-prefixed) are pasted correctly. |
196 EXPECT_EQ(extension->url().spec() + "test.html", | 197 EXPECT_EQ(extension->url().spec() + "test.html", |
197 extension->GetResourceURL("/test.html").spec()); | 198 extension->GetResourceURL("/test.html").spec()); |
198 } | 199 } |
199 | 200 |
200 TEST_F(ExtensionTest, GetAbsolutePathNoError) { | 201 TEST_F(ExtensionTest, GetAbsolutePathNoError) { |
201 scoped_refptr<Extension> extension = LoadManifestStrict("absolute_path", | 202 scoped_refptr<Extension> extension = LoadManifestStrict("absolute_path", |
202 "absolute.json"); | 203 "absolute.json"); |
203 EXPECT_TRUE(extension.get()); | 204 EXPECT_TRUE(extension.get()); |
204 std::string err; | 205 std::string err; |
205 Extension::InstallWarningVector warnings; | 206 std::vector<InstallWarning> warnings; |
206 EXPECT_TRUE(extension_file_util::ValidateExtension(extension.get(), | 207 EXPECT_TRUE(extension_file_util::ValidateExtension(extension.get(), |
207 &err, &warnings)); | 208 &err, &warnings)); |
208 EXPECT_EQ(0U, warnings.size()); | 209 EXPECT_EQ(0U, warnings.size()); |
209 | 210 |
210 EXPECT_EQ(extension->path().AppendASCII("test.html").value(), | 211 EXPECT_EQ(extension->path().AppendASCII("test.html").value(), |
211 extension->GetResource("test.html").GetFilePath().value()); | 212 extension->GetResource("test.html").GetFilePath().value()); |
212 EXPECT_EQ(extension->path().AppendASCII("test.js").value(), | 213 EXPECT_EQ(extension->path().AppendASCII("test.js").value(), |
213 extension->GetResource("test.js").GetFilePath().value()); | 214 extension->GetResource("test.js").GetFilePath().value()); |
214 } | 215 } |
215 | 216 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 chrome::VersionInfo::CHANNEL_DEV); | 467 chrome::VersionInfo::CHANNEL_DEV); |
467 scoped_refptr<Extension> extension; | 468 scoped_refptr<Extension> extension; |
468 std::string error; | 469 std::string error; |
469 | 470 |
470 extension = LoadManifest("socket_permissions", "empty.json"); | 471 extension = LoadManifest("socket_permissions", "empty.json"); |
471 EXPECT_FALSE(CheckSocketPermission(extension, | 472 EXPECT_FALSE(CheckSocketPermission(extension, |
472 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); | 473 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); |
473 | 474 |
474 extension = LoadManifestUnchecked("socket_permissions", | 475 extension = LoadManifestUnchecked("socket_permissions", |
475 "socket1.json", | 476 "socket1.json", |
476 Extension::INTERNAL, Extension::NO_FLAGS, | 477 Manifest::INTERNAL, Extension::NO_FLAGS, |
477 &error); | 478 &error); |
478 EXPECT_TRUE(extension == NULL); | 479 EXPECT_TRUE(extension == NULL); |
479 ASSERT_EQ(ErrorUtils::FormatErrorMessage( | 480 ASSERT_EQ(ErrorUtils::FormatErrorMessage( |
480 errors::kInvalidPermission, "socket"), error); | 481 errors::kInvalidPermission, "socket"), error); |
481 | 482 |
482 extension = LoadManifest("socket_permissions", "socket2.json"); | 483 extension = LoadManifest("socket_permissions", "socket2.json"); |
483 EXPECT_TRUE(CheckSocketPermission(extension, | 484 EXPECT_TRUE(CheckSocketPermission(extension, |
484 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); | 485 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); |
485 EXPECT_FALSE(CheckSocketPermission( | 486 EXPECT_FALSE(CheckSocketPermission( |
486 extension, SocketPermissionRequest::UDP_BIND, "", 80)); | 487 extension, SocketPermissionRequest::UDP_BIND, "", 80)); |
(...skipping 24 matching lines...) Expand all Loading... |
511 FilePath path; | 512 FilePath path; |
512 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 513 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
513 path = path.AppendASCII("extensions"); | 514 path = path.AppendASCII("extensions"); |
514 | 515 |
515 // Initialize the Extension. | 516 // Initialize the Extension. |
516 std::string errors; | 517 std::string errors; |
517 DictionaryValue values; | 518 DictionaryValue values; |
518 values.SetString(keys::kName, "test"); | 519 values.SetString(keys::kName, "test"); |
519 values.SetString(keys::kVersion, "0.1"); | 520 values.SetString(keys::kVersion, "0.1"); |
520 scoped_refptr<Extension> extension(Extension::Create( | 521 scoped_refptr<Extension> extension(Extension::Create( |
521 path, Extension::INVALID, values, Extension::NO_FLAGS, &errors)); | 522 path, Manifest::INVALID_LOCATION, values, Extension::NO_FLAGS, &errors)); |
522 ASSERT_TRUE(extension.get()); | 523 ASSERT_TRUE(extension.get()); |
523 | 524 |
524 // Create an ExtensionResource pointing at an icon. | 525 // Create an ExtensionResource pointing at an icon. |
525 FilePath icon_relative_path(FILE_PATH_LITERAL("icon3.png")); | 526 FilePath icon_relative_path(FILE_PATH_LITERAL("icon3.png")); |
526 ExtensionResource resource(extension->id(), | 527 ExtensionResource resource(extension->id(), |
527 extension->path(), | 528 extension->path(), |
528 icon_relative_path); | 529 icon_relative_path); |
529 | 530 |
530 // Read in the icon file. | 531 // Read in the icon file. |
531 FilePath icon_absolute_path = extension->path().Append(icon_relative_path); | 532 FilePath icon_absolute_path = extension->path().Append(icon_relative_path); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 EXPECT_TRUE(Blocked(extension, favicon_url)); | 898 EXPECT_TRUE(Blocked(extension, favicon_url)); |
898 extension = LoadManifest("script_and_capture", | 899 extension = LoadManifest("script_and_capture", |
899 "extension_wildcard_settings.json"); | 900 "extension_wildcard_settings.json"); |
900 EXPECT_TRUE(Blocked(extension, settings_url)); | 901 EXPECT_TRUE(Blocked(extension, settings_url)); |
901 | 902 |
902 // Having chrome://*/ should not work for regular extensions. Note that | 903 // Having chrome://*/ should not work for regular extensions. Note that |
903 // for favicon access, we require the explicit pattern chrome://favicon/*. | 904 // for favicon access, we require the explicit pattern chrome://favicon/*. |
904 std::string error; | 905 std::string error; |
905 extension = LoadManifestUnchecked("script_and_capture", | 906 extension = LoadManifestUnchecked("script_and_capture", |
906 "extension_wildcard_chrome.json", | 907 "extension_wildcard_chrome.json", |
907 Extension::INTERNAL, Extension::NO_FLAGS, | 908 Manifest::INTERNAL, Extension::NO_FLAGS, |
908 &error); | 909 &error); |
909 EXPECT_TRUE(extension == NULL); | 910 EXPECT_TRUE(extension == NULL); |
910 EXPECT_EQ(ErrorUtils::FormatErrorMessage( | 911 EXPECT_EQ(ErrorUtils::FormatErrorMessage( |
911 errors::kInvalidPermissionScheme, "chrome://*/"), error); | 912 errors::kInvalidPermissionScheme, "chrome://*/"), error); |
912 | 913 |
913 // Having chrome://favicon/* should not give you chrome://* | 914 // Having chrome://favicon/* should not give you chrome://* |
914 extension = LoadManifestStrict("script_and_capture", | 915 extension = LoadManifestStrict("script_and_capture", |
915 "extension_chrome_favicon_wildcard.json"); | 916 "extension_chrome_favicon_wildcard.json"); |
916 EXPECT_TRUE(Blocked(extension, settings_url)); | 917 EXPECT_TRUE(Blocked(extension, settings_url)); |
917 EXPECT_TRUE(CaptureOnly(extension, favicon_url)); | 918 EXPECT_TRUE(CaptureOnly(extension, favicon_url)); |
918 EXPECT_TRUE(Blocked(extension, about_url)); | 919 EXPECT_TRUE(Blocked(extension, about_url)); |
919 EXPECT_TRUE(extension->HasHostPermission(favicon_url)); | 920 EXPECT_TRUE(extension->HasHostPermission(favicon_url)); |
920 | 921 |
921 // Having http://favicon should not give you chrome://favicon | 922 // Having http://favicon should not give you chrome://favicon |
922 extension = LoadManifestStrict("script_and_capture", | 923 extension = LoadManifestStrict("script_and_capture", |
923 "extension_http_favicon.json"); | 924 "extension_http_favicon.json"); |
924 EXPECT_TRUE(Blocked(extension, settings_url)); | 925 EXPECT_TRUE(Blocked(extension, settings_url)); |
925 EXPECT_TRUE(Blocked(extension, favicon_url)); | 926 EXPECT_TRUE(Blocked(extension, favicon_url)); |
926 | 927 |
927 // Component extensions with <all_urls> should get everything. | 928 // Component extensions with <all_urls> should get everything. |
928 extension = LoadManifest("script_and_capture", "extension_component_all.json", | 929 extension = LoadManifest("script_and_capture", "extension_component_all.json", |
929 Extension::COMPONENT, Extension::NO_FLAGS); | 930 Manifest::COMPONENT, Extension::NO_FLAGS); |
930 EXPECT_TRUE(Allowed(extension, http_url)); | 931 EXPECT_TRUE(Allowed(extension, http_url)); |
931 EXPECT_TRUE(Allowed(extension, https_url)); | 932 EXPECT_TRUE(Allowed(extension, https_url)); |
932 EXPECT_TRUE(Allowed(extension, settings_url)); | 933 EXPECT_TRUE(Allowed(extension, settings_url)); |
933 EXPECT_TRUE(Allowed(extension, about_url)); | 934 EXPECT_TRUE(Allowed(extension, about_url)); |
934 EXPECT_TRUE(Allowed(extension, favicon_url)); | 935 EXPECT_TRUE(Allowed(extension, favicon_url)); |
935 EXPECT_TRUE(extension->HasHostPermission(favicon_url)); | 936 EXPECT_TRUE(extension->HasHostPermission(favicon_url)); |
936 | 937 |
937 // Component extensions should only get access to what they ask for. | 938 // Component extensions should only get access to what they ask for. |
938 extension = LoadManifest("script_and_capture", | 939 extension = LoadManifest("script_and_capture", |
939 "extension_component_google.json", Extension::COMPONENT, | 940 "extension_component_google.json", Manifest::COMPONENT, |
940 Extension::NO_FLAGS); | 941 Extension::NO_FLAGS); |
941 EXPECT_TRUE(Allowed(extension, http_url)); | 942 EXPECT_TRUE(Allowed(extension, http_url)); |
942 EXPECT_TRUE(Blocked(extension, https_url)); | 943 EXPECT_TRUE(Blocked(extension, https_url)); |
943 EXPECT_TRUE(Blocked(extension, file_url)); | 944 EXPECT_TRUE(Blocked(extension, file_url)); |
944 EXPECT_TRUE(Blocked(extension, settings_url)); | 945 EXPECT_TRUE(Blocked(extension, settings_url)); |
945 EXPECT_TRUE(Blocked(extension, favicon_url)); | 946 EXPECT_TRUE(Blocked(extension, favicon_url)); |
946 EXPECT_TRUE(Blocked(extension, about_url)); | 947 EXPECT_TRUE(Blocked(extension, about_url)); |
947 EXPECT_TRUE(Blocked(extension, extension_url)); | 948 EXPECT_TRUE(Blocked(extension, extension_url)); |
948 EXPECT_FALSE(extension->HasHostPermission(settings_url)); | 949 EXPECT_FALSE(extension->HasHostPermission(settings_url)); |
949 } | 950 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 EXTENSION, | 1052 EXTENSION, |
1052 APP, | 1053 APP, |
1053 USER_SCRIPT, | 1054 USER_SCRIPT, |
1054 THEME | 1055 THEME |
1055 }; | 1056 }; |
1056 | 1057 |
1057 static scoped_refptr<Extension> MakeSyncTestExtension( | 1058 static scoped_refptr<Extension> MakeSyncTestExtension( |
1058 SyncTestExtensionType type, | 1059 SyncTestExtensionType type, |
1059 const GURL& update_url, | 1060 const GURL& update_url, |
1060 const GURL& launch_url, | 1061 const GURL& launch_url, |
1061 Extension::Location location, | 1062 Manifest::Location location, |
1062 int num_plugins, | 1063 int num_plugins, |
1063 const FilePath& extension_path, | 1064 const FilePath& extension_path, |
1064 int creation_flags) { | 1065 int creation_flags) { |
1065 DictionaryValue source; | 1066 DictionaryValue source; |
1066 source.SetString(extension_manifest_keys::kName, | 1067 source.SetString(extension_manifest_keys::kName, |
1067 "PossiblySyncableExtension"); | 1068 "PossiblySyncableExtension"); |
1068 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0"); | 1069 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0"); |
1069 if (type == APP) | 1070 if (type == APP) |
1070 source.SetString(extension_manifest_keys::kApp, "true"); | 1071 source.SetString(extension_manifest_keys::kApp, "true"); |
1071 if (type == THEME) | 1072 if (type == THEME) |
(...skipping 28 matching lines...) Expand all Loading... |
1100 | 1101 |
1101 static const char kValidUpdateUrl1[] = | 1102 static const char kValidUpdateUrl1[] = |
1102 "http://clients2.google.com/service/update2/crx"; | 1103 "http://clients2.google.com/service/update2/crx"; |
1103 static const char kValidUpdateUrl2[] = | 1104 static const char kValidUpdateUrl2[] = |
1104 "https://clients2.google.com/service/update2/crx"; | 1105 "https://clients2.google.com/service/update2/crx"; |
1105 } | 1106 } |
1106 | 1107 |
1107 TEST_F(ExtensionTest, GetSyncTypeNormalExtensionNoUpdateUrl) { | 1108 TEST_F(ExtensionTest, GetSyncTypeNormalExtensionNoUpdateUrl) { |
1108 scoped_refptr<Extension> extension( | 1109 scoped_refptr<Extension> extension( |
1109 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1110 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1110 Extension::INTERNAL, 0, FilePath(), | 1111 Manifest::INTERNAL, 0, FilePath(), |
1111 Extension::NO_FLAGS)); | 1112 Extension::NO_FLAGS)); |
1112 EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1113 EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1113 } | 1114 } |
1114 | 1115 |
1115 // http://crbug.com/172712 | 1116 // http://crbug.com/172712 |
1116 TEST_F(ExtensionTest, DISABLED_GetSyncTypeUserScriptValidUpdateUrl) { | 1117 TEST_F(ExtensionTest, DISABLED_GetSyncTypeUserScriptValidUpdateUrl) { |
1117 scoped_refptr<Extension> extension( | 1118 scoped_refptr<Extension> extension( |
1118 MakeSyncTestExtension(USER_SCRIPT, GURL(kValidUpdateUrl1), GURL(), | 1119 MakeSyncTestExtension(USER_SCRIPT, GURL(kValidUpdateUrl1), GURL(), |
1119 Extension::INTERNAL, 0, FilePath(), | 1120 Manifest::INTERNAL, 0, FilePath(), |
1120 Extension::NO_FLAGS)); | 1121 Extension::NO_FLAGS)); |
1121 EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1122 EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1122 } | 1123 } |
1123 | 1124 |
1124 TEST_F(ExtensionTest, GetSyncTypeUserScriptNoUpdateUrl) { | 1125 TEST_F(ExtensionTest, GetSyncTypeUserScriptNoUpdateUrl) { |
1125 scoped_refptr<Extension> extension( | 1126 scoped_refptr<Extension> extension( |
1126 MakeSyncTestExtension(USER_SCRIPT, GURL(), GURL(), | 1127 MakeSyncTestExtension(USER_SCRIPT, GURL(), GURL(), |
1127 Extension::INTERNAL, 0, FilePath(), | 1128 Manifest::INTERNAL, 0, FilePath(), |
1128 Extension::NO_FLAGS)); | 1129 Extension::NO_FLAGS)); |
1129 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1130 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1130 } | 1131 } |
1131 | 1132 |
1132 TEST_F(ExtensionTest, GetSyncTypeThemeNoUpdateUrl) { | 1133 TEST_F(ExtensionTest, GetSyncTypeThemeNoUpdateUrl) { |
1133 scoped_refptr<Extension> extension( | 1134 scoped_refptr<Extension> extension( |
1134 MakeSyncTestExtension(THEME, GURL(), GURL(), | 1135 MakeSyncTestExtension(THEME, GURL(), GURL(), |
1135 Extension::INTERNAL, 0, FilePath(), | 1136 Manifest::INTERNAL, 0, FilePath(), |
1136 Extension::NO_FLAGS)); | 1137 Extension::NO_FLAGS)); |
1137 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1138 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1138 } | 1139 } |
1139 | 1140 |
1140 TEST_F(ExtensionTest, GetSyncTypeExtensionWithLaunchUrl) { | 1141 TEST_F(ExtensionTest, GetSyncTypeExtensionWithLaunchUrl) { |
1141 scoped_refptr<Extension> extension( | 1142 scoped_refptr<Extension> extension( |
1142 MakeSyncTestExtension(EXTENSION, GURL(), GURL("http://www.google.com"), | 1143 MakeSyncTestExtension(EXTENSION, GURL(), GURL("http://www.google.com"), |
1143 Extension::INTERNAL, 0, FilePath(), | 1144 Manifest::INTERNAL, 0, FilePath(), |
1144 Extension::NO_FLAGS)); | 1145 Extension::NO_FLAGS)); |
1145 EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1146 EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1146 } | 1147 } |
1147 | 1148 |
1148 TEST_F(ExtensionTest, GetSyncTypeExtensionExternal) { | 1149 TEST_F(ExtensionTest, GetSyncTypeExtensionExternal) { |
1149 scoped_refptr<Extension> extension( | 1150 scoped_refptr<Extension> extension( |
1150 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1151 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1151 Extension::EXTERNAL_PREF, 0, FilePath(), | 1152 Manifest::EXTERNAL_PREF, 0, FilePath(), |
1152 Extension::NO_FLAGS)); | 1153 Extension::NO_FLAGS)); |
1153 | 1154 |
1154 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1155 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1155 } | 1156 } |
1156 | 1157 |
1157 TEST_F(ExtensionTest, GetSyncTypeUserScriptThirdPartyUpdateUrl) { | 1158 TEST_F(ExtensionTest, GetSyncTypeUserScriptThirdPartyUpdateUrl) { |
1158 scoped_refptr<Extension> extension( | 1159 scoped_refptr<Extension> extension( |
1159 MakeSyncTestExtension( | 1160 MakeSyncTestExtension( |
1160 USER_SCRIPT, GURL("http://third-party.update_url.com"), GURL(), | 1161 USER_SCRIPT, GURL("http://third-party.update_url.com"), GURL(), |
1161 Extension::INTERNAL, 0, FilePath(), Extension::NO_FLAGS)); | 1162 Manifest::INTERNAL, 0, FilePath(), Extension::NO_FLAGS)); |
1162 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1163 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1163 } | 1164 } |
1164 | 1165 |
1165 TEST_F(ExtensionTest, OnlyDisplayAppsInLauncher) { | 1166 TEST_F(ExtensionTest, OnlyDisplayAppsInLauncher) { |
1166 scoped_refptr<Extension> extension( | 1167 scoped_refptr<Extension> extension( |
1167 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1168 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1168 Extension::INTERNAL, 0, FilePath(), | 1169 Manifest::INTERNAL, 0, FilePath(), |
1169 Extension::NO_FLAGS)); | 1170 Extension::NO_FLAGS)); |
1170 | 1171 |
1171 EXPECT_FALSE(extension->ShouldDisplayInAppLauncher()); | 1172 EXPECT_FALSE(extension->ShouldDisplayInAppLauncher()); |
1172 EXPECT_FALSE(extension->ShouldDisplayInNewTabPage()); | 1173 EXPECT_FALSE(extension->ShouldDisplayInNewTabPage()); |
1173 | 1174 |
1174 scoped_refptr<Extension> app( | 1175 scoped_refptr<Extension> app( |
1175 MakeSyncTestExtension(APP, GURL(), GURL("http://www.google.com"), | 1176 MakeSyncTestExtension(APP, GURL(), GURL("http://www.google.com"), |
1176 Extension::INTERNAL, 0, FilePath(), | 1177 Manifest::INTERNAL, 0, FilePath(), |
1177 Extension::NO_FLAGS)); | 1178 Extension::NO_FLAGS)); |
1178 EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); | 1179 EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); |
1179 EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); | 1180 EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); |
1180 } | 1181 } |
1181 | 1182 |
1182 TEST_F(ExtensionTest, DisplayInXManifestProperties) { | 1183 TEST_F(ExtensionTest, DisplayInXManifestProperties) { |
1183 DictionaryValue manifest; | 1184 DictionaryValue manifest; |
1184 manifest.SetString(keys::kName, "TestComponentApp"); | 1185 manifest.SetString(keys::kName, "TestComponentApp"); |
1185 manifest.SetString(keys::kVersion, "0.0.0.0"); | 1186 manifest.SetString(keys::kVersion, "0.0.0.0"); |
1186 manifest.SetString(keys::kApp, "true"); | 1187 manifest.SetString(keys::kApp, "true"); |
1187 manifest.SetString(keys::kPlatformAppBackgroundPage, ""); | 1188 manifest.SetString(keys::kPlatformAppBackgroundPage, ""); |
1188 | 1189 |
1189 std::string error; | 1190 std::string error; |
1190 scoped_refptr<Extension> app; | 1191 scoped_refptr<Extension> app; |
1191 | 1192 |
1192 // Default to true. | 1193 // Default to true. |
1193 app = Extension::Create( | 1194 app = Extension::Create( |
1194 FilePath(), Extension::COMPONENT, manifest, 0, &error); | 1195 FilePath(), Manifest::COMPONENT, manifest, 0, &error); |
1195 EXPECT_EQ(error, std::string()); | 1196 EXPECT_EQ(error, std::string()); |
1196 EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); | 1197 EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); |
1197 EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); | 1198 EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); |
1198 | 1199 |
1199 // Value display_in_NTP defaults to display_in_launcher. | 1200 // Value display_in_NTP defaults to display_in_launcher. |
1200 manifest.SetBoolean(keys::kDisplayInLauncher, false); | 1201 manifest.SetBoolean(keys::kDisplayInLauncher, false); |
1201 app = Extension::Create( | 1202 app = Extension::Create( |
1202 FilePath(), Extension::COMPONENT, manifest, 0, &error); | 1203 FilePath(), Manifest::COMPONENT, manifest, 0, &error); |
1203 EXPECT_EQ(error, std::string()); | 1204 EXPECT_EQ(error, std::string()); |
1204 EXPECT_FALSE(app->ShouldDisplayInAppLauncher()); | 1205 EXPECT_FALSE(app->ShouldDisplayInAppLauncher()); |
1205 EXPECT_FALSE(app->ShouldDisplayInNewTabPage()); | 1206 EXPECT_FALSE(app->ShouldDisplayInNewTabPage()); |
1206 | 1207 |
1207 // Value display_in_NTP = true overriding display_in_launcher = false. | 1208 // Value display_in_NTP = true overriding display_in_launcher = false. |
1208 manifest.SetBoolean(keys::kDisplayInNewTabPage, true); | 1209 manifest.SetBoolean(keys::kDisplayInNewTabPage, true); |
1209 app = Extension::Create( | 1210 app = Extension::Create( |
1210 FilePath(), Extension::COMPONENT, manifest, 0, &error); | 1211 FilePath(), Manifest::COMPONENT, manifest, 0, &error); |
1211 EXPECT_EQ(error, std::string()); | 1212 EXPECT_EQ(error, std::string()); |
1212 EXPECT_FALSE(app->ShouldDisplayInAppLauncher()); | 1213 EXPECT_FALSE(app->ShouldDisplayInAppLauncher()); |
1213 EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); | 1214 EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); |
1214 | 1215 |
1215 // Value display_in_NTP = false only, overrides default = true. | 1216 // Value display_in_NTP = false only, overrides default = true. |
1216 manifest.Remove(keys::kDisplayInLauncher, NULL); | 1217 manifest.Remove(keys::kDisplayInLauncher, NULL); |
1217 manifest.SetBoolean(keys::kDisplayInNewTabPage, false); | 1218 manifest.SetBoolean(keys::kDisplayInNewTabPage, false); |
1218 app = Extension::Create( | 1219 app = Extension::Create( |
1219 FilePath(), Extension::COMPONENT, manifest, 0, &error); | 1220 FilePath(), Manifest::COMPONENT, manifest, 0, &error); |
1220 EXPECT_EQ(error, std::string()); | 1221 EXPECT_EQ(error, std::string()); |
1221 EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); | 1222 EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); |
1222 EXPECT_FALSE(app->ShouldDisplayInNewTabPage()); | 1223 EXPECT_FALSE(app->ShouldDisplayInNewTabPage()); |
1223 | 1224 |
1224 // Error checking. | 1225 // Error checking. |
1225 manifest.SetString(keys::kDisplayInNewTabPage, "invalid"); | 1226 manifest.SetString(keys::kDisplayInNewTabPage, "invalid"); |
1226 app = Extension::Create( | 1227 app = Extension::Create( |
1227 FilePath(), Extension::COMPONENT, manifest, 0, &error); | 1228 FilePath(), Manifest::COMPONENT, manifest, 0, &error); |
1228 EXPECT_EQ(error, std::string(errors::kInvalidDisplayInNewTabPage)); | 1229 EXPECT_EQ(error, std::string(errors::kInvalidDisplayInNewTabPage)); |
1229 } | 1230 } |
1230 | 1231 |
1231 TEST_F(ExtensionTest, OnlySyncInternal) { | 1232 TEST_F(ExtensionTest, OnlySyncInternal) { |
1232 scoped_refptr<Extension> extension_internal( | 1233 scoped_refptr<Extension> extension_internal( |
1233 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1234 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1234 Extension::INTERNAL, 0, FilePath(), | 1235 Manifest::INTERNAL, 0, FilePath(), |
1235 Extension::NO_FLAGS)); | 1236 Extension::NO_FLAGS)); |
1236 EXPECT_TRUE(extension_internal->IsSyncable()); | 1237 EXPECT_TRUE(extension_internal->IsSyncable()); |
1237 | 1238 |
1238 scoped_refptr<Extension> extension_noninternal( | 1239 scoped_refptr<Extension> extension_noninternal( |
1239 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1240 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1240 Extension::COMPONENT, 0, FilePath(), | 1241 Manifest::COMPONENT, 0, FilePath(), |
1241 Extension::NO_FLAGS)); | 1242 Extension::NO_FLAGS)); |
1242 EXPECT_FALSE(extension_noninternal->IsSyncable()); | 1243 EXPECT_FALSE(extension_noninternal->IsSyncable()); |
1243 } | 1244 } |
1244 | 1245 |
1245 TEST_F(ExtensionTest, DontSyncDefault) { | 1246 TEST_F(ExtensionTest, DontSyncDefault) { |
1246 scoped_refptr<Extension> extension_default( | 1247 scoped_refptr<Extension> extension_default( |
1247 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1248 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1248 Extension::INTERNAL, 0, FilePath(), | 1249 Manifest::INTERNAL, 0, FilePath(), |
1249 Extension::WAS_INSTALLED_BY_DEFAULT)); | 1250 Extension::WAS_INSTALLED_BY_DEFAULT)); |
1250 EXPECT_FALSE(extension_default->IsSyncable()); | 1251 EXPECT_FALSE(extension_default->IsSyncable()); |
1251 } | 1252 } |
1252 | 1253 |
1253 TEST_F(ExtensionTest, OptionalOnlyPermission) { | 1254 TEST_F(ExtensionTest, OptionalOnlyPermission) { |
1254 // Set feature current channel to dev because the only permission that must | 1255 // Set feature current channel to dev because the only permission that must |
1255 // be optional (usbDevices) is only available on dev channel. | 1256 // be optional (usbDevices) is only available on dev channel. |
1256 Feature::ScopedCurrentChannel scoped_channel( | 1257 Feature::ScopedCurrentChannel scoped_channel( |
1257 chrome::VersionInfo::CHANNEL_DEV); | 1258 chrome::VersionInfo::CHANNEL_DEV); |
1258 | 1259 |
1259 scoped_refptr<Extension> extension; | 1260 scoped_refptr<Extension> extension; |
1260 std::string error; | 1261 std::string error; |
1261 extension = LoadManifestUnchecked("optional_only_permission", | 1262 extension = LoadManifestUnchecked("optional_only_permission", |
1262 "manifest1.json", | 1263 "manifest1.json", |
1263 Extension::INTERNAL, Extension::NO_FLAGS, | 1264 Manifest::INTERNAL, Extension::NO_FLAGS, |
1264 &error); | 1265 &error); |
1265 EXPECT_TRUE(extension == NULL); | 1266 EXPECT_TRUE(extension == NULL); |
1266 ASSERT_EQ(ErrorUtils::FormatErrorMessage( | 1267 ASSERT_EQ(ErrorUtils::FormatErrorMessage( |
1267 errors::kPermissionMustBeOptional, "usbDevices"), error); | 1268 errors::kPermissionMustBeOptional, "usbDevices"), error); |
1268 | 1269 |
1269 error.clear(); | 1270 error.clear(); |
1270 extension = LoadManifestUnchecked("optional_only_permission", | 1271 extension = LoadManifestUnchecked("optional_only_permission", |
1271 "manifest2.json", | 1272 "manifest2.json", |
1272 Extension::INTERNAL, Extension::NO_FLAGS, | 1273 Manifest::INTERNAL, Extension::NO_FLAGS, |
1273 &error); | 1274 &error); |
1274 EXPECT_TRUE(extension != NULL); | 1275 EXPECT_TRUE(extension != NULL); |
1275 EXPECT_TRUE(error.empty()); | 1276 EXPECT_TRUE(error.empty()); |
1276 } | 1277 } |
1277 | 1278 |
1278 // These last 2 tests don't make sense on Chrome OS, where extension plugins | 1279 // These last 2 tests don't make sense on Chrome OS, where extension plugins |
1279 // are not allowed. | 1280 // are not allowed. |
1280 #if !defined(OS_CHROMEOS) | 1281 #if !defined(OS_CHROMEOS) |
1281 TEST_F(ExtensionTest, GetSyncTypeExtensionWithPlugin) { | 1282 TEST_F(ExtensionTest, GetSyncTypeExtensionWithPlugin) { |
1282 scoped_refptr<Extension> extension( | 1283 scoped_refptr<Extension> extension( |
1283 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1284 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1284 Extension::INTERNAL, 1, FilePath(), | 1285 Manifest::INTERNAL, 1, FilePath(), |
1285 Extension::NO_FLAGS)); | 1286 Extension::NO_FLAGS)); |
1286 if (extension) | 1287 if (extension) |
1287 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1288 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1288 } | 1289 } |
1289 | 1290 |
1290 TEST_F(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) { | 1291 TEST_F(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) { |
1291 scoped_refptr<Extension> extension( | 1292 scoped_refptr<Extension> extension( |
1292 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1293 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1293 Extension::INTERNAL, 2, FilePath(), | 1294 Manifest::INTERNAL, 2, FilePath(), |
1294 Extension::NO_FLAGS)); | 1295 Extension::NO_FLAGS)); |
1295 if (extension) | 1296 if (extension) |
1296 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1297 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1297 } | 1298 } |
1298 #endif // !defined(OS_CHROMEOS) | 1299 #endif // !defined(OS_CHROMEOS) |
1299 | 1300 |
1300 } // namespace extensions | 1301 } // namespace extensions |
OLD | NEW |