Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: content/browser/service_worker/service_worker_storage_unittest.cc

Issue 633873002: Service Worker: Respect the "clear on exit" content setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@contentsettings
Patch Set: sync Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 } // namespace 186 } // namespace
187 187
188 class ServiceWorkerStorageTest : public testing::Test { 188 class ServiceWorkerStorageTest : public testing::Test {
189 public: 189 public:
190 ServiceWorkerStorageTest() 190 ServiceWorkerStorageTest()
191 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { 191 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {
192 } 192 }
193 193
194 virtual void SetUp() override { 194 virtual void SetUp() override {
195 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager(
196 new MockServiceWorkerDatabaseTaskManager(
197 base::ThreadTaskRunnerHandle::Get()));
195 context_.reset( 198 context_.reset(
196 new ServiceWorkerContextCore(GetUserDataDirectory(), 199 new ServiceWorkerContextCore(GetUserDataDirectory(),
197 base::ThreadTaskRunnerHandle::Get(), 200 base::ThreadTaskRunnerHandle::Get(),
198 base::ThreadTaskRunnerHandle::Get(), 201 database_task_manager.Pass(),
199 base::ThreadTaskRunnerHandle::Get(), 202 base::ThreadTaskRunnerHandle::Get(),
200 NULL, 203 NULL,
201 NULL, 204 NULL,
205 NULL,
202 NULL)); 206 NULL));
203 context_ptr_ = context_->AsWeakPtr(); 207 context_ptr_ = context_->AsWeakPtr();
204 } 208 }
205 209
206 virtual void TearDown() override { 210 virtual void TearDown() override {
207 context_.reset(); 211 context_.reset();
208 } 212 }
209 213
210 virtual base::FilePath GetUserDataDirectory() { return base::FilePath(); } 214 virtual base::FilePath GetUserDataDirectory() { return base::FilePath(); }
211 215
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, 807 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
804 storage()->database_->GetUncommittedResourceIds(&verify_ids)); 808 storage()->database_->GetUncommittedResourceIds(&verify_ids));
805 EXPECT_EQ(1u, verify_ids.size()); 809 EXPECT_EQ(1u, verify_ids.size());
806 WriteBasicResponse(storage(), kStaleUncommittedResourceId); 810 WriteBasicResponse(storage(), kStaleUncommittedResourceId);
807 EXPECT_TRUE( 811 EXPECT_TRUE(
808 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, true)); 812 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, true));
809 813
810 // Simulate browser shutdown. The purgeable and uncommitted resources are now 814 // Simulate browser shutdown. The purgeable and uncommitted resources are now
811 // stale. 815 // stale.
812 context_.reset(); 816 context_.reset();
817 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager(
818 new MockServiceWorkerDatabaseTaskManager(
819 base::ThreadTaskRunnerHandle::Get()));
813 context_.reset( 820 context_.reset(
814 new ServiceWorkerContextCore(GetUserDataDirectory(), 821 new ServiceWorkerContextCore(GetUserDataDirectory(),
815 base::ThreadTaskRunnerHandle::Get(), 822 base::ThreadTaskRunnerHandle::Get(),
816 base::ThreadTaskRunnerHandle::Get(), 823 database_task_manager.Pass(),
817 base::ThreadTaskRunnerHandle::Get(), 824 base::ThreadTaskRunnerHandle::Get(),
818 NULL, 825 NULL,
819 NULL, 826 NULL,
827 NULL,
820 NULL)); 828 NULL));
821 storage()->LazyInitialize(base::Bind(&base::DoNothing)); 829 storage()->LazyInitialize(base::Bind(&base::DoNothing));
822 base::RunLoop().RunUntilIdle(); 830 base::RunLoop().RunUntilIdle();
823 831
824 // Store a new uncommitted resource. This triggers stale resource cleanup. 832 // Store a new uncommitted resource. This triggers stale resource cleanup.
825 int64 kNewResourceId = storage()->NewResourceId(); 833 int64 kNewResourceId = storage()->NewResourceId();
826 WriteBasicResponse(storage(), kNewResourceId); 834 WriteBasicResponse(storage(), kNewResourceId);
827 storage()->StoreUncommittedResponseId(kNewResourceId); 835 storage()->StoreUncommittedResponseId(kNewResourceId);
828 base::RunLoop().RunUntilIdle(); 836 base::RunLoop().RunUntilIdle();
829 837
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 are_equal = true; 1046 are_equal = true;
1039 storage()->CompareScriptResources( 1047 storage()->CompareScriptResources(
1040 5, 6, 1048 5, 6,
1041 base::Bind(&OnCompareComplete, &status, &are_equal)); 1049 base::Bind(&OnCompareComplete, &status, &are_equal));
1042 base::RunLoop().RunUntilIdle(); 1050 base::RunLoop().RunUntilIdle();
1043 EXPECT_EQ(SERVICE_WORKER_OK, status); 1051 EXPECT_EQ(SERVICE_WORKER_OK, status);
1044 EXPECT_FALSE(are_equal); 1052 EXPECT_FALSE(are_equal);
1045 } 1053 }
1046 1054
1047 } // namespace content 1055 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_storage.cc ('k') | content/browser/storage_partition_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698