Index: content/browser/dom_storage/dom_storage_context_impl_unittest.cc |
diff --git a/content/browser/dom_storage/dom_storage_context_impl_unittest.cc b/content/browser/dom_storage/dom_storage_context_impl_unittest.cc |
index f3744ab157bc394424bf66cfb2b46f7852166904..7d6cd0dec360facc33ad15fb991cf37d8534b71d 100644 |
--- a/content/browser/dom_storage/dom_storage_context_impl_unittest.cc |
+++ b/content/browser/dom_storage/dom_storage_context_impl_unittest.cc |
@@ -15,7 +15,6 @@ |
#include "content/browser/dom_storage/dom_storage_namespace.h" |
#include "content/browser/dom_storage/dom_storage_task_runner.h" |
#include "content/public/browser/local_storage_usage_info.h" |
-#include "content/public/browser/session_storage_namespace.h" |
#include "content/public/browser/session_storage_usage_info.h" |
#include "content/public/test/mock_special_storage_policy.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -260,115 +259,4 @@ TEST_F(DOMStorageContextImplTest, DeleteSessionStorage) { |
base::MessageLoop::current()->RunUntilIdle(); |
} |
-TEST_F(DOMStorageContextImplTest, SessionStorageAlias) { |
- const int kFirstSessionStorageNamespaceId = 1; |
- const std::string kPersistentId = "persistent"; |
- context_->CreateSessionNamespace(kFirstSessionStorageNamespaceId, |
- kPersistentId); |
- DOMStorageNamespace* dom_namespace1 = |
- context_->GetStorageNamespace(kFirstSessionStorageNamespaceId); |
- ASSERT_TRUE(dom_namespace1); |
- DOMStorageArea* area1 = dom_namespace1->OpenStorageArea(kOrigin); |
- base::NullableString16 old_value; |
- area1->SetItem(kKey, kValue, &old_value); |
- EXPECT_TRUE(old_value.is_null()); |
- base::NullableString16 read_value = area1->GetItem(kKey); |
- EXPECT_TRUE(!read_value.is_null() && read_value.string() == kValue); |
- |
- // Create an alias. |
- const int kAliasSessionStorageNamespaceId = 2; |
- context_->CreateAliasSessionNamespace(kFirstSessionStorageNamespaceId, |
- kAliasSessionStorageNamespaceId, |
- kPersistentId); |
- DOMStorageNamespace* dom_namespace2 = |
- context_->GetStorageNamespace(kAliasSessionStorageNamespaceId); |
- ASSERT_TRUE(dom_namespace2); |
- ASSERT_TRUE(dom_namespace2->alias_master_namespace() == dom_namespace1); |
- |
- // Verify that read values are identical. |
- DOMStorageArea* area2 = dom_namespace2->OpenStorageArea(kOrigin); |
- read_value = area2->GetItem(kKey); |
- EXPECT_TRUE(!read_value.is_null() && read_value.string() == kValue); |
- |
- // Verify that writes are reflected in both namespaces. |
- const base::string16 kValue2(ASCIIToUTF16("value2")); |
- area2->SetItem(kKey, kValue2, &old_value); |
- read_value = area1->GetItem(kKey); |
- EXPECT_TRUE(!read_value.is_null() && read_value.string() == kValue2); |
- dom_namespace1->CloseStorageArea(area1); |
- dom_namespace2->CloseStorageArea(area2); |
- |
- // When creating an alias of an alias, ensure that the master relationship |
- // is collapsed. |
- const int kAlias2SessionStorageNamespaceId = 3; |
- context_->CreateAliasSessionNamespace(kAliasSessionStorageNamespaceId, |
- kAlias2SessionStorageNamespaceId, |
- kPersistentId); |
- DOMStorageNamespace* dom_namespace3 = |
- context_->GetStorageNamespace(kAlias2SessionStorageNamespaceId); |
- ASSERT_TRUE(dom_namespace3); |
- ASSERT_TRUE(dom_namespace3->alias_master_namespace() == dom_namespace1); |
-} |
- |
-TEST_F(DOMStorageContextImplTest, SessionStorageMerge) { |
- // Create a target namespace that we will merge into. |
- const int kTargetSessionStorageNamespaceId = 1; |
- const std::string kTargetPersistentId = "persistent"; |
- context_->CreateSessionNamespace(kTargetSessionStorageNamespaceId, |
- kTargetPersistentId); |
- DOMStorageNamespace* target_ns = |
- context_->GetStorageNamespace(kTargetSessionStorageNamespaceId); |
- ASSERT_TRUE(target_ns); |
- DOMStorageArea* target_ns_area = target_ns->OpenStorageArea(kOrigin); |
- base::NullableString16 old_value; |
- const base::string16 kKey2(ASCIIToUTF16("key2")); |
- const base::string16 kKey2Value(ASCIIToUTF16("key2value")); |
- target_ns_area->SetItem(kKey, kValue, &old_value); |
- target_ns_area->SetItem(kKey2, kKey2Value, &old_value); |
- |
- // Create a source namespace & its alias. |
- const int kSourceSessionStorageNamespaceId = 2; |
- const int kAliasSessionStorageNamespaceId = 3; |
- const std::string kSourcePersistentId = "persistent_source"; |
- context_->CreateSessionNamespace(kSourceSessionStorageNamespaceId, |
- kSourcePersistentId); |
- context_->CreateAliasSessionNamespace(kSourceSessionStorageNamespaceId, |
- kAliasSessionStorageNamespaceId, |
- kSourcePersistentId); |
- DOMStorageNamespace* alias_ns = |
- context_->GetStorageNamespace(kAliasSessionStorageNamespaceId); |
- ASSERT_TRUE(alias_ns); |
- |
- // Create a transaction log that can't be merged. |
- const int kPid1 = 10; |
- ASSERT_FALSE(alias_ns->IsLoggingRenderer(kPid1)); |
- alias_ns->AddTransactionLogProcessId(kPid1); |
- ASSERT_TRUE(alias_ns->IsLoggingRenderer(kPid1)); |
- const base::string16 kValue2(ASCIIToUTF16("value2")); |
- DOMStorageNamespace::TransactionRecord txn; |
- txn.origin = kOrigin; |
- txn.key = kKey; |
- txn.value = base::NullableString16(kValue2, false); |
- txn.transaction_type = DOMStorageNamespace::TRANSACTION_READ; |
- alias_ns->AddTransaction(kPid1, txn); |
- ASSERT_TRUE(alias_ns->Merge(false, kPid1, target_ns, NULL) == |
- SessionStorageNamespace::MERGE_RESULT_NOT_MERGEABLE); |
- |
- // Create a transaction log that can be merged. |
- const int kPid2 = 20; |
- alias_ns->AddTransactionLogProcessId(kPid2); |
- txn.transaction_type = DOMStorageNamespace::TRANSACTION_WRITE; |
- alias_ns->AddTransaction(kPid2, txn); |
- ASSERT_TRUE(alias_ns->Merge(true, kPid2, target_ns, NULL) == |
- SessionStorageNamespace::MERGE_RESULT_MERGEABLE); |
- |
- // Verify that the merge was successful. |
- ASSERT_TRUE(alias_ns->alias_master_namespace() == target_ns); |
- base::NullableString16 read_value = target_ns_area->GetItem(kKey); |
- EXPECT_TRUE(!read_value.is_null() && read_value.string() == kValue2); |
- DOMStorageArea* alias_ns_area = alias_ns->OpenStorageArea(kOrigin); |
- read_value = alias_ns_area->GetItem(kKey2); |
- EXPECT_TRUE(!read_value.is_null() && read_value.string() == kKey2Value); |
-} |
- |
} // namespace content |