| 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 "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 6 | 6 |
| 7 #include "chrome/test/base/testing_profile.h" | 7 #include "chrome/test/base/testing_profile.h" |
| 8 #include "content/public/test/test_browser_thread_bundle.h" | 8 #include "content/public/test/test_browser_thread_bundle.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 helper->AddLocalStorage(origin3); | 45 helper->AddLocalStorage(origin3); |
| 46 EXPECT_EQ(3u, helper->GetLocalStorageCount()); | 46 EXPECT_EQ(3u, helper->GetLocalStorageCount()); |
| 47 helper->DeleteOrigin(origin2); | 47 helper->DeleteOrigin(origin2); |
| 48 EXPECT_EQ(2u, helper->GetLocalStorageCount()); | 48 EXPECT_EQ(2u, helper->GetLocalStorageCount()); |
| 49 helper->DeleteOrigin(origin1); | 49 helper->DeleteOrigin(origin1); |
| 50 EXPECT_EQ(1u, helper->GetLocalStorageCount()); | 50 EXPECT_EQ(1u, helper->GetLocalStorageCount()); |
| 51 | 51 |
| 52 // Local storage for a suborigin | 52 // Local storage for a suborigin |
| 53 // (https://www.chromestatus.com/feature/5569465034997760) should be deleted | 53 // (https://www.chromestatus.com/feature/5569465034997760) should be deleted |
| 54 // when the corresponding physical origin is deleted. | 54 // when the corresponding physical origin is deleted. |
| 55 const GURL suborigin("http-so://suborigin.foo.example.com"); | 55 const GURL suborigin_on_origin_3("http-so://suborigin.foo.example.com"); |
| 56 helper->AddLocalStorage(suborigin); | 56 helper->AddLocalStorage(suborigin_on_origin_3); |
| 57 EXPECT_EQ(2u, helper->GetLocalStorageCount()); | 57 EXPECT_EQ(2u, helper->GetLocalStorageCount()); |
| 58 helper->DeleteOrigin(origin3); | 58 helper->DeleteOrigin(origin3); |
| 59 EXPECT_EQ(0u, helper->GetLocalStorageCount()); | 59 EXPECT_EQ(0u, helper->GetLocalStorageCount()); |
| 60 helper->AddLocalStorage(suborigin); | 60 helper->AddLocalStorage(suborigin_on_origin_3); |
| 61 EXPECT_EQ(1u, helper->GetLocalStorageCount()); | 61 EXPECT_EQ(1u, helper->GetLocalStorageCount()); |
| 62 helper->DeleteOrigin(origin3); | 62 helper->DeleteOrigin(origin3); |
| 63 EXPECT_EQ(0u, helper->GetLocalStorageCount()); | 63 EXPECT_EQ(0u, helper->GetLocalStorageCount()); |
| 64 |
| 65 // Similarly, the suborigin should be deleted when the corresponding |
| 66 // physical origin is deleted. |
| 67 helper->AddLocalStorage(origin3); |
| 68 helper->AddLocalStorage(suborigin_on_origin_3); |
| 69 EXPECT_EQ(2u, helper->GetLocalStorageCount()); |
| 70 helper->DeleteOrigin(suborigin_on_origin_3); |
| 71 EXPECT_EQ(0u, helper->GetLocalStorageCount()); |
| 64 } | 72 } |
| 65 | 73 |
| 66 TEST_F(CannedBrowsingDataLocalStorageTest, IgnoreExtensionsAndDevTools) { | 74 TEST_F(CannedBrowsingDataLocalStorageTest, IgnoreExtensionsAndDevTools) { |
| 67 TestingProfile profile; | 75 TestingProfile profile; |
| 68 | 76 |
| 69 const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/"); | 77 const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/"); |
| 70 const GURL origin2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/"); | 78 const GURL origin2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/"); |
| 71 | 79 |
| 72 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( | 80 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( |
| 73 new CannedBrowsingDataLocalStorageHelper(&profile)); | 81 new CannedBrowsingDataLocalStorageHelper(&profile)); |
| 74 | 82 |
| 75 ASSERT_TRUE(helper->empty()); | 83 ASSERT_TRUE(helper->empty()); |
| 76 helper->AddLocalStorage(origin1); | 84 helper->AddLocalStorage(origin1); |
| 77 ASSERT_TRUE(helper->empty()); | 85 ASSERT_TRUE(helper->empty()); |
| 78 helper->AddLocalStorage(origin2); | 86 helper->AddLocalStorage(origin2); |
| 79 ASSERT_TRUE(helper->empty()); | 87 ASSERT_TRUE(helper->empty()); |
| 80 } | 88 } |
| 81 | 89 |
| 82 } // namespace | 90 } // namespace |
| OLD | NEW |