| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 Manifest::Location location); | 668 Manifest::Location location); |
| 669 | 669 |
| 670 void PackCRX(const base::FilePath& dir_path, | 670 void PackCRX(const base::FilePath& dir_path, |
| 671 const base::FilePath& pem_path, | 671 const base::FilePath& pem_path, |
| 672 const base::FilePath& crx_path) { | 672 const base::FilePath& crx_path) { |
| 673 // Use the existing pem key, if provided. | 673 // Use the existing pem key, if provided. |
| 674 base::FilePath pem_output_path; | 674 base::FilePath pem_output_path; |
| 675 if (pem_path.value().empty()) { | 675 if (pem_path.value().empty()) { |
| 676 pem_output_path = crx_path.DirName().AppendASCII("temp.pem"); | 676 pem_output_path = crx_path.DirName().AppendASCII("temp.pem"); |
| 677 } else { | 677 } else { |
| 678 ASSERT_TRUE(file_util::PathExists(pem_path)); | 678 ASSERT_TRUE(base::PathExists(pem_path)); |
| 679 } | 679 } |
| 680 | 680 |
| 681 ASSERT_TRUE(base::Delete(crx_path, false)); | 681 ASSERT_TRUE(base::Delete(crx_path, false)); |
| 682 | 682 |
| 683 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); | 683 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); |
| 684 ASSERT_TRUE(creator->Run(dir_path, | 684 ASSERT_TRUE(creator->Run(dir_path, |
| 685 crx_path, | 685 crx_path, |
| 686 pem_path, | 686 pem_path, |
| 687 pem_output_path, | 687 pem_output_path, |
| 688 ExtensionCreator::kOverwriteCRX)); | 688 ExtensionCreator::kOverwriteCRX)); |
| 689 | 689 |
| 690 ASSERT_TRUE(file_util::PathExists(crx_path)); | 690 ASSERT_TRUE(base::PathExists(crx_path)); |
| 691 } | 691 } |
| 692 | 692 |
| 693 // Create a CrxInstaller and start installation. To allow the install | 693 // Create a CrxInstaller and start installation. To allow the install |
| 694 // to happen, use loop_.RunUntilIdle();. Most tests will not use this | 694 // to happen, use loop_.RunUntilIdle();. Most tests will not use this |
| 695 // method directly. Instead, use InstallCrx(), which waits for | 695 // method directly. Instead, use InstallCrx(), which waits for |
| 696 // the crx to be installed and does extra error checking. | 696 // the crx to be installed and does extra error checking. |
| 697 void StartCRXInstall(const base::FilePath& crx_path) { | 697 void StartCRXInstall(const base::FilePath& crx_path) { |
| 698 StartCRXInstall(crx_path, Extension::NO_FLAGS); | 698 StartCRXInstall(crx_path, Extension::NO_FLAGS); |
| 699 } | 699 } |
| 700 | 700 |
| 701 void StartCRXInstall(const base::FilePath& crx_path, int creation_flags) { | 701 void StartCRXInstall(const base::FilePath& crx_path, int creation_flags) { |
| 702 ASSERT_TRUE(file_util::PathExists(crx_path)) | 702 ASSERT_TRUE(base::PathExists(crx_path)) |
| 703 << "Path does not exist: "<< crx_path.value().c_str(); | 703 << "Path does not exist: "<< crx_path.value().c_str(); |
| 704 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); | 704 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); |
| 705 installer->set_creation_flags(creation_flags); | 705 installer->set_creation_flags(creation_flags); |
| 706 if (!(creation_flags & Extension::WAS_INSTALLED_BY_DEFAULT)) { | 706 if (!(creation_flags & Extension::WAS_INSTALLED_BY_DEFAULT)) { |
| 707 installer->set_allow_silent_install(true); | 707 installer->set_allow_silent_install(true); |
| 708 } | 708 } |
| 709 | 709 |
| 710 content::WindowedNotificationObserver windowed_observer( | 710 content::WindowedNotificationObserver windowed_observer( |
| 711 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 711 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 712 content::Source<extensions::CrxInstaller>(installer)); | 712 content::Source<extensions::CrxInstaller>(installer)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 | 777 |
| 778 const Extension* InstallCRXFromWebStore(const base::FilePath& path, | 778 const Extension* InstallCRXFromWebStore(const base::FilePath& path, |
| 779 InstallState install_state) { | 779 InstallState install_state) { |
| 780 StartCRXInstall(path, Extension::FROM_WEBSTORE); | 780 StartCRXInstall(path, Extension::FROM_WEBSTORE); |
| 781 return WaitForCrxInstall(path, install_state); | 781 return WaitForCrxInstall(path, install_state); |
| 782 } | 782 } |
| 783 | 783 |
| 784 const Extension* InstallCRXWithLocation(const base::FilePath& crx_path, | 784 const Extension* InstallCRXWithLocation(const base::FilePath& crx_path, |
| 785 Manifest::Location install_location, | 785 Manifest::Location install_location, |
| 786 InstallState install_state) { | 786 InstallState install_state) { |
| 787 EXPECT_TRUE(file_util::PathExists(crx_path)) | 787 EXPECT_TRUE(base::PathExists(crx_path)) |
| 788 << "Path does not exist: "<< crx_path.value().c_str(); | 788 << "Path does not exist: "<< crx_path.value().c_str(); |
| 789 // no client (silent install) | 789 // no client (silent install) |
| 790 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); | 790 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); |
| 791 installer->set_install_source(install_location); | 791 installer->set_install_source(install_location); |
| 792 installer->InstallCrx(crx_path); | 792 installer->InstallCrx(crx_path); |
| 793 | 793 |
| 794 return WaitForCrxInstall(crx_path, install_state); | 794 return WaitForCrxInstall(crx_path, install_state); |
| 795 } | 795 } |
| 796 | 796 |
| 797 // Wait for a CrxInstaller to finish. Used by InstallCRX. Set the | 797 // Wait for a CrxInstaller to finish. Used by InstallCRX. Set the |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 " }\n" | 879 " }\n" |
| 880 " ]\n" | 880 " ]\n" |
| 881 "}"; | 881 "}"; |
| 882 gpu::GPUInfo gpu_info; | 882 gpu::GPUInfo gpu_info; |
| 883 content::GpuDataManager::GetInstance()->InitializeForTesting( | 883 content::GpuDataManager::GetInstance()->InitializeForTesting( |
| 884 json_blacklist, gpu_info); | 884 json_blacklist, gpu_info); |
| 885 } | 885 } |
| 886 | 886 |
| 887 void UpdateExtension(const std::string& id, const base::FilePath& in_path, | 887 void UpdateExtension(const std::string& id, const base::FilePath& in_path, |
| 888 UpdateState expected_state) { | 888 UpdateState expected_state) { |
| 889 ASSERT_TRUE(file_util::PathExists(in_path)); | 889 ASSERT_TRUE(base::PathExists(in_path)); |
| 890 | 890 |
| 891 // We need to copy this to a temporary location because Update() will delete | 891 // We need to copy this to a temporary location because Update() will delete |
| 892 // it. | 892 // it. |
| 893 base::FilePath path = temp_dir_.path(); | 893 base::FilePath path = temp_dir_.path(); |
| 894 path = path.Append(in_path.BaseName()); | 894 path = path.Append(in_path.BaseName()); |
| 895 ASSERT_TRUE(base::CopyFile(in_path, path)); | 895 ASSERT_TRUE(base::CopyFile(in_path, path)); |
| 896 | 896 |
| 897 int previous_enabled_extension_count = | 897 int previous_enabled_extension_count = |
| 898 service_->extensions()->size(); | 898 service_->extensions()->size(); |
| 899 int previous_installed_extension_count = | 899 int previous_installed_extension_count = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 (expected_state >= INSTALLED) ? 1 : 0; | 931 (expected_state >= INSTALLED) ? 1 : 0; |
| 932 int expected_enabled_extension_count = | 932 int expected_enabled_extension_count = |
| 933 (expected_state >= ENABLED) ? 1 : 0; | 933 (expected_state >= ENABLED) ? 1 : 0; |
| 934 EXPECT_EQ(expected_installed_extension_count, | 934 EXPECT_EQ(expected_installed_extension_count, |
| 935 installed_extension_count); | 935 installed_extension_count); |
| 936 EXPECT_EQ(expected_enabled_extension_count, | 936 EXPECT_EQ(expected_enabled_extension_count, |
| 937 enabled_extension_count); | 937 enabled_extension_count); |
| 938 } | 938 } |
| 939 | 939 |
| 940 // Update() should the temporary input file. | 940 // Update() should the temporary input file. |
| 941 EXPECT_FALSE(file_util::PathExists(path)); | 941 EXPECT_FALSE(base::PathExists(path)); |
| 942 } | 942 } |
| 943 | 943 |
| 944 void TerminateExtension(const std::string& id) { | 944 void TerminateExtension(const std::string& id) { |
| 945 const Extension* extension = service_->GetInstalledExtension(id); | 945 const Extension* extension = service_->GetInstalledExtension(id); |
| 946 if (!extension) { | 946 if (!extension) { |
| 947 ADD_FAILURE(); | 947 ADD_FAILURE(); |
| 948 return; | 948 return; |
| 949 } | 949 } |
| 950 service_->TrackTerminatedExtensionForTest(extension); | 950 service_->TrackTerminatedExtensionForTest(extension); |
| 951 } | 951 } |
| 952 | 952 |
| 953 size_t GetPrefKeyCount() { | 953 size_t GetPrefKeyCount() { |
| 954 const DictionaryValue* dict = | 954 const DictionaryValue* dict = |
| 955 profile_->GetPrefs()->GetDictionary("extensions.settings"); | 955 profile_->GetPrefs()->GetDictionary("extensions.settings"); |
| 956 if (!dict) { | 956 if (!dict) { |
| 957 ADD_FAILURE(); | 957 ADD_FAILURE(); |
| 958 return 0; | 958 return 0; |
| 959 } | 959 } |
| 960 return dict->size(); | 960 return dict->size(); |
| 961 } | 961 } |
| 962 | 962 |
| 963 void UninstallExtension(const std::string& id, bool use_helper) { | 963 void UninstallExtension(const std::string& id, bool use_helper) { |
| 964 // Verify that the extension is installed. | 964 // Verify that the extension is installed. |
| 965 base::FilePath extension_path = extensions_install_dir_.AppendASCII(id); | 965 base::FilePath extension_path = extensions_install_dir_.AppendASCII(id); |
| 966 EXPECT_TRUE(file_util::PathExists(extension_path)); | 966 EXPECT_TRUE(base::PathExists(extension_path)); |
| 967 size_t pref_key_count = GetPrefKeyCount(); | 967 size_t pref_key_count = GetPrefKeyCount(); |
| 968 EXPECT_GT(pref_key_count, 0u); | 968 EXPECT_GT(pref_key_count, 0u); |
| 969 ValidateIntegerPref(id, "state", Extension::ENABLED); | 969 ValidateIntegerPref(id, "state", Extension::ENABLED); |
| 970 | 970 |
| 971 // Uninstall it. | 971 // Uninstall it. |
| 972 if (use_helper) { | 972 if (use_helper) { |
| 973 EXPECT_TRUE(ExtensionService::UninstallExtensionHelper(service_, id)); | 973 EXPECT_TRUE(ExtensionService::UninstallExtensionHelper(service_, id)); |
| 974 } else { | 974 } else { |
| 975 EXPECT_TRUE(service_->UninstallExtension(id, false, NULL)); | 975 EXPECT_TRUE(service_->UninstallExtension(id, false, NULL)); |
| 976 } | 976 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 987 Extension::EXTERNAL_EXTENSION_UNINSTALLED); | 987 Extension::EXTERNAL_EXTENSION_UNINSTALLED); |
| 988 } else { | 988 } else { |
| 989 EXPECT_EQ(new_pref_key_count, pref_key_count - 1); | 989 EXPECT_EQ(new_pref_key_count, pref_key_count - 1); |
| 990 } | 990 } |
| 991 | 991 |
| 992 // The extension should not be in the service anymore. | 992 // The extension should not be in the service anymore. |
| 993 EXPECT_FALSE(service_->GetInstalledExtension(id)); | 993 EXPECT_FALSE(service_->GetInstalledExtension(id)); |
| 994 loop_.RunUntilIdle(); | 994 loop_.RunUntilIdle(); |
| 995 | 995 |
| 996 // The directory should be gone. | 996 // The directory should be gone. |
| 997 EXPECT_FALSE(file_util::PathExists(extension_path)); | 997 EXPECT_FALSE(base::PathExists(extension_path)); |
| 998 } | 998 } |
| 999 | 999 |
| 1000 void ValidatePrefKeyCount(size_t count) { | 1000 void ValidatePrefKeyCount(size_t count) { |
| 1001 EXPECT_EQ(count, GetPrefKeyCount()); | 1001 EXPECT_EQ(count, GetPrefKeyCount()); |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 void ValidateBooleanPref(const std::string& extension_id, | 1004 void ValidateBooleanPref(const std::string& extension_id, |
| 1005 const std::string& pref_path, | 1005 const std::string& pref_path, |
| 1006 bool expected_val) { | 1006 bool expected_val) { |
| 1007 std::string msg = " while checking: "; | 1007 std::string msg = " while checking: "; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 const base::FilePath& crx_path, | 1198 const base::FilePath& crx_path, |
| 1199 const base::FilePath& private_key_path) { | 1199 const base::FilePath& private_key_path) { |
| 1200 // We got the notification and processed it; we don't expect any further tasks | 1200 // We got the notification and processed it; we don't expect any further tasks |
| 1201 // to be posted to the current thread, so we should stop blocking and continue | 1201 // to be posted to the current thread, so we should stop blocking and continue |
| 1202 // on with the rest of the test. | 1202 // on with the rest of the test. |
| 1203 // This call to |Quit()| matches the call to |Run()| in the | 1203 // This call to |Quit()| matches the call to |Run()| in the |
| 1204 // |PackPunctuatedExtension| test. | 1204 // |PackPunctuatedExtension| test. |
| 1205 base::MessageLoop::current()->Quit(); | 1205 base::MessageLoop::current()->Quit(); |
| 1206 EXPECT_EQ(expected_crx_path_.value(), crx_path.value()); | 1206 EXPECT_EQ(expected_crx_path_.value(), crx_path.value()); |
| 1207 EXPECT_EQ(expected_private_key_path_.value(), private_key_path.value()); | 1207 EXPECT_EQ(expected_private_key_path_.value(), private_key_path.value()); |
| 1208 ASSERT_TRUE(file_util::PathExists(private_key_path)); | 1208 ASSERT_TRUE(base::PathExists(private_key_path)); |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 // The tests are designed so that we never expect to see a packing error. | 1211 // The tests are designed so that we never expect to see a packing error. |
| 1212 void PackExtensionTestClient::OnPackFailure(const std::string& error_message, | 1212 void PackExtensionTestClient::OnPackFailure(const std::string& error_message, |
| 1213 ExtensionCreator::ErrorType type) { | 1213 ExtensionCreator::ErrorType type) { |
| 1214 if (type == ExtensionCreator::kCRXExists) | 1214 if (type == ExtensionCreator::kCRXExists) |
| 1215 FAIL() << "Packing should not fail."; | 1215 FAIL() << "Packing should not fail."; |
| 1216 else | 1216 else |
| 1217 FAIL() << "Existing CRX should have been overwritten."; | 1217 FAIL() << "Existing CRX should have been overwritten."; |
| 1218 } | 1218 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 size_t count = 0; | 1403 size_t count = 0; |
| 1404 while (!dirs.Next().empty()) | 1404 while (!dirs.Next().empty()) |
| 1405 count++; | 1405 count++; |
| 1406 | 1406 |
| 1407 // We should have only gotten two extensions now. | 1407 // We should have only gotten two extensions now. |
| 1408 EXPECT_EQ(2u, count); | 1408 EXPECT_EQ(2u, count); |
| 1409 | 1409 |
| 1410 // And extension1 dir should now be toast. | 1410 // And extension1 dir should now be toast. |
| 1411 base::FilePath extension_dir = extensions_install_dir_ | 1411 base::FilePath extension_dir = extensions_install_dir_ |
| 1412 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj"); | 1412 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj"); |
| 1413 ASSERT_FALSE(file_util::PathExists(extension_dir)); | 1413 ASSERT_FALSE(base::PathExists(extension_dir)); |
| 1414 } | 1414 } |
| 1415 | 1415 |
| 1416 // Test that GarbageCollectExtensions deletes the right versions of an | 1416 // Test that GarbageCollectExtensions deletes the right versions of an |
| 1417 // extension. | 1417 // extension. |
| 1418 TEST_F(ExtensionServiceTest, GarbageCollectWithPendingUpdates) { | 1418 TEST_F(ExtensionServiceTest, GarbageCollectWithPendingUpdates) { |
| 1419 InitPluginService(); | 1419 InitPluginService(); |
| 1420 | 1420 |
| 1421 base::FilePath source_install_dir = data_dir_ | 1421 base::FilePath source_install_dir = data_dir_ |
| 1422 .AppendASCII("pending_updates") | 1422 .AppendASCII("pending_updates") |
| 1423 .AppendASCII("Extensions"); | 1423 .AppendASCII("Extensions"); |
| 1424 base::FilePath pref_path = source_install_dir | 1424 base::FilePath pref_path = source_install_dir |
| 1425 .DirName() | 1425 .DirName() |
| 1426 .AppendASCII("Preferences"); | 1426 .AppendASCII("Preferences"); |
| 1427 | 1427 |
| 1428 InitializeInstalledExtensionService(pref_path, source_install_dir); | 1428 InitializeInstalledExtensionService(pref_path, source_install_dir); |
| 1429 | 1429 |
| 1430 // This is the directory that is going to be deleted, so make sure it actually | 1430 // This is the directory that is going to be deleted, so make sure it actually |
| 1431 // is there before the garbage collection. | 1431 // is there before the garbage collection. |
| 1432 ASSERT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1432 ASSERT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1433 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); | 1433 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); |
| 1434 | 1434 |
| 1435 service_->GarbageCollectExtensions(); | 1435 service_->GarbageCollectExtensions(); |
| 1436 // Wait for GarbageCollectExtensions task to complete. | 1436 // Wait for GarbageCollectExtensions task to complete. |
| 1437 loop_.RunUntilIdle(); | 1437 loop_.RunUntilIdle(); |
| 1438 | 1438 |
| 1439 // Verify that the pending update for the first extension didn't get | 1439 // Verify that the pending update for the first extension didn't get |
| 1440 // deleted. | 1440 // deleted. |
| 1441 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1441 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1442 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); | 1442 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); |
| 1443 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1443 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1444 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0"))); | 1444 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0"))); |
| 1445 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1445 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1446 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); | 1446 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); |
| 1447 EXPECT_FALSE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1447 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1448 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); | 1448 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 // Test that pending updates are properly handled on startup. | 1451 // Test that pending updates are properly handled on startup. |
| 1452 TEST_F(ExtensionServiceTest, UpdateOnStartup) { | 1452 TEST_F(ExtensionServiceTest, UpdateOnStartup) { |
| 1453 InitPluginService(); | 1453 InitPluginService(); |
| 1454 | 1454 |
| 1455 base::FilePath source_install_dir = data_dir_ | 1455 base::FilePath source_install_dir = data_dir_ |
| 1456 .AppendASCII("pending_updates") | 1456 .AppendASCII("pending_updates") |
| 1457 .AppendASCII("Extensions"); | 1457 .AppendASCII("Extensions"); |
| 1458 base::FilePath pref_path = source_install_dir | 1458 base::FilePath pref_path = source_install_dir |
| 1459 .DirName() | 1459 .DirName() |
| 1460 .AppendASCII("Preferences"); | 1460 .AppendASCII("Preferences"); |
| 1461 | 1461 |
| 1462 InitializeInstalledExtensionService(pref_path, source_install_dir); | 1462 InitializeInstalledExtensionService(pref_path, source_install_dir); |
| 1463 | 1463 |
| 1464 // This is the directory that is going to be deleted, so make sure it actually | 1464 // This is the directory that is going to be deleted, so make sure it actually |
| 1465 // is there before the garbage collection. | 1465 // is there before the garbage collection. |
| 1466 ASSERT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1466 ASSERT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1467 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); | 1467 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); |
| 1468 | 1468 |
| 1469 service_->Init(); | 1469 service_->Init(); |
| 1470 // A delayed task to call GarbageCollectExtensions is posted by | 1470 // A delayed task to call GarbageCollectExtensions is posted by |
| 1471 // ExtensionService::Init. As the test won't wait for the delayed task to | 1471 // ExtensionService::Init. As the test won't wait for the delayed task to |
| 1472 // be called, call it manually instead. | 1472 // be called, call it manually instead. |
| 1473 service_->GarbageCollectExtensions(); | 1473 service_->GarbageCollectExtensions(); |
| 1474 // Wait for GarbageCollectExtensions task to complete. | 1474 // Wait for GarbageCollectExtensions task to complete. |
| 1475 loop_.RunUntilIdle(); | 1475 loop_.RunUntilIdle(); |
| 1476 | 1476 |
| 1477 // Verify that the pending update for the first extension got installed. | 1477 // Verify that the pending update for the first extension got installed. |
| 1478 EXPECT_FALSE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1478 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1479 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); | 1479 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); |
| 1480 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1480 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1481 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0"))); | 1481 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0"))); |
| 1482 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1482 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1483 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); | 1483 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); |
| 1484 EXPECT_FALSE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1484 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1485 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); | 1485 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); |
| 1486 | 1486 |
| 1487 // Make sure update information got deleted. | 1487 // Make sure update information got deleted. |
| 1488 ExtensionPrefs* prefs = service_->extension_prefs(); | 1488 ExtensionPrefs* prefs = service_->extension_prefs(); |
| 1489 EXPECT_FALSE( | 1489 EXPECT_FALSE( |
| 1490 prefs->GetDelayedInstallInfo("bjafgdebaacbbbecmhlhpofkepfkgcpa")); | 1490 prefs->GetDelayedInstallInfo("bjafgdebaacbbbecmhlhpofkepfkgcpa")); |
| 1491 } | 1491 } |
| 1492 | 1492 |
| 1493 // Test various cases for delayed install because of missing imports. | 1493 // Test various cases for delayed install because of missing imports. |
| 1494 TEST_F(ExtensionServiceTest, PendingImports) { | 1494 TEST_F(ExtensionServiceTest, PendingImports) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1505 | 1505 |
| 1506 // Verify there are no pending extensions initially. | 1506 // Verify there are no pending extensions initially. |
| 1507 EXPECT_FALSE(service_->pending_extension_manager()->HasPendingExtensions()); | 1507 EXPECT_FALSE(service_->pending_extension_manager()->HasPendingExtensions()); |
| 1508 | 1508 |
| 1509 service_->Init(); | 1509 service_->Init(); |
| 1510 // Wait for GarbageCollectExtensions task to complete. | 1510 // Wait for GarbageCollectExtensions task to complete. |
| 1511 loop_.RunUntilIdle(); | 1511 loop_.RunUntilIdle(); |
| 1512 | 1512 |
| 1513 // These extensions are used by the extensions we test below, they must be | 1513 // These extensions are used by the extensions we test below, they must be |
| 1514 // installed. | 1514 // installed. |
| 1515 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1515 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1516 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); | 1516 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); |
| 1517 EXPECT_TRUE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1517 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1518 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); | 1518 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); |
| 1519 | 1519 |
| 1520 // Each of these extensions should have been rejected because of dependencies | 1520 // Each of these extensions should have been rejected because of dependencies |
| 1521 // that cannot be satisfied. | 1521 // that cannot be satisfied. |
| 1522 ExtensionPrefs* prefs = service_->extension_prefs(); | 1522 ExtensionPrefs* prefs = service_->extension_prefs(); |
| 1523 EXPECT_FALSE( | 1523 EXPECT_FALSE( |
| 1524 prefs->GetDelayedInstallInfo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); | 1524 prefs->GetDelayedInstallInfo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
| 1525 EXPECT_FALSE( | 1525 EXPECT_FALSE( |
| 1526 prefs->GetInstalledExtensionInfo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); | 1526 prefs->GetInstalledExtensionInfo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
| 1527 EXPECT_FALSE( | 1527 EXPECT_FALSE( |
| 1528 prefs->GetDelayedInstallInfo("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); | 1528 prefs->GetDelayedInstallInfo("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); |
| 1529 EXPECT_FALSE( | 1529 EXPECT_FALSE( |
| 1530 prefs->GetInstalledExtensionInfo("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); | 1530 prefs->GetInstalledExtensionInfo("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); |
| 1531 EXPECT_FALSE( | 1531 EXPECT_FALSE( |
| 1532 prefs->GetDelayedInstallInfo("cccccccccccccccccccccccccccccccc")); | 1532 prefs->GetDelayedInstallInfo("cccccccccccccccccccccccccccccccc")); |
| 1533 EXPECT_FALSE( | 1533 EXPECT_FALSE( |
| 1534 prefs->GetInstalledExtensionInfo("cccccccccccccccccccccccccccccccc")); | 1534 prefs->GetInstalledExtensionInfo("cccccccccccccccccccccccccccccccc")); |
| 1535 | 1535 |
| 1536 // Make sure the import started for the extension with a dependency. | 1536 // Make sure the import started for the extension with a dependency. |
| 1537 EXPECT_TRUE( | 1537 EXPECT_TRUE( |
| 1538 prefs->GetDelayedInstallInfo("behllobkkfkfnphdnhnkndlbkcpglgmj")); | 1538 prefs->GetDelayedInstallInfo("behllobkkfkfnphdnhnkndlbkcpglgmj")); |
| 1539 EXPECT_EQ(ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS, | 1539 EXPECT_EQ(ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS, |
| 1540 prefs->GetDelayedInstallReason("behllobkkfkfnphdnhnkndlbkcpglgmj")); | 1540 prefs->GetDelayedInstallReason("behllobkkfkfnphdnhnkndlbkcpglgmj")); |
| 1541 | 1541 |
| 1542 EXPECT_FALSE(file_util::PathExists(extensions_install_dir_.AppendASCII( | 1542 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII( |
| 1543 "behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0"))); | 1543 "behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0"))); |
| 1544 | 1544 |
| 1545 EXPECT_TRUE(service_->pending_extension_manager()->HasPendingExtensions()); | 1545 EXPECT_TRUE(service_->pending_extension_manager()->HasPendingExtensions()); |
| 1546 std::string pending_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); | 1546 std::string pending_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); |
| 1547 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(pending_id)); | 1547 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(pending_id)); |
| 1548 // Remove it because we are not testing the pending extension manager's | 1548 // Remove it because we are not testing the pending extension manager's |
| 1549 // ability to download and install extensions. | 1549 // ability to download and install extensions. |
| 1550 EXPECT_TRUE(service_->pending_extension_manager()->Remove(pending_id)); | 1550 EXPECT_TRUE(service_->pending_extension_manager()->Remove(pending_id)); |
| 1551 } | 1551 } |
| 1552 | 1552 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 | 1794 |
| 1795 // Install a user script (they get converted automatically to an extension) | 1795 // Install a user script (they get converted automatically to an extension) |
| 1796 TEST_F(ExtensionServiceTest, InstallUserScript) { | 1796 TEST_F(ExtensionServiceTest, InstallUserScript) { |
| 1797 // The details of script conversion are tested elsewhere, this just tests | 1797 // The details of script conversion are tested elsewhere, this just tests |
| 1798 // integration with ExtensionService. | 1798 // integration with ExtensionService. |
| 1799 InitializeEmptyExtensionService(); | 1799 InitializeEmptyExtensionService(); |
| 1800 | 1800 |
| 1801 base::FilePath path = data_dir_ | 1801 base::FilePath path = data_dir_ |
| 1802 .AppendASCII("user_script_basic.user.js"); | 1802 .AppendASCII("user_script_basic.user.js"); |
| 1803 | 1803 |
| 1804 ASSERT_TRUE(file_util::PathExists(path)); | 1804 ASSERT_TRUE(base::PathExists(path)); |
| 1805 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); | 1805 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); |
| 1806 installer->set_allow_silent_install(true); | 1806 installer->set_allow_silent_install(true); |
| 1807 installer->InstallUserScript( | 1807 installer->InstallUserScript( |
| 1808 path, | 1808 path, |
| 1809 GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js")); | 1809 GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js")); |
| 1810 | 1810 |
| 1811 loop_.RunUntilIdle(); | 1811 loop_.RunUntilIdle(); |
| 1812 std::vector<string16> errors = GetErrors(); | 1812 std::vector<string16> errors = GetErrors(); |
| 1813 EXPECT_TRUE(installed_) << "Nothing was installed."; | 1813 EXPECT_TRUE(installed_) << "Nothing was installed."; |
| 1814 EXPECT_FALSE(was_update_) << path.value(); | 1814 EXPECT_FALSE(was_update_) << path.value(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1844 // This tests that the granted permissions preferences are correctly set when | 1844 // This tests that the granted permissions preferences are correctly set when |
| 1845 // installing an extension. | 1845 // installing an extension. |
| 1846 TEST_F(ExtensionServiceTest, GrantedPermissions) { | 1846 TEST_F(ExtensionServiceTest, GrantedPermissions) { |
| 1847 InitializeEmptyExtensionService(); | 1847 InitializeEmptyExtensionService(); |
| 1848 base::FilePath path = data_dir_ | 1848 base::FilePath path = data_dir_ |
| 1849 .AppendASCII("permissions"); | 1849 .AppendASCII("permissions"); |
| 1850 | 1850 |
| 1851 base::FilePath pem_path = path.AppendASCII("unknown.pem"); | 1851 base::FilePath pem_path = path.AppendASCII("unknown.pem"); |
| 1852 path = path.AppendASCII("unknown"); | 1852 path = path.AppendASCII("unknown"); |
| 1853 | 1853 |
| 1854 ASSERT_TRUE(file_util::PathExists(pem_path)); | 1854 ASSERT_TRUE(base::PathExists(pem_path)); |
| 1855 ASSERT_TRUE(file_util::PathExists(path)); | 1855 ASSERT_TRUE(base::PathExists(path)); |
| 1856 | 1856 |
| 1857 ExtensionPrefs* prefs = service_->extension_prefs(); | 1857 ExtensionPrefs* prefs = service_->extension_prefs(); |
| 1858 | 1858 |
| 1859 APIPermissionSet expected_api_perms; | 1859 APIPermissionSet expected_api_perms; |
| 1860 URLPatternSet expected_host_perms; | 1860 URLPatternSet expected_host_perms; |
| 1861 | 1861 |
| 1862 // Make sure there aren't any granted permissions before the | 1862 // Make sure there aren't any granted permissions before the |
| 1863 // extension is installed. | 1863 // extension is installed. |
| 1864 scoped_refptr<PermissionSet> known_perms( | 1864 scoped_refptr<PermissionSet> known_perms( |
| 1865 prefs->GetGrantedPermissions(permissions_crx)); | 1865 prefs->GetGrantedPermissions(permissions_crx)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1893 // default apps. | 1893 // default apps. |
| 1894 TEST_F(ExtensionServiceTest, DefaultAppsGrantedPermissions) { | 1894 TEST_F(ExtensionServiceTest, DefaultAppsGrantedPermissions) { |
| 1895 InitializeEmptyExtensionService(); | 1895 InitializeEmptyExtensionService(); |
| 1896 InitializeRequestContext(); | 1896 InitializeRequestContext(); |
| 1897 base::FilePath path = data_dir_ | 1897 base::FilePath path = data_dir_ |
| 1898 .AppendASCII("permissions"); | 1898 .AppendASCII("permissions"); |
| 1899 | 1899 |
| 1900 base::FilePath pem_path = path.AppendASCII("unknown.pem"); | 1900 base::FilePath pem_path = path.AppendASCII("unknown.pem"); |
| 1901 path = path.AppendASCII("unknown"); | 1901 path = path.AppendASCII("unknown"); |
| 1902 | 1902 |
| 1903 ASSERT_TRUE(file_util::PathExists(pem_path)); | 1903 ASSERT_TRUE(base::PathExists(pem_path)); |
| 1904 ASSERT_TRUE(file_util::PathExists(path)); | 1904 ASSERT_TRUE(base::PathExists(path)); |
| 1905 | 1905 |
| 1906 ExtensionPrefs* prefs = service_->extension_prefs(); | 1906 ExtensionPrefs* prefs = service_->extension_prefs(); |
| 1907 | 1907 |
| 1908 APIPermissionSet expected_api_perms; | 1908 APIPermissionSet expected_api_perms; |
| 1909 URLPatternSet expected_host_perms; | 1909 URLPatternSet expected_host_perms; |
| 1910 | 1910 |
| 1911 // Make sure there aren't any granted permissions before the | 1911 // Make sure there aren't any granted permissions before the |
| 1912 // extension is installed. | 1912 // extension is installed. |
| 1913 scoped_refptr<PermissionSet> known_perms( | 1913 scoped_refptr<PermissionSet> known_perms( |
| 1914 prefs->GetGrantedPermissions(permissions_crx)); | 1914 prefs->GetGrantedPermissions(permissions_crx)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1940 InitPluginService(); | 1940 InitPluginService(); |
| 1941 | 1941 |
| 1942 InitializeEmptyExtensionService(); | 1942 InitializeEmptyExtensionService(); |
| 1943 | 1943 |
| 1944 base::FilePath path = data_dir_ | 1944 base::FilePath path = data_dir_ |
| 1945 .AppendASCII("good") | 1945 .AppendASCII("good") |
| 1946 .AppendASCII("Extensions") | 1946 .AppendASCII("Extensions") |
| 1947 .AppendASCII(good1) | 1947 .AppendASCII(good1) |
| 1948 .AppendASCII("2"); | 1948 .AppendASCII("2"); |
| 1949 | 1949 |
| 1950 ASSERT_TRUE(file_util::PathExists(path)); | 1950 ASSERT_TRUE(base::PathExists(path)); |
| 1951 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); | 1951 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); |
| 1952 EXPECT_EQ(0u, GetErrors().size()); | 1952 EXPECT_EQ(0u, GetErrors().size()); |
| 1953 EXPECT_EQ(1u, service_->extensions()->size()); | 1953 EXPECT_EQ(1u, service_->extensions()->size()); |
| 1954 ExtensionPrefs* prefs = service_->extension_prefs(); | 1954 ExtensionPrefs* prefs = service_->extension_prefs(); |
| 1955 | 1955 |
| 1956 scoped_refptr<PermissionSet> permissions( | 1956 scoped_refptr<PermissionSet> permissions( |
| 1957 prefs->GetGrantedPermissions(extension->id())); | 1957 prefs->GetGrantedPermissions(extension->id())); |
| 1958 EXPECT_FALSE(permissions->IsEmpty()); | 1958 EXPECT_FALSE(permissions->IsEmpty()); |
| 1959 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); | 1959 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); |
| 1960 EXPECT_FALSE(permissions->apis().empty()); | 1960 EXPECT_FALSE(permissions->apis().empty()); |
| 1961 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); | 1961 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); |
| 1962 | 1962 |
| 1963 // Full access implies full host access too... | 1963 // Full access implies full host access too... |
| 1964 EXPECT_TRUE(permissions->HasEffectiveAccessToAllHosts()); | 1964 EXPECT_TRUE(permissions->HasEffectiveAccessToAllHosts()); |
| 1965 } | 1965 } |
| 1966 #endif | 1966 #endif |
| 1967 | 1967 |
| 1968 // Tests that the extension is disabled when permissions are missing from | 1968 // Tests that the extension is disabled when permissions are missing from |
| 1969 // the extension's granted permissions preferences. (This simulates updating | 1969 // the extension's granted permissions preferences. (This simulates updating |
| 1970 // the browser to a version which recognizes more permissions). | 1970 // the browser to a version which recognizes more permissions). |
| 1971 TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) { | 1971 TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) { |
| 1972 InitializeEmptyExtensionService(); | 1972 InitializeEmptyExtensionService(); |
| 1973 | 1973 |
| 1974 base::FilePath path = data_dir_ | 1974 base::FilePath path = data_dir_ |
| 1975 .AppendASCII("permissions") | 1975 .AppendASCII("permissions") |
| 1976 .AppendASCII("unknown"); | 1976 .AppendASCII("unknown"); |
| 1977 | 1977 |
| 1978 ASSERT_TRUE(file_util::PathExists(path)); | 1978 ASSERT_TRUE(base::PathExists(path)); |
| 1979 | 1979 |
| 1980 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); | 1980 const Extension* extension = PackAndInstallCRX(path, INSTALL_NEW); |
| 1981 | 1981 |
| 1982 EXPECT_EQ(0u, GetErrors().size()); | 1982 EXPECT_EQ(0u, GetErrors().size()); |
| 1983 EXPECT_EQ(1u, service_->extensions()->size()); | 1983 EXPECT_EQ(1u, service_->extensions()->size()); |
| 1984 std::string extension_id = extension->id(); | 1984 std::string extension_id = extension->id(); |
| 1985 | 1985 |
| 1986 ExtensionPrefs* prefs = service_->extension_prefs(); | 1986 ExtensionPrefs* prefs = service_->extension_prefs(); |
| 1987 | 1987 |
| 1988 APIPermissionSet expected_api_permissions; | 1988 APIPermissionSet expected_api_permissions; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 base::ScopedTempDir temp_dir; | 2079 base::ScopedTempDir temp_dir; |
| 2080 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 2080 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 2081 base::FilePath output_directory = temp_dir.path(); | 2081 base::FilePath output_directory = temp_dir.path(); |
| 2082 | 2082 |
| 2083 base::FilePath crx_path(output_directory.AppendASCII("ex1.crx")); | 2083 base::FilePath crx_path(output_directory.AppendASCII("ex1.crx")); |
| 2084 base::FilePath privkey_path(output_directory.AppendASCII("privkey.pem")); | 2084 base::FilePath privkey_path(output_directory.AppendASCII("privkey.pem")); |
| 2085 | 2085 |
| 2086 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); | 2086 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); |
| 2087 ASSERT_TRUE(creator->Run(input_directory, crx_path, base::FilePath(), | 2087 ASSERT_TRUE(creator->Run(input_directory, crx_path, base::FilePath(), |
| 2088 privkey_path, ExtensionCreator::kNoRunFlags)); | 2088 privkey_path, ExtensionCreator::kNoRunFlags)); |
| 2089 ASSERT_TRUE(file_util::PathExists(crx_path)); | 2089 ASSERT_TRUE(base::PathExists(crx_path)); |
| 2090 ASSERT_TRUE(file_util::PathExists(privkey_path)); | 2090 ASSERT_TRUE(base::PathExists(privkey_path)); |
| 2091 | 2091 |
| 2092 // Repeat the run with the pem file gone, and no special flags | 2092 // Repeat the run with the pem file gone, and no special flags |
| 2093 // Should refuse to overwrite the existing crx. | 2093 // Should refuse to overwrite the existing crx. |
| 2094 base::Delete(privkey_path, false); | 2094 base::Delete(privkey_path, false); |
| 2095 ASSERT_FALSE(creator->Run(input_directory, crx_path, base::FilePath(), | 2095 ASSERT_FALSE(creator->Run(input_directory, crx_path, base::FilePath(), |
| 2096 privkey_path, ExtensionCreator::kNoRunFlags)); | 2096 privkey_path, ExtensionCreator::kNoRunFlags)); |
| 2097 | 2097 |
| 2098 // OK, now try it with a flag to overwrite existing crx. Should work. | 2098 // OK, now try it with a flag to overwrite existing crx. Should work. |
| 2099 ASSERT_TRUE(creator->Run(input_directory, crx_path, base::FilePath(), | 2099 ASSERT_TRUE(creator->Run(input_directory, crx_path, base::FilePath(), |
| 2100 privkey_path, ExtensionCreator::kOverwriteCRX)); | 2100 privkey_path, ExtensionCreator::kOverwriteCRX)); |
| 2101 | 2101 |
| 2102 // Repeat the run allowing existing crx, but the existing pem is still | 2102 // Repeat the run allowing existing crx, but the existing pem is still |
| 2103 // an error. Should fail. | 2103 // an error. Should fail. |
| 2104 ASSERT_FALSE(creator->Run(input_directory, crx_path, base::FilePath(), | 2104 ASSERT_FALSE(creator->Run(input_directory, crx_path, base::FilePath(), |
| 2105 privkey_path, ExtensionCreator::kOverwriteCRX)); | 2105 privkey_path, ExtensionCreator::kOverwriteCRX)); |
| 2106 | 2106 |
| 2107 ASSERT_TRUE(file_util::PathExists(privkey_path)); | 2107 ASSERT_TRUE(base::PathExists(privkey_path)); |
| 2108 InstallCRX(crx_path, INSTALL_NEW); | 2108 InstallCRX(crx_path, INSTALL_NEW); |
| 2109 | 2109 |
| 2110 // Try packing with invalid paths. | 2110 // Try packing with invalid paths. |
| 2111 creator.reset(new ExtensionCreator()); | 2111 creator.reset(new ExtensionCreator()); |
| 2112 ASSERT_FALSE( | 2112 ASSERT_FALSE( |
| 2113 creator->Run(base::FilePath(), base::FilePath(), base::FilePath(), | 2113 creator->Run(base::FilePath(), base::FilePath(), base::FilePath(), |
| 2114 base::FilePath(), ExtensionCreator::kOverwriteCRX)); | 2114 base::FilePath(), ExtensionCreator::kOverwriteCRX)); |
| 2115 | 2115 |
| 2116 // Try packing an empty directory. Should fail because an empty directory is | 2116 // Try packing an empty directory. Should fail because an empty directory is |
| 2117 // not a valid extension. | 2117 // not a valid extension. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 base::FilePath output_directory = output_temp_dir.path(); | 2218 base::FilePath output_directory = output_temp_dir.path(); |
| 2219 | 2219 |
| 2220 base::FilePath crx_path(output_directory.AppendASCII("ex1.crx")); | 2220 base::FilePath crx_path(output_directory.AppendASCII("ex1.crx")); |
| 2221 base::FilePath privkey_path(output_directory.AppendASCII("privkey.pem")); | 2221 base::FilePath privkey_path(output_directory.AppendASCII("privkey.pem")); |
| 2222 | 2222 |
| 2223 // Pack the extension once to get a private key. | 2223 // Pack the extension once to get a private key. |
| 2224 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); | 2224 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); |
| 2225 ASSERT_TRUE(creator->Run(input_directory, crx_path, base::FilePath(), | 2225 ASSERT_TRUE(creator->Run(input_directory, crx_path, base::FilePath(), |
| 2226 privkey_path, ExtensionCreator::kNoRunFlags)) | 2226 privkey_path, ExtensionCreator::kNoRunFlags)) |
| 2227 << creator->error_message(); | 2227 << creator->error_message(); |
| 2228 ASSERT_TRUE(file_util::PathExists(crx_path)); | 2228 ASSERT_TRUE(base::PathExists(crx_path)); |
| 2229 ASSERT_TRUE(file_util::PathExists(privkey_path)); | 2229 ASSERT_TRUE(base::PathExists(privkey_path)); |
| 2230 | 2230 |
| 2231 base::Delete(crx_path, false); | 2231 base::Delete(crx_path, false); |
| 2232 // Move the pem file into the extension. | 2232 // Move the pem file into the extension. |
| 2233 base::Move(privkey_path, | 2233 base::Move(privkey_path, |
| 2234 input_directory.AppendASCII("privkey.pem")); | 2234 input_directory.AppendASCII("privkey.pem")); |
| 2235 | 2235 |
| 2236 // This pack should fail because of the contained private key. | 2236 // This pack should fail because of the contained private key. |
| 2237 EXPECT_FALSE(creator->Run(input_directory, crx_path, base::FilePath(), | 2237 EXPECT_FALSE(creator->Run(input_directory, crx_path, base::FilePath(), |
| 2238 privkey_path, ExtensionCreator::kNoRunFlags)); | 2238 privkey_path, ExtensionCreator::kNoRunFlags)); |
| 2239 EXPECT_THAT(creator->error_message(), | 2239 EXPECT_THAT(creator->error_message(), |
| 2240 testing::ContainsRegex( | 2240 testing::ContainsRegex( |
| 2241 "extension includes the key file.*privkey.pem")); | 2241 "extension includes the key file.*privkey.pem")); |
| 2242 } | 2242 } |
| 2243 | 2243 |
| 2244 // Test Packaging and installing an extension using an openssl generated key. | 2244 // Test Packaging and installing an extension using an openssl generated key. |
| 2245 // The openssl is generated with the following: | 2245 // The openssl is generated with the following: |
| 2246 // > openssl genrsa -out privkey.pem 1024 | 2246 // > openssl genrsa -out privkey.pem 1024 |
| 2247 // > openssl pkcs8 -topk8 -nocrypt -in privkey.pem -out privkey_asn1.pem | 2247 // > openssl pkcs8 -topk8 -nocrypt -in privkey.pem -out privkey_asn1.pem |
| 2248 // The privkey.pem is a PrivateKey, and the pcks8 -topk8 creates a | 2248 // The privkey.pem is a PrivateKey, and the pcks8 -topk8 creates a |
| 2249 // PrivateKeyInfo ASN.1 structure, we our RSAPrivateKey expects. | 2249 // PrivateKeyInfo ASN.1 structure, we our RSAPrivateKey expects. |
| 2250 TEST_F(ExtensionServiceTest, PackExtensionOpenSSLKey) { | 2250 TEST_F(ExtensionServiceTest, PackExtensionOpenSSLKey) { |
| 2251 InitializeEmptyExtensionService(); | 2251 InitializeEmptyExtensionService(); |
| 2252 base::FilePath input_directory = data_dir_ | 2252 base::FilePath input_directory = data_dir_ |
| 2253 .AppendASCII("good") | 2253 .AppendASCII("good") |
| 2254 .AppendASCII("Extensions") | 2254 .AppendASCII("Extensions") |
| 2255 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 2255 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 2256 .AppendASCII("1.0.0.0"); | 2256 .AppendASCII("1.0.0.0"); |
| 2257 base::FilePath privkey_path(data_dir_.AppendASCII( | 2257 base::FilePath privkey_path(data_dir_.AppendASCII( |
| 2258 "openssl_privkey_asn1.pem")); | 2258 "openssl_privkey_asn1.pem")); |
| 2259 ASSERT_TRUE(file_util::PathExists(privkey_path)); | 2259 ASSERT_TRUE(base::PathExists(privkey_path)); |
| 2260 | 2260 |
| 2261 base::ScopedTempDir temp_dir; | 2261 base::ScopedTempDir temp_dir; |
| 2262 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 2262 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 2263 base::FilePath output_directory = temp_dir.path(); | 2263 base::FilePath output_directory = temp_dir.path(); |
| 2264 | 2264 |
| 2265 base::FilePath crx_path(output_directory.AppendASCII("ex1.crx")); | 2265 base::FilePath crx_path(output_directory.AppendASCII("ex1.crx")); |
| 2266 | 2266 |
| 2267 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); | 2267 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); |
| 2268 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path, | 2268 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path, |
| 2269 base::FilePath(), ExtensionCreator::kOverwriteCRX)); | 2269 base::FilePath(), ExtensionCreator::kOverwriteCRX)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2323 ASSERT_EQ(1u, loaded_.size()); | 2323 ASSERT_EQ(1u, loaded_.size()); |
| 2324 EXPECT_EQ(1u, service_->extensions()->size()); | 2324 EXPECT_EQ(1u, service_->extensions()->size()); |
| 2325 const Extension* theme = service_->extensions()->begin()->get(); | 2325 const Extension* theme = service_->extensions()->begin()->get(); |
| 2326 EXPECT_EQ("name", theme->name()); | 2326 EXPECT_EQ("name", theme->name()); |
| 2327 EXPECT_EQ("description", theme->description()); | 2327 EXPECT_EQ("description", theme->description()); |
| 2328 | 2328 |
| 2329 // Cleanup the "Cached Theme.pak" file. Ideally, this would be installed in a | 2329 // Cleanup the "Cached Theme.pak" file. Ideally, this would be installed in a |
| 2330 // temporary directory, but it automatically installs to the extension's | 2330 // temporary directory, but it automatically installs to the extension's |
| 2331 // directory, and we don't want to copy the whole extension for a unittest. | 2331 // directory, and we don't want to copy the whole extension for a unittest. |
| 2332 base::FilePath theme_file = extension_path.Append(chrome::kThemePackFilename); | 2332 base::FilePath theme_file = extension_path.Append(chrome::kThemePackFilename); |
| 2333 ASSERT_TRUE(file_util::PathExists(theme_file)); | 2333 ASSERT_TRUE(base::PathExists(theme_file)); |
| 2334 ASSERT_TRUE(base::Delete(theme_file, false)); // Not recursive. | 2334 ASSERT_TRUE(base::Delete(theme_file, false)); // Not recursive. |
| 2335 } | 2335 } |
| 2336 | 2336 |
| 2337 // Tests that we can change the ID of an unpacked extension by adding a key | 2337 // Tests that we can change the ID of an unpacked extension by adding a key |
| 2338 // to its manifest. | 2338 // to its manifest. |
| 2339 TEST_F(ExtensionServiceTest, UnpackedExtensionCanChangeID) { | 2339 TEST_F(ExtensionServiceTest, UnpackedExtensionCanChangeID) { |
| 2340 InitializeEmptyExtensionService(); | 2340 InitializeEmptyExtensionService(); |
| 2341 | 2341 |
| 2342 base::ScopedTempDir temp; | 2342 base::ScopedTempDir temp; |
| 2343 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 2343 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 2344 | 2344 |
| 2345 base::FilePath extension_path = temp.path(); | 2345 base::FilePath extension_path = temp.path(); |
| 2346 base::FilePath manifest_path = | 2346 base::FilePath manifest_path = |
| 2347 extension_path.Append(extensions::kManifestFilename); | 2347 extension_path.Append(extensions::kManifestFilename); |
| 2348 base::FilePath manifest_no_key = data_dir_. | 2348 base::FilePath manifest_no_key = data_dir_. |
| 2349 AppendASCII("unpacked"). | 2349 AppendASCII("unpacked"). |
| 2350 AppendASCII("manifest_no_key.json"); | 2350 AppendASCII("manifest_no_key.json"); |
| 2351 | 2351 |
| 2352 base::FilePath manifest_with_key = data_dir_. | 2352 base::FilePath manifest_with_key = data_dir_. |
| 2353 AppendASCII("unpacked"). | 2353 AppendASCII("unpacked"). |
| 2354 AppendASCII("manifest_with_key.json"); | 2354 AppendASCII("manifest_with_key.json"); |
| 2355 | 2355 |
| 2356 ASSERT_TRUE(file_util::PathExists(manifest_no_key)); | 2356 ASSERT_TRUE(base::PathExists(manifest_no_key)); |
| 2357 ASSERT_TRUE(file_util::PathExists(manifest_with_key)); | 2357 ASSERT_TRUE(base::PathExists(manifest_with_key)); |
| 2358 | 2358 |
| 2359 // Load the unpacked extension with no key. | 2359 // Load the unpacked extension with no key. |
| 2360 base::CopyFile(manifest_no_key, manifest_path); | 2360 base::CopyFile(manifest_no_key, manifest_path); |
| 2361 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); | 2361 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); |
| 2362 | 2362 |
| 2363 loop_.RunUntilIdle(); | 2363 loop_.RunUntilIdle(); |
| 2364 EXPECT_EQ(0u, GetErrors().size()); | 2364 EXPECT_EQ(0u, GetErrors().size()); |
| 2365 ASSERT_EQ(1u, loaded_.size()); | 2365 ASSERT_EQ(1u, loaded_.size()); |
| 2366 EXPECT_EQ(1u, service_->extensions()->size()); | 2366 EXPECT_EQ(1u, service_->extensions()->size()); |
| 2367 | 2367 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2380 } | 2380 } |
| 2381 | 2381 |
| 2382 #if defined(OS_POSIX) | 2382 #if defined(OS_POSIX) |
| 2383 TEST_F(ExtensionServiceTest, UnpackedExtensionMayContainSymlinkedFiles) { | 2383 TEST_F(ExtensionServiceTest, UnpackedExtensionMayContainSymlinkedFiles) { |
| 2384 base::FilePath source_data_dir = data_dir_. | 2384 base::FilePath source_data_dir = data_dir_. |
| 2385 AppendASCII("unpacked"). | 2385 AppendASCII("unpacked"). |
| 2386 AppendASCII("symlinks_allowed"); | 2386 AppendASCII("symlinks_allowed"); |
| 2387 | 2387 |
| 2388 // Paths to test data files. | 2388 // Paths to test data files. |
| 2389 base::FilePath source_manifest = source_data_dir.AppendASCII("manifest.json"); | 2389 base::FilePath source_manifest = source_data_dir.AppendASCII("manifest.json"); |
| 2390 ASSERT_TRUE(file_util::PathExists(source_manifest)); | 2390 ASSERT_TRUE(base::PathExists(source_manifest)); |
| 2391 base::FilePath source_icon = source_data_dir.AppendASCII("icon.png"); | 2391 base::FilePath source_icon = source_data_dir.AppendASCII("icon.png"); |
| 2392 ASSERT_TRUE(file_util::PathExists(source_icon)); | 2392 ASSERT_TRUE(base::PathExists(source_icon)); |
| 2393 | 2393 |
| 2394 // Set up the temporary extension directory. | 2394 // Set up the temporary extension directory. |
| 2395 base::ScopedTempDir temp; | 2395 base::ScopedTempDir temp; |
| 2396 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 2396 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 2397 base::FilePath extension_path = temp.path(); | 2397 base::FilePath extension_path = temp.path(); |
| 2398 base::FilePath manifest = extension_path.Append( | 2398 base::FilePath manifest = extension_path.Append( |
| 2399 extensions::kManifestFilename); | 2399 extensions::kManifestFilename); |
| 2400 base::FilePath icon_symlink = extension_path.AppendASCII("icon.png"); | 2400 base::FilePath icon_symlink = extension_path.AppendASCII("icon.png"); |
| 2401 base::CopyFile(source_manifest, manifest); | 2401 base::CopyFile(source_manifest, manifest); |
| 2402 file_util::CreateSymbolicLink(source_icon, icon_symlink); | 2402 file_util::CreateSymbolicLink(source_icon, icon_symlink); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2835 InitializeEmptyExtensionService(); | 2835 InitializeEmptyExtensionService(); |
| 2836 | 2836 |
| 2837 base::ScopedTempDir temp; | 2837 base::ScopedTempDir temp; |
| 2838 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 2838 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 2839 | 2839 |
| 2840 // We'll write the extension manifest dynamically to a temporary path | 2840 // We'll write the extension manifest dynamically to a temporary path |
| 2841 // to make it easier to change the version number. | 2841 // to make it easier to change the version number. |
| 2842 base::FilePath extension_path = temp.path(); | 2842 base::FilePath extension_path = temp.path(); |
| 2843 base::FilePath manifest_path = | 2843 base::FilePath manifest_path = |
| 2844 extension_path.Append(extensions::kManifestFilename); | 2844 extension_path.Append(extensions::kManifestFilename); |
| 2845 ASSERT_FALSE(file_util::PathExists(manifest_path)); | 2845 ASSERT_FALSE(base::PathExists(manifest_path)); |
| 2846 | 2846 |
| 2847 // Start with version 2.0. | 2847 // Start with version 2.0. |
| 2848 DictionaryValue manifest; | 2848 DictionaryValue manifest; |
| 2849 manifest.SetString("version", "2.0"); | 2849 manifest.SetString("version", "2.0"); |
| 2850 manifest.SetString("name", "LOAD Downgrade Test"); | 2850 manifest.SetString("name", "LOAD Downgrade Test"); |
| 2851 manifest.SetInteger("manifest_version", 2); | 2851 manifest.SetInteger("manifest_version", 2); |
| 2852 | 2852 |
| 2853 JSONFileValueSerializer serializer(manifest_path); | 2853 JSONFileValueSerializer serializer(manifest_path); |
| 2854 ASSERT_TRUE(serializer.Serialize(manifest)); | 2854 ASSERT_TRUE(serializer.Serialize(manifest)); |
| 2855 | 2855 |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 | 4054 |
| 4055 // Create local storage. We only simulate this by creating the backing files. | 4055 // Create local storage. We only simulate this by creating the backing files. |
| 4056 // Note: This test depends on details of how the dom_storage library | 4056 // Note: This test depends on details of how the dom_storage library |
| 4057 // stores data in the host file system. | 4057 // stores data in the host file system. |
| 4058 base::FilePath lso_dir_path = | 4058 base::FilePath lso_dir_path = |
| 4059 profile_->GetPath().AppendASCII("Local Storage"); | 4059 profile_->GetPath().AppendASCII("Local Storage"); |
| 4060 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) | 4060 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) |
| 4061 .AddExtension(FILE_PATH_LITERAL(".localstorage")); | 4061 .AddExtension(FILE_PATH_LITERAL(".localstorage")); |
| 4062 EXPECT_TRUE(file_util::CreateDirectory(lso_dir_path)); | 4062 EXPECT_TRUE(file_util::CreateDirectory(lso_dir_path)); |
| 4063 EXPECT_EQ(0, file_util::WriteFile(lso_file_path, NULL, 0)); | 4063 EXPECT_EQ(0, file_util::WriteFile(lso_file_path, NULL, 0)); |
| 4064 EXPECT_TRUE(file_util::PathExists(lso_file_path)); | 4064 EXPECT_TRUE(base::PathExists(lso_file_path)); |
| 4065 | 4065 |
| 4066 // Create indexed db. Similarly, it is enough to only simulate this by | 4066 // Create indexed db. Similarly, it is enough to only simulate this by |
| 4067 // creating the directory on the disk. | 4067 // creating the directory on the disk. |
| 4068 IndexedDBContext* idb_context = | 4068 IndexedDBContext* idb_context = |
| 4069 BrowserContext::GetDefaultStoragePartition(profile_.get())-> | 4069 BrowserContext::GetDefaultStoragePartition(profile_.get())-> |
| 4070 GetIndexedDBContext(); | 4070 GetIndexedDBContext(); |
| 4071 idb_context->SetTaskRunnerForTesting( | 4071 idb_context->SetTaskRunnerForTesting( |
| 4072 base::MessageLoop::current()->message_loop_proxy().get()); | 4072 base::MessageLoop::current()->message_loop_proxy().get()); |
| 4073 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); | 4073 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); |
| 4074 EXPECT_TRUE(file_util::CreateDirectory(idb_path)); | 4074 EXPECT_TRUE(file_util::CreateDirectory(idb_path)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4085 base::Unretained(&callback))); | 4085 base::Unretained(&callback))); |
| 4086 loop_.RunUntilIdle(); | 4086 loop_.RunUntilIdle(); |
| 4087 EXPECT_EQ(0U, callback.list_.size()); | 4087 EXPECT_EQ(0U, callback.list_.size()); |
| 4088 | 4088 |
| 4089 // The database should have vanished as well. | 4089 // The database should have vanished as well. |
| 4090 origins.clear(); | 4090 origins.clear(); |
| 4091 db_tracker->GetAllOriginsInfo(&origins); | 4091 db_tracker->GetAllOriginsInfo(&origins); |
| 4092 EXPECT_EQ(0U, origins.size()); | 4092 EXPECT_EQ(0U, origins.size()); |
| 4093 | 4093 |
| 4094 // Check that the LSO file has been removed. | 4094 // Check that the LSO file has been removed. |
| 4095 EXPECT_FALSE(file_util::PathExists(lso_file_path)); | 4095 EXPECT_FALSE(base::PathExists(lso_file_path)); |
| 4096 | 4096 |
| 4097 // Check if the indexed db has disappeared too. | 4097 // Check if the indexed db has disappeared too. |
| 4098 EXPECT_FALSE(file_util::DirectoryExists(idb_path)); | 4098 EXPECT_FALSE(file_util::DirectoryExists(idb_path)); |
| 4099 } | 4099 } |
| 4100 | 4100 |
| 4101 // Verifies app state is removed upon uninstall. | 4101 // Verifies app state is removed upon uninstall. |
| 4102 TEST_F(ExtensionServiceTest, ClearAppData) { | 4102 TEST_F(ExtensionServiceTest, ClearAppData) { |
| 4103 InitializeEmptyExtensionService(); | 4103 InitializeEmptyExtensionService(); |
| 4104 InitializeRequestContext(); | 4104 InitializeRequestContext(); |
| 4105 ExtensionCookieCallback callback; | 4105 ExtensionCookieCallback callback; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4171 | 4171 |
| 4172 // Create local storage. We only simulate this by creating the backing files. | 4172 // Create local storage. We only simulate this by creating the backing files. |
| 4173 // Note: This test depends on details of how the dom_storage library | 4173 // Note: This test depends on details of how the dom_storage library |
| 4174 // stores data in the host file system. | 4174 // stores data in the host file system. |
| 4175 base::FilePath lso_dir_path = | 4175 base::FilePath lso_dir_path = |
| 4176 profile_->GetPath().AppendASCII("Local Storage"); | 4176 profile_->GetPath().AppendASCII("Local Storage"); |
| 4177 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) | 4177 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) |
| 4178 .AddExtension(FILE_PATH_LITERAL(".localstorage")); | 4178 .AddExtension(FILE_PATH_LITERAL(".localstorage")); |
| 4179 EXPECT_TRUE(file_util::CreateDirectory(lso_dir_path)); | 4179 EXPECT_TRUE(file_util::CreateDirectory(lso_dir_path)); |
| 4180 EXPECT_EQ(0, file_util::WriteFile(lso_file_path, NULL, 0)); | 4180 EXPECT_EQ(0, file_util::WriteFile(lso_file_path, NULL, 0)); |
| 4181 EXPECT_TRUE(file_util::PathExists(lso_file_path)); | 4181 EXPECT_TRUE(base::PathExists(lso_file_path)); |
| 4182 | 4182 |
| 4183 // Create indexed db. Similarly, it is enough to only simulate this by | 4183 // Create indexed db. Similarly, it is enough to only simulate this by |
| 4184 // creating the directory on the disk. | 4184 // creating the directory on the disk. |
| 4185 IndexedDBContext* idb_context = | 4185 IndexedDBContext* idb_context = |
| 4186 BrowserContext::GetDefaultStoragePartition(profile_.get())-> | 4186 BrowserContext::GetDefaultStoragePartition(profile_.get())-> |
| 4187 GetIndexedDBContext(); | 4187 GetIndexedDBContext(); |
| 4188 idb_context->SetTaskRunnerForTesting( | 4188 idb_context->SetTaskRunnerForTesting( |
| 4189 base::MessageLoop::current()->message_loop_proxy().get()); | 4189 base::MessageLoop::current()->message_loop_proxy().get()); |
| 4190 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); | 4190 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); |
| 4191 EXPECT_TRUE(file_util::CreateDirectory(idb_path)); | 4191 EXPECT_TRUE(file_util::CreateDirectory(idb_path)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4219 base::Unretained(&callback))); | 4219 base::Unretained(&callback))); |
| 4220 loop_.RunUntilIdle(); | 4220 loop_.RunUntilIdle(); |
| 4221 EXPECT_EQ(0U, callback.list_.size()); | 4221 EXPECT_EQ(0U, callback.list_.size()); |
| 4222 | 4222 |
| 4223 // The database should have vanished as well. | 4223 // The database should have vanished as well. |
| 4224 origins.clear(); | 4224 origins.clear(); |
| 4225 db_tracker->GetAllOriginsInfo(&origins); | 4225 db_tracker->GetAllOriginsInfo(&origins); |
| 4226 EXPECT_EQ(0U, origins.size()); | 4226 EXPECT_EQ(0U, origins.size()); |
| 4227 | 4227 |
| 4228 // Check that the LSO file has been removed. | 4228 // Check that the LSO file has been removed. |
| 4229 EXPECT_FALSE(file_util::PathExists(lso_file_path)); | 4229 EXPECT_FALSE(base::PathExists(lso_file_path)); |
| 4230 | 4230 |
| 4231 // Check if the indexed db has disappeared too. | 4231 // Check if the indexed db has disappeared too. |
| 4232 EXPECT_FALSE(file_util::DirectoryExists(idb_path)); | 4232 EXPECT_FALSE(file_util::DirectoryExists(idb_path)); |
| 4233 } | 4233 } |
| 4234 | 4234 |
| 4235 // Tests loading single extensions (like --load-extension) | 4235 // Tests loading single extensions (like --load-extension) |
| 4236 // Flaky crashes. http://crbug.com/231806 | 4236 // Flaky crashes. http://crbug.com/231806 |
| 4237 TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) { | 4237 TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) { |
| 4238 InitializeEmptyExtensionService(); | 4238 InitializeEmptyExtensionService(); |
| 4239 | 4239 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4356 // preference should prevent us from reinstalling. | 4356 // preference should prevent us from reinstalling. |
| 4357 std::string id = loaded_[0]->id(); | 4357 std::string id = loaded_[0]->id(); |
| 4358 bool no_uninstall = | 4358 bool no_uninstall = |
| 4359 management_policy_->MustRemainEnabled(loaded_[0].get(), NULL); | 4359 management_policy_->MustRemainEnabled(loaded_[0].get(), NULL); |
| 4360 service_->UninstallExtension(id, false, NULL); | 4360 service_->UninstallExtension(id, false, NULL); |
| 4361 loop_.RunUntilIdle(); | 4361 loop_.RunUntilIdle(); |
| 4362 | 4362 |
| 4363 base::FilePath install_path = extensions_install_dir_.AppendASCII(id); | 4363 base::FilePath install_path = extensions_install_dir_.AppendASCII(id); |
| 4364 if (no_uninstall) { | 4364 if (no_uninstall) { |
| 4365 // Policy controlled extensions should not have been touched by uninstall. | 4365 // Policy controlled extensions should not have been touched by uninstall. |
| 4366 ASSERT_TRUE(file_util::PathExists(install_path)); | 4366 ASSERT_TRUE(base::PathExists(install_path)); |
| 4367 } else { | 4367 } else { |
| 4368 // The extension should also be gone from the install directory. | 4368 // The extension should also be gone from the install directory. |
| 4369 ASSERT_FALSE(file_util::PathExists(install_path)); | 4369 ASSERT_FALSE(base::PathExists(install_path)); |
| 4370 loaded_.clear(); | 4370 loaded_.clear(); |
| 4371 service_->CheckForExternalUpdates(); | 4371 service_->CheckForExternalUpdates(); |
| 4372 loop_.RunUntilIdle(); | 4372 loop_.RunUntilIdle(); |
| 4373 ASSERT_EQ(0u, loaded_.size()); | 4373 ASSERT_EQ(0u, loaded_.size()); |
| 4374 ValidatePrefKeyCount(1); | 4374 ValidatePrefKeyCount(1); |
| 4375 ValidateIntegerPref(good_crx, "state", | 4375 ValidateIntegerPref(good_crx, "state", |
| 4376 Extension::EXTERNAL_EXTENSION_UNINSTALLED); | 4376 Extension::EXTERNAL_EXTENSION_UNINSTALLED); |
| 4377 ValidateIntegerPref(good_crx, "location", location); | 4377 ValidateIntegerPref(good_crx, "location", location); |
| 4378 | 4378 |
| 4379 // Now clear the preference and reinstall. | 4379 // Now clear the preference and reinstall. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4397 // the pref entry). | 4397 // the pref entry). |
| 4398 provider->RemoveExtension(good_crx); | 4398 provider->RemoveExtension(good_crx); |
| 4399 | 4399 |
| 4400 loaded_.clear(); | 4400 loaded_.clear(); |
| 4401 service_->OnExternalProviderReady(provider); | 4401 service_->OnExternalProviderReady(provider); |
| 4402 loop_.RunUntilIdle(); | 4402 loop_.RunUntilIdle(); |
| 4403 ASSERT_EQ(0u, loaded_.size()); | 4403 ASSERT_EQ(0u, loaded_.size()); |
| 4404 ValidatePrefKeyCount(0); | 4404 ValidatePrefKeyCount(0); |
| 4405 | 4405 |
| 4406 // The extension should also be gone from the install directory. | 4406 // The extension should also be gone from the install directory. |
| 4407 ASSERT_FALSE(file_util::PathExists(install_path)); | 4407 ASSERT_FALSE(base::PathExists(install_path)); |
| 4408 | 4408 |
| 4409 // Now test the case where user uninstalls and then the extension is removed | 4409 // Now test the case where user uninstalls and then the extension is removed |
| 4410 // from the external provider. | 4410 // from the external provider. |
| 4411 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path); | 4411 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path); |
| 4412 service_->CheckForExternalUpdates(); | 4412 service_->CheckForExternalUpdates(); |
| 4413 content::WindowedNotificationObserver( | 4413 content::WindowedNotificationObserver( |
| 4414 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 4414 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 4415 content::NotificationService::AllSources()).Wait(); | 4415 content::NotificationService::AllSources()).Wait(); |
| 4416 | 4416 |
| 4417 ASSERT_EQ(1u, loaded_.size()); | 4417 ASSERT_EQ(1u, loaded_.size()); |
| (...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6272 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); | 6272 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); |
| 6273 | 6273 |
| 6274 service_->CheckForExternalUpdates(); | 6274 service_->CheckForExternalUpdates(); |
| 6275 content::WindowedNotificationObserver( | 6275 content::WindowedNotificationObserver( |
| 6276 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 6276 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 6277 content::NotificationService::AllSources()).Wait(); | 6277 content::NotificationService::AllSources()).Wait(); |
| 6278 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); | 6278 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); |
| 6279 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); | 6279 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); |
| 6280 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); | 6280 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); |
| 6281 } | 6281 } |
| OLD | NEW |