OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | 135 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> |
136 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); | 136 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); |
137 context_->Shutdown(); | 137 context_->Shutdown(); |
138 context_ = NULL; | 138 context_ = NULL; |
139 MessageLoop::current()->RunAllPending(); | 139 MessageLoop::current()->RunAllPending(); |
140 | 140 |
141 // Verify that the session-only origin data is gone. | 141 // Verify that the session-only origin data is gone. |
142 VerifySingleOriginRemains(kOrigin); | 142 VerifySingleOriginRemains(kOrigin); |
143 } | 143 } |
144 | 144 |
145 TEST_F(DomStorageContextTest, ClearLocalState) { | 145 TEST_F(DomStorageContextTest, SetForceKeepSessionState) { |
146 const GURL kProtectedOrigin("http://www.protected.com/"); | |
147 storage_policy_->AddProtected(kProtectedOrigin); | |
148 | |
149 // Store data for a normal and a protected origin, setup shutdown options | |
150 // to clear normal local state, then shutdown and let things flush. | |
151 NullableString16 old_value; | |
152 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | |
153 OpenStorageArea(kOrigin)->SetItem(kKey, kValue, &old_value)); | |
154 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | |
155 OpenStorageArea(kProtectedOrigin)->SetItem(kKey, kValue, &old_value)); | |
156 context_->SetClearLocalState(true); | |
157 context_->Shutdown(); | |
158 context_ = NULL; | |
159 MessageLoop::current()->RunAllPending(); | |
160 | |
161 VerifySingleOriginRemains(kProtectedOrigin); | |
162 } | |
163 | |
164 TEST_F(DomStorageContextTest, SaveSessionState) { | |
165 const GURL kSessionOnlyOrigin("http://www.sessiononly.com/"); | 146 const GURL kSessionOnlyOrigin("http://www.sessiononly.com/"); |
166 storage_policy_->AddSessionOnly(kSessionOnlyOrigin); | 147 storage_policy_->AddSessionOnly(kSessionOnlyOrigin); |
167 | 148 |
168 // Store data for a session-only origin, setup to save session data, then | 149 // Store data for a session-only origin, setup to save session data, then |
169 // shutdown. | 150 // shutdown. |
170 NullableString16 old_value; | 151 NullableString16 old_value; |
171 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | 152 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> |
172 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); | 153 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); |
173 context_->SetClearLocalState(true); | 154 context_->SetForceKeepSessionState(); // Should override clear behavior. |
174 context_->SaveSessionState(); // Should override clear behavior. | |
175 context_->Shutdown(); | 155 context_->Shutdown(); |
176 context_ = NULL; | 156 context_ = NULL; |
177 MessageLoop::current()->RunAllPending(); | 157 MessageLoop::current()->RunAllPending(); |
178 | 158 |
179 VerifySingleOriginRemains(kSessionOnlyOrigin); | 159 VerifySingleOriginRemains(kSessionOnlyOrigin); |
180 } | 160 } |
181 | 161 |
182 } // namespace dom_storage | 162 } // namespace dom_storage |
OLD | NEW |