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/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 #include "webkit/database/database_tracker.h" | 89 #include "webkit/database/database_tracker.h" |
90 #include "webkit/database/database_util.h" | 90 #include "webkit/database/database_util.h" |
91 #include "webkit/plugins/npapi/mock_plugin_list.h" | 91 #include "webkit/plugins/npapi/mock_plugin_list.h" |
92 #include "webkit/quota/quota_manager.h" | 92 #include "webkit/quota/quota_manager.h" |
93 | 93 |
94 using content::BrowserContext; | 94 using content::BrowserContext; |
95 using content::BrowserThread; | 95 using content::BrowserThread; |
96 using content::DOMStorageContext; | 96 using content::DOMStorageContext; |
97 using content::IndexedDBContext; | 97 using content::IndexedDBContext; |
98 using content::PluginService; | 98 using content::PluginService; |
| 99 using extensions::APIPermission; |
| 100 using extensions::APIPermissionSet; |
99 using extensions::Extension; | 101 using extensions::Extension; |
| 102 using extensions::PermissionSet; |
100 | 103 |
101 namespace keys = extension_manifest_keys; | 104 namespace keys = extension_manifest_keys; |
102 | 105 |
103 namespace { | 106 namespace { |
104 | 107 |
105 // Extension ids used during testing. | 108 // Extension ids used during testing. |
106 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 109 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
107 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"; | 110 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"; |
108 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 111 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj"; |
109 const char* const good1 = "hpiknbiabeeppbpihjehijgoemciehgk"; | 112 const char* const good1 = "hpiknbiabeeppbpihjehijgoemciehgk"; |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 .AppendASCII("permissions"); | 1462 .AppendASCII("permissions"); |
1460 | 1463 |
1461 FilePath pem_path = path.AppendASCII("unknown.pem"); | 1464 FilePath pem_path = path.AppendASCII("unknown.pem"); |
1462 path = path.AppendASCII("unknown"); | 1465 path = path.AppendASCII("unknown"); |
1463 | 1466 |
1464 ASSERT_TRUE(file_util::PathExists(pem_path)); | 1467 ASSERT_TRUE(file_util::PathExists(pem_path)); |
1465 ASSERT_TRUE(file_util::PathExists(path)); | 1468 ASSERT_TRUE(file_util::PathExists(path)); |
1466 | 1469 |
1467 ExtensionPrefs* prefs = service_->extension_prefs(); | 1470 ExtensionPrefs* prefs = service_->extension_prefs(); |
1468 | 1471 |
1469 ExtensionAPIPermissionSet expected_api_perms; | 1472 APIPermissionSet expected_api_perms; |
1470 URLPatternSet expected_host_perms; | 1473 URLPatternSet expected_host_perms; |
1471 | 1474 |
1472 // Make sure there aren't any granted permissions before the | 1475 // Make sure there aren't any granted permissions before the |
1473 // extension is installed. | 1476 // extension is installed. |
1474 scoped_refptr<ExtensionPermissionSet> known_perms( | 1477 scoped_refptr<PermissionSet> known_perms( |
1475 prefs->GetGrantedPermissions(permissions_crx)); | 1478 prefs->GetGrantedPermissions(permissions_crx)); |
1476 EXPECT_FALSE(known_perms.get()); | 1479 EXPECT_FALSE(known_perms.get()); |
1477 | 1480 |
1478 const Extension* extension = PackAndInstallCRX(path, pem_path, INSTALL_NEW); | 1481 const Extension* extension = PackAndInstallCRX(path, pem_path, INSTALL_NEW); |
1479 | 1482 |
1480 EXPECT_EQ(0u, GetErrors().size()); | 1483 EXPECT_EQ(0u, GetErrors().size()); |
1481 ASSERT_EQ(1u, service_->extensions()->size()); | 1484 ASSERT_EQ(1u, service_->extensions()->size()); |
1482 EXPECT_EQ(permissions_crx, extension->id()); | 1485 EXPECT_EQ(permissions_crx, extension->id()); |
1483 | 1486 |
1484 // Verify that the valid API permissions have been recognized. | 1487 // Verify that the valid API permissions have been recognized. |
1485 expected_api_perms.insert(ExtensionAPIPermission::kTab); | 1488 expected_api_perms.insert(APIPermission::kTab); |
1486 | 1489 |
1487 AddPattern(&expected_host_perms, "http://*.google.com/*"); | 1490 AddPattern(&expected_host_perms, "http://*.google.com/*"); |
1488 AddPattern(&expected_host_perms, "https://*.google.com/*"); | 1491 AddPattern(&expected_host_perms, "https://*.google.com/*"); |
1489 AddPattern(&expected_host_perms, "http://*.google.com.hk/*"); | 1492 AddPattern(&expected_host_perms, "http://*.google.com.hk/*"); |
1490 AddPattern(&expected_host_perms, "http://www.example.com/*"); | 1493 AddPattern(&expected_host_perms, "http://www.example.com/*"); |
1491 | 1494 |
1492 known_perms = prefs->GetGrantedPermissions(extension->id()); | 1495 known_perms = prefs->GetGrantedPermissions(extension->id()); |
1493 EXPECT_TRUE(known_perms.get()); | 1496 EXPECT_TRUE(known_perms.get()); |
1494 EXPECT_FALSE(known_perms->IsEmpty()); | 1497 EXPECT_FALSE(known_perms->IsEmpty()); |
1495 EXPECT_EQ(expected_api_perms, known_perms->apis()); | 1498 EXPECT_EQ(expected_api_perms, known_perms->apis()); |
(...skipping 15 matching lines...) Expand all Loading... |
1511 .AppendASCII("Extensions") | 1514 .AppendASCII("Extensions") |
1512 .AppendASCII(good1) | 1515 .AppendASCII(good1) |
1513 .AppendASCII("2"); | 1516 .AppendASCII("2"); |
1514 | 1517 |
1515 ASSERT_TRUE(file_util::PathExists(path)); | 1518 ASSERT_TRUE(file_util::PathExists(path)); |
1516 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); | 1519 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); |
1517 EXPECT_EQ(0u, GetErrors().size()); | 1520 EXPECT_EQ(0u, GetErrors().size()); |
1518 EXPECT_EQ(1u, service_->extensions()->size()); | 1521 EXPECT_EQ(1u, service_->extensions()->size()); |
1519 ExtensionPrefs* prefs = service_->extension_prefs(); | 1522 ExtensionPrefs* prefs = service_->extension_prefs(); |
1520 | 1523 |
1521 scoped_refptr<ExtensionPermissionSet> permissions( | 1524 scoped_refptr<PermissionSet> permissions( |
1522 prefs->GetGrantedPermissions(extension->id())); | 1525 prefs->GetGrantedPermissions(extension->id())); |
1523 EXPECT_FALSE(permissions->IsEmpty()); | 1526 EXPECT_FALSE(permissions->IsEmpty()); |
1524 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); | 1527 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); |
1525 EXPECT_FALSE(permissions->apis().empty()); | 1528 EXPECT_FALSE(permissions->apis().empty()); |
1526 EXPECT_TRUE(permissions->HasAPIPermission(ExtensionAPIPermission::kPlugin)); | 1529 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); |
1527 | 1530 |
1528 // Full access implies full host access too... | 1531 // Full access implies full host access too... |
1529 EXPECT_TRUE(permissions->HasEffectiveAccessToAllHosts()); | 1532 EXPECT_TRUE(permissions->HasEffectiveAccessToAllHosts()); |
1530 } | 1533 } |
1531 #endif | 1534 #endif |
1532 | 1535 |
1533 // Tests that the extension is disabled when permissions are missing from | 1536 // Tests that the extension is disabled when permissions are missing from |
1534 // the extension's granted permissions preferences. (This simulates updating | 1537 // the extension's granted permissions preferences. (This simulates updating |
1535 // the browser to a version which recognizes more permissions). | 1538 // the browser to a version which recognizes more permissions). |
1536 TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) { | 1539 TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) { |
1537 InitializeEmptyExtensionService(); | 1540 InitializeEmptyExtensionService(); |
1538 | 1541 |
1539 FilePath path = data_dir_ | 1542 FilePath path = data_dir_ |
1540 .AppendASCII("permissions") | 1543 .AppendASCII("permissions") |
1541 .AppendASCII("unknown"); | 1544 .AppendASCII("unknown"); |
1542 | 1545 |
1543 ASSERT_TRUE(file_util::PathExists(path)); | 1546 ASSERT_TRUE(file_util::PathExists(path)); |
1544 | 1547 |
1545 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); | 1548 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); |
1546 | 1549 |
1547 EXPECT_EQ(0u, GetErrors().size()); | 1550 EXPECT_EQ(0u, GetErrors().size()); |
1548 EXPECT_EQ(1u, service_->extensions()->size()); | 1551 EXPECT_EQ(1u, service_->extensions()->size()); |
1549 std::string extension_id = extension->id(); | 1552 std::string extension_id = extension->id(); |
1550 | 1553 |
1551 ExtensionPrefs* prefs = service_->extension_prefs(); | 1554 ExtensionPrefs* prefs = service_->extension_prefs(); |
1552 | 1555 |
1553 ExtensionAPIPermissionSet expected_api_permissions; | 1556 APIPermissionSet expected_api_permissions; |
1554 URLPatternSet expected_host_permissions; | 1557 URLPatternSet expected_host_permissions; |
1555 | 1558 |
1556 expected_api_permissions.insert(ExtensionAPIPermission::kTab); | 1559 expected_api_permissions.insert(APIPermission::kTab); |
1557 AddPattern(&expected_host_permissions, "http://*.google.com/*"); | 1560 AddPattern(&expected_host_permissions, "http://*.google.com/*"); |
1558 AddPattern(&expected_host_permissions, "https://*.google.com/*"); | 1561 AddPattern(&expected_host_permissions, "https://*.google.com/*"); |
1559 AddPattern(&expected_host_permissions, "http://*.google.com.hk/*"); | 1562 AddPattern(&expected_host_permissions, "http://*.google.com.hk/*"); |
1560 AddPattern(&expected_host_permissions, "http://www.example.com/*"); | 1563 AddPattern(&expected_host_permissions, "http://www.example.com/*"); |
1561 | 1564 |
1562 std::set<std::string> host_permissions; | 1565 std::set<std::string> host_permissions; |
1563 | 1566 |
1564 // Test that the extension is disabled when an API permission is missing from | 1567 // Test that the extension is disabled when an API permission is missing from |
1565 // the extension's granted api permissions preference. (This simulates | 1568 // the extension's granted api permissions preference. (This simulates |
1566 // updating the browser to a version which recognizes a new API permission). | 1569 // updating the browser to a version which recognizes a new API permission). |
1567 SetPref(extension_id, "granted_permissions.api", | 1570 SetPref(extension_id, "granted_permissions.api", |
1568 new ListValue(), "granted_permissions.api"); | 1571 new ListValue(), "granted_permissions.api"); |
1569 service_->ReloadExtensions(); | 1572 service_->ReloadExtensions(); |
1570 | 1573 |
1571 EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 1574 EXPECT_EQ(1u, service_->disabled_extensions()->size()); |
1572 extension = *service_->disabled_extensions()->begin(); | 1575 extension = *service_->disabled_extensions()->begin(); |
1573 | 1576 |
1574 ASSERT_TRUE(prefs->IsExtensionDisabled(extension_id)); | 1577 ASSERT_TRUE(prefs->IsExtensionDisabled(extension_id)); |
1575 ASSERT_FALSE(service_->IsExtensionEnabled(extension_id)); | 1578 ASSERT_FALSE(service_->IsExtensionEnabled(extension_id)); |
1576 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id)); | 1579 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id)); |
1577 | 1580 |
1578 // Now grant and re-enable the extension, making sure the prefs are updated. | 1581 // Now grant and re-enable the extension, making sure the prefs are updated. |
1579 service_->GrantPermissionsAndEnableExtension(extension); | 1582 service_->GrantPermissionsAndEnableExtension(extension); |
1580 | 1583 |
1581 ASSERT_FALSE(prefs->IsExtensionDisabled(extension_id)); | 1584 ASSERT_FALSE(prefs->IsExtensionDisabled(extension_id)); |
1582 ASSERT_TRUE(service_->IsExtensionEnabled(extension_id)); | 1585 ASSERT_TRUE(service_->IsExtensionEnabled(extension_id)); |
1583 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id)); | 1586 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id)); |
1584 | 1587 |
1585 scoped_refptr<ExtensionPermissionSet> current_perms( | 1588 scoped_refptr<PermissionSet> current_perms( |
1586 prefs->GetGrantedPermissions(extension_id)); | 1589 prefs->GetGrantedPermissions(extension_id)); |
1587 ASSERT_TRUE(current_perms.get()); | 1590 ASSERT_TRUE(current_perms.get()); |
1588 ASSERT_FALSE(current_perms->IsEmpty()); | 1591 ASSERT_FALSE(current_perms->IsEmpty()); |
1589 ASSERT_FALSE(current_perms->HasEffectiveFullAccess()); | 1592 ASSERT_FALSE(current_perms->HasEffectiveFullAccess()); |
1590 ASSERT_EQ(expected_api_permissions, current_perms->apis()); | 1593 ASSERT_EQ(expected_api_permissions, current_perms->apis()); |
1591 ASSERT_EQ(expected_host_permissions, current_perms->effective_hosts()); | 1594 ASSERT_EQ(expected_host_permissions, current_perms->effective_hosts()); |
1592 | 1595 |
1593 // Tests that the extension is disabled when a host permission is missing from | 1596 // Tests that the extension is disabled when a host permission is missing from |
1594 // the extension's granted host permissions preference. (This simulates | 1597 // the extension's granted host permissions preference. (This simulates |
1595 // updating the browser to a version which recognizes additional host | 1598 // updating the browser to a version which recognizes additional host |
1596 // permissions). | 1599 // permissions). |
1597 host_permissions.clear(); | 1600 host_permissions.clear(); |
1598 current_perms = NULL; | 1601 current_perms = NULL; |
1599 | 1602 |
1600 host_permissions.insert("http://*.google.com/*"); | 1603 host_permissions.insert("http://*.google.com/*"); |
1601 host_permissions.insert("https://*.google.com/*"); | 1604 host_permissions.insert("https://*.google.com/*"); |
1602 host_permissions.insert("http://*.google.com.hk/*"); | 1605 host_permissions.insert("http://*.google.com.hk/*"); |
1603 | 1606 |
1604 ListValue* api_permissions = new ListValue(); | 1607 ListValue* api_permissions = new ListValue(); |
1605 api_permissions->Append( | 1608 api_permissions->Append( |
1606 Value::CreateIntegerValue(ExtensionAPIPermission::kTab)); | 1609 Value::CreateIntegerValue(APIPermission::kTab)); |
1607 SetPref(extension_id, "granted_permissions.api", | 1610 SetPref(extension_id, "granted_permissions.api", |
1608 api_permissions, "granted_permissions.api"); | 1611 api_permissions, "granted_permissions.api"); |
1609 SetPrefStringSet( | 1612 SetPrefStringSet( |
1610 extension_id, "granted_permissions.scriptable_host", host_permissions); | 1613 extension_id, "granted_permissions.scriptable_host", host_permissions); |
1611 | 1614 |
1612 service_->ReloadExtensions(); | 1615 service_->ReloadExtensions(); |
1613 | 1616 |
1614 EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 1617 EXPECT_EQ(1u, service_->disabled_extensions()->size()); |
1615 extension = *service_->disabled_extensions()->begin(); | 1618 extension = *service_->disabled_extensions()->begin(); |
1616 | 1619 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 | 2082 |
2080 int pref_count = 0; | 2083 int pref_count = 0; |
2081 | 2084 |
2082 // Install app1 with unlimited storage. | 2085 // Install app1 with unlimited storage. |
2083 const Extension* extension = | 2086 const Extension* extension = |
2084 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); | 2087 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); |
2085 ValidatePrefKeyCount(++pref_count); | 2088 ValidatePrefKeyCount(++pref_count); |
2086 ASSERT_EQ(1u, service_->extensions()->size()); | 2089 ASSERT_EQ(1u, service_->extensions()->size()); |
2087 const std::string id1 = extension->id(); | 2090 const std::string id1 = extension->id(); |
2088 EXPECT_TRUE(extension->HasAPIPermission( | 2091 EXPECT_TRUE(extension->HasAPIPermission( |
2089 ExtensionAPIPermission::kUnlimitedStorage)); | 2092 APIPermission::kUnlimitedStorage)); |
2090 EXPECT_TRUE(extension->web_extent().MatchesURL( | 2093 EXPECT_TRUE(extension->web_extent().MatchesURL( |
2091 extension->GetFullLaunchURL())); | 2094 extension->GetFullLaunchURL())); |
2092 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); | 2095 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); |
2093 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 2096 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
2094 IsStorageUnlimited(origin1)); | 2097 IsStorageUnlimited(origin1)); |
2095 | 2098 |
2096 // Install app2 from the same origin with unlimited storage. | 2099 // Install app2 from the same origin with unlimited storage. |
2097 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); | 2100 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); |
2098 ValidatePrefKeyCount(++pref_count); | 2101 ValidatePrefKeyCount(++pref_count); |
2099 ASSERT_EQ(2u, service_->extensions()->size()); | 2102 ASSERT_EQ(2u, service_->extensions()->size()); |
2100 const std::string id2 = extension->id(); | 2103 const std::string id2 = extension->id(); |
2101 EXPECT_TRUE(extension->HasAPIPermission( | 2104 EXPECT_TRUE(extension->HasAPIPermission( |
2102 ExtensionAPIPermission::kUnlimitedStorage)); | 2105 APIPermission::kUnlimitedStorage)); |
2103 EXPECT_TRUE(extension->web_extent().MatchesURL( | 2106 EXPECT_TRUE(extension->web_extent().MatchesURL( |
2104 extension->GetFullLaunchURL())); | 2107 extension->GetFullLaunchURL())); |
2105 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); | 2108 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); |
2106 EXPECT_EQ(origin1, origin2); | 2109 EXPECT_EQ(origin1, origin2); |
2107 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 2110 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
2108 IsStorageUnlimited(origin2)); | 2111 IsStorageUnlimited(origin2)); |
2109 | 2112 |
2110 | 2113 |
2111 // Uninstall one of them, unlimited storage should still be granted | 2114 // Uninstall one of them, unlimited storage should still be granted |
2112 // to the origin. | 2115 // to the origin. |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 extension_with_plugin_path); | 2452 extension_with_plugin_path); |
2450 loop_.RunAllPending(); | 2453 loop_.RunAllPending(); |
2451 EXPECT_EQ(0u, GetErrors().size()); | 2454 EXPECT_EQ(0u, GetErrors().size()); |
2452 EXPECT_EQ(2u, loaded_.size()); | 2455 EXPECT_EQ(2u, loaded_.size()); |
2453 EXPECT_EQ(2u, service_->extensions()->size()); | 2456 EXPECT_EQ(2u, service_->extensions()->size()); |
2454 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 2457 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
2455 EXPECT_TRUE(service_->extensions()->Contains(good1)); | 2458 EXPECT_TRUE(service_->extensions()->Contains(good1)); |
2456 EXPECT_TRUE(service_->extensions()->Contains(good2)); | 2459 EXPECT_TRUE(service_->extensions()->Contains(good2)); |
2457 | 2460 |
2458 // Make sure the granted permissions have been setup. | 2461 // Make sure the granted permissions have been setup. |
2459 scoped_refptr<ExtensionPermissionSet> permissions( | 2462 scoped_refptr<PermissionSet> permissions( |
2460 service_->extension_prefs()->GetGrantedPermissions(good1)); | 2463 service_->extension_prefs()->GetGrantedPermissions(good1)); |
2461 EXPECT_FALSE(permissions->IsEmpty()); | 2464 EXPECT_FALSE(permissions->IsEmpty()); |
2462 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); | 2465 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); |
2463 EXPECT_FALSE(permissions->apis().empty()); | 2466 EXPECT_FALSE(permissions->apis().empty()); |
2464 EXPECT_TRUE(permissions->HasAPIPermission(ExtensionAPIPermission::kPlugin)); | 2467 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); |
2465 | 2468 |
2466 // We should be able to reload the extension without getting another prompt. | 2469 // We should be able to reload the extension without getting another prompt. |
2467 loaded_.clear(); | 2470 loaded_.clear(); |
2468 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 2471 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
2469 switches::kAppsGalleryInstallAutoConfirmForTests, | 2472 switches::kAppsGalleryInstallAutoConfirmForTests, |
2470 "cancel"); | 2473 "cancel"); |
2471 | 2474 |
2472 service_->ReloadExtension(good1); | 2475 service_->ReloadExtension(good1); |
2473 loop_.RunAllPending(); | 2476 loop_.RunAllPending(); |
2474 EXPECT_EQ(1u, loaded_.size()); | 2477 EXPECT_EQ(1u, loaded_.size()); |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3373 | 3376 |
3374 int pref_count = 0; | 3377 int pref_count = 0; |
3375 | 3378 |
3376 // Install app1 with unlimited storage. | 3379 // Install app1 with unlimited storage. |
3377 const Extension* extension = | 3380 const Extension* extension = |
3378 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); | 3381 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); |
3379 ValidatePrefKeyCount(++pref_count); | 3382 ValidatePrefKeyCount(++pref_count); |
3380 ASSERT_EQ(1u, service_->extensions()->size()); | 3383 ASSERT_EQ(1u, service_->extensions()->size()); |
3381 const std::string id1 = extension->id(); | 3384 const std::string id1 = extension->id(); |
3382 EXPECT_TRUE(extension->HasAPIPermission( | 3385 EXPECT_TRUE(extension->HasAPIPermission( |
3383 ExtensionAPIPermission::kUnlimitedStorage)); | 3386 APIPermission::kUnlimitedStorage)); |
3384 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); | 3387 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); |
3385 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 3388 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
3386 IsStorageUnlimited(origin1)); | 3389 IsStorageUnlimited(origin1)); |
3387 string16 origin_id = | 3390 string16 origin_id = |
3388 webkit_database::DatabaseUtil::GetOriginIdentifier(origin1); | 3391 webkit_database::DatabaseUtil::GetOriginIdentifier(origin1); |
3389 | 3392 |
3390 // Install app2 from the same origin with unlimited storage. | 3393 // Install app2 from the same origin with unlimited storage. |
3391 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); | 3394 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); |
3392 ValidatePrefKeyCount(++pref_count); | 3395 ValidatePrefKeyCount(++pref_count); |
3393 ASSERT_EQ(2u, service_->extensions()->size()); | 3396 ASSERT_EQ(2u, service_->extensions()->size()); |
3394 const std::string id2 = extension->id(); | 3397 const std::string id2 = extension->id(); |
3395 EXPECT_TRUE(extension->HasAPIPermission( | 3398 EXPECT_TRUE(extension->HasAPIPermission( |
3396 ExtensionAPIPermission::kUnlimitedStorage)); | 3399 APIPermission::kUnlimitedStorage)); |
3397 EXPECT_TRUE(extension->web_extent().MatchesURL( | 3400 EXPECT_TRUE(extension->web_extent().MatchesURL( |
3398 extension->GetFullLaunchURL())); | 3401 extension->GetFullLaunchURL())); |
3399 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); | 3402 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); |
3400 EXPECT_EQ(origin1, origin2); | 3403 EXPECT_EQ(origin1, origin2); |
3401 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 3404 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
3402 IsStorageUnlimited(origin2)); | 3405 IsStorageUnlimited(origin2)); |
3403 | 3406 |
3404 // Set a cookie for the extension. | 3407 // Set a cookie for the extension. |
3405 net::CookieMonster* cookie_monster = | 3408 net::CookieMonster* cookie_monster = |
3406 profile_->GetRequestContext()->GetURLRequestContext()-> | 3409 profile_->GetRequestContext()->GetURLRequestContext()-> |
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5188 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", | 5191 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", |
5189 data_dir_.AppendASCII("hosted_app.crx")); | 5192 data_dir_.AppendASCII("hosted_app.crx")); |
5190 | 5193 |
5191 service_->CheckForExternalUpdates(); | 5194 service_->CheckForExternalUpdates(); |
5192 loop_.RunAllPending(); | 5195 loop_.RunAllPending(); |
5193 | 5196 |
5194 ASSERT_TRUE(service_->PopulateExtensionGlobalError( | 5197 ASSERT_TRUE(service_->PopulateExtensionGlobalError( |
5195 extension_global_error.get())); | 5198 extension_global_error.get())); |
5196 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); | 5199 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); |
5197 } | 5200 } |
OLD | NEW |