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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) { | 1263 TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) { |
1264 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); | 1264 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); |
1265 | 1265 |
1266 scoped_refptr<Extension> extension = | 1266 scoped_refptr<Extension> extension = |
1267 LoadManifest("permissions", "socket_any_host.json"); | 1267 LoadManifest("permissions", "socket_any_host.json"); |
1268 EXPECT_TRUE(extension->is_platform_app()); | 1268 EXPECT_TRUE(extension->is_platform_app()); |
1269 EXPECT_TRUE( | 1269 EXPECT_TRUE( |
1270 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); | 1270 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); |
1271 EXPECT_TRUE(VerifyOnePermissionMessage( | 1271 EXPECT_TRUE(VerifyOnePermissionMessage( |
1272 extension->permissions_data(), | 1272 extension->permissions_data(), |
1273 "Exchange data with any computer on the local network or internet")); | 1273 "Exchange data with any device on the local network or internet")); |
1274 } | 1274 } |
1275 | 1275 |
1276 TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) { | 1276 TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) { |
1277 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); | 1277 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); |
1278 | 1278 |
1279 scoped_refptr<Extension> extension = | 1279 scoped_refptr<Extension> extension = |
1280 LoadManifest("permissions", "socket_one_domain_two_hostnames.json"); | 1280 LoadManifest("permissions", "socket_one_domain_two_hostnames.json"); |
1281 EXPECT_TRUE(extension->is_platform_app()); | 1281 EXPECT_TRUE(extension->is_platform_app()); |
1282 EXPECT_TRUE( | 1282 EXPECT_TRUE( |
1283 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); | 1283 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); |
1284 | 1284 |
1285 // Verify the warnings, including support for unicode characters, the fact | 1285 // Verify the warnings, including support for unicode characters, the fact |
1286 // that domain host warnings come before specific host warnings, and the fact | 1286 // that domain host warnings come before specific host warnings, and the fact |
1287 // that domains and hostnames are in alphabetical order regardless of the | 1287 // that domains and hostnames are in alphabetical order regardless of the |
1288 // order in the manifest file. | 1288 // order in the manifest file. |
1289 EXPECT_TRUE(VerifyTwoPermissionMessages( | 1289 EXPECT_TRUE(VerifyTwoPermissionMessages( |
1290 extension->permissions_data(), | 1290 extension->permissions_data(), |
1291 "Exchange data with any computer in the domain example.org", | 1291 "Exchange data with any device in the domain example.org", |
1292 "Exchange data with the computers named: " | 1292 "Exchange data with the devices named: " |
1293 "b\xC3\xA5r.example.com foo.example.com", | 1293 "b\xC3\xA5r.example.com foo.example.com", |
1294 // "\xC3\xA5" = UTF-8 for lowercase A with ring above | 1294 // "\xC3\xA5" = UTF-8 for lowercase A with ring above |
1295 true)); | 1295 true)); |
1296 } | 1296 } |
1297 | 1297 |
1298 TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) { | 1298 TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) { |
1299 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); | 1299 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); |
1300 | 1300 |
1301 scoped_refptr<Extension> extension = | 1301 scoped_refptr<Extension> extension = |
1302 LoadManifest("permissions", "socket_two_domains_one_hostname.json"); | 1302 LoadManifest("permissions", "socket_two_domains_one_hostname.json"); |
1303 EXPECT_TRUE(extension->is_platform_app()); | 1303 EXPECT_TRUE(extension->is_platform_app()); |
1304 EXPECT_TRUE( | 1304 EXPECT_TRUE( |
1305 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); | 1305 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); |
1306 | 1306 |
1307 // Verify the warnings, including the fact that domain host warnings come | 1307 // Verify the warnings, including the fact that domain host warnings come |
1308 // before specific host warnings and the fact that domains and hostnames are | 1308 // before specific host warnings and the fact that domains and hostnames are |
1309 // in alphabetical order regardless of the order in the manifest file. | 1309 // in alphabetical order regardless of the order in the manifest file. |
1310 EXPECT_TRUE(VerifyTwoPermissionMessages( | 1310 EXPECT_TRUE(VerifyTwoPermissionMessages( |
1311 extension->permissions_data(), | 1311 extension->permissions_data(), |
1312 "Exchange data with any computer in the domains: " | 1312 "Exchange data with any device in the domains: " |
1313 "example.com foo.example.org", | 1313 "example.com foo.example.org", |
1314 "Exchange data with the computer named bar.example.org", true)); | 1314 "Exchange data with the device named bar.example.org", true)); |
1315 } | 1315 } |
1316 | 1316 |
1317 // Since platform apps always use isolated storage, they can't (silently) | 1317 // Since platform apps always use isolated storage, they can't (silently) |
1318 // access user data on other domains, so there's no need to prompt about host | 1318 // access user data on other domains, so there's no need to prompt about host |
1319 // permissions. See crbug.com/255229. | 1319 // permissions. See crbug.com/255229. |
1320 TEST(PermissionsTest, GetWarningMessages_PlatformAppHosts) { | 1320 TEST(PermissionsTest, GetWarningMessages_PlatformAppHosts) { |
1321 scoped_refptr<Extension> extension; | 1321 scoped_refptr<Extension> extension; |
1322 | 1322 |
1323 extension = LoadManifest("permissions", "platform_app_hosts.json"); | 1323 extension = LoadManifest("permissions", "platform_app_hosts.json"); |
1324 EXPECT_TRUE(extension->is_platform_app()); | 1324 EXPECT_TRUE(extension->is_platform_app()); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 scoped_refptr<const PermissionSet> permissions_dwr( | 1802 scoped_refptr<const PermissionSet> permissions_dwr( |
1803 extension_dwr->permissions_data()->active_permissions()); | 1803 extension_dwr->permissions_data()->active_permissions()); |
1804 | 1804 |
1805 EXPECT_FALSE(PermissionMessageProvider::Get()-> | 1805 EXPECT_FALSE(PermissionMessageProvider::Get()-> |
1806 IsPrivilegeIncrease(permissions.get(), | 1806 IsPrivilegeIncrease(permissions.get(), |
1807 permissions_dwr.get(), | 1807 permissions_dwr.get(), |
1808 extension->GetType())); | 1808 extension->GetType())); |
1809 } | 1809 } |
1810 | 1810 |
1811 } // namespace extensions | 1811 } // namespace extensions |
OLD | NEW |