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

Side by Side Diff: webkit/dom_storage/dom_storage_context_unittest.cc

Issue 10546167: Create and store persistent unique ids for sessionStorage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> 152 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)->
153 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); 153 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value));
154 context_->SetForceKeepSessionState(); // Should override clear behavior. 154 context_->SetForceKeepSessionState(); // Should override clear behavior.
155 context_->Shutdown(); 155 context_->Shutdown();
156 context_ = NULL; 156 context_ = NULL;
157 MessageLoop::current()->RunAllPending(); 157 MessageLoop::current()->RunAllPending();
158 158
159 VerifySingleOriginRemains(kSessionOnlyOrigin); 159 VerifySingleOriginRemains(kSessionOnlyOrigin);
160 } 160 }
161 161
162 TEST_F(DomStorageContextTest, PersistentIds) {
163 const int kFirstSessionStorageNamespaceId = 1;
164 const std::string kPersistentId = "persistent";
165 context_->CreateSessionNamespace(kFirstSessionStorageNamespaceId,
166 kPersistentId);
167 DomStorageNamespace* dom_namespace =
168 context_->GetStorageNamespace(kFirstSessionStorageNamespaceId);
169 ASSERT_TRUE(dom_namespace);
170 EXPECT_EQ(kPersistentId, dom_namespace->persistent_namespace_id());
171 // Verify that the areas inherit the persistent ID.
172 DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin);
173 EXPECT_EQ(kPersistentId, area->persistent_namespace_id_);
174
175 // Verify that the persistent IDs are handled correctly when cloning.
176 const int kClonedSessionStorageNamespaceId = 2;
177 const std::string kClonedPersistentId = "cloned";
178 context_->CloneSessionNamespace(kFirstSessionStorageNamespaceId,
179 kClonedSessionStorageNamespaceId,
180 kClonedPersistentId);
181 DomStorageNamespace* cloned_dom_namespace =
182 context_->GetStorageNamespace(kClonedSessionStorageNamespaceId);
183 ASSERT_TRUE(dom_namespace);
184 EXPECT_EQ(kClonedPersistentId,
185 cloned_dom_namespace->persistent_namespace_id());
186 // Verify that the areas inherit the persistent ID.
187 DomStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin);
188 EXPECT_EQ(kClonedPersistentId, cloned_area->persistent_namespace_id_);
189 }
190
162 } // namespace dom_storage 191 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698