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 4054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)); |
4075 EXPECT_TRUE(file_util::DirectoryExists(idb_path)); | 4075 EXPECT_TRUE(base::DirectoryExists(idb_path)); |
4076 | 4076 |
4077 // Uninstall the extension. | 4077 // Uninstall the extension. |
4078 service_->UninstallExtension(good_crx, false, NULL); | 4078 service_->UninstallExtension(good_crx, false, NULL); |
4079 loop_.RunUntilIdle(); | 4079 loop_.RunUntilIdle(); |
4080 | 4080 |
4081 // Check that the cookie is gone. | 4081 // Check that the cookie is gone. |
4082 cookie_monster->GetAllCookiesForURLAsync( | 4082 cookie_monster->GetAllCookiesForURLAsync( |
4083 ext_url, | 4083 ext_url, |
4084 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, | 4084 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, |
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(base::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(base::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; |
4106 | 4106 |
4107 int pref_count = 0; | 4107 int pref_count = 0; |
4108 | 4108 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)); |
4192 EXPECT_TRUE(file_util::DirectoryExists(idb_path)); | 4192 EXPECT_TRUE(base::DirectoryExists(idb_path)); |
4193 | 4193 |
4194 // Uninstall one of them, unlimited storage should still be granted | 4194 // Uninstall one of them, unlimited storage should still be granted |
4195 // to the origin. | 4195 // to the origin. |
4196 UninstallExtension(id1, false); | 4196 UninstallExtension(id1, false); |
4197 EXPECT_EQ(1u, service_->extensions()->size()); | 4197 EXPECT_EQ(1u, service_->extensions()->size()); |
4198 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 4198 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
4199 IsStorageUnlimited(origin1)); | 4199 IsStorageUnlimited(origin1)); |
4200 | 4200 |
4201 // Check that the cookie is still there. | 4201 // Check that the cookie is still there. |
4202 cookie_monster->GetAllCookiesForURLAsync( | 4202 cookie_monster->GetAllCookiesForURLAsync( |
(...skipping 19 matching lines...) Expand all Loading... |
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(base::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(base::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 |
4240 base::FilePath ext1 = data_dir_ | 4240 base::FilePath ext1 = data_dir_ |
4241 .AppendASCII("good") | 4241 .AppendASCII("good") |
4242 .AppendASCII("Extensions") | 4242 .AppendASCII("Extensions") |
(...skipping 2029 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 |