| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 EXPECT_TRUE(helper->empty()); | 42 EXPECT_TRUE(helper->empty()); |
| 43 helper->AddLocalStorage(origin1); | 43 helper->AddLocalStorage(origin1); |
| 44 helper->AddLocalStorage(origin2); | 44 helper->AddLocalStorage(origin2); |
| 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 |
| 52 // Local storage for a suborigin |
| 53 // (https://www.chromestatus.com/feature/5569465034997760) should be deleted |
| 54 // when the corresponding physical origin is deleted. |
| 55 const GURL suborigin("http-so://suborigin.foo.example.com"); |
| 56 helper->AddLocalStorage(suborigin); |
| 57 EXPECT_EQ(2u, helper->GetLocalStorageCount()); |
| 58 helper->DeleteOrigin(origin3); |
| 59 EXPECT_EQ(0u, helper->GetLocalStorageCount()); |
| 60 helper->AddLocalStorage(suborigin); |
| 61 EXPECT_EQ(1u, helper->GetLocalStorageCount()); |
| 62 helper->DeleteOrigin(origin3); |
| 63 EXPECT_EQ(0u, helper->GetLocalStorageCount()); |
| 51 } | 64 } |
| 52 | 65 |
| 53 TEST_F(CannedBrowsingDataLocalStorageTest, IgnoreExtensionsAndDevTools) { | 66 TEST_F(CannedBrowsingDataLocalStorageTest, IgnoreExtensionsAndDevTools) { |
| 54 TestingProfile profile; | 67 TestingProfile profile; |
| 55 | 68 |
| 56 const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/"); | 69 const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/"); |
| 57 const GURL origin2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/"); | 70 const GURL origin2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/"); |
| 58 | 71 |
| 59 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( | 72 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( |
| 60 new CannedBrowsingDataLocalStorageHelper(&profile)); | 73 new CannedBrowsingDataLocalStorageHelper(&profile)); |
| 61 | 74 |
| 62 ASSERT_TRUE(helper->empty()); | 75 ASSERT_TRUE(helper->empty()); |
| 63 helper->AddLocalStorage(origin1); | 76 helper->AddLocalStorage(origin1); |
| 64 ASSERT_TRUE(helper->empty()); | 77 ASSERT_TRUE(helper->empty()); |
| 65 helper->AddLocalStorage(origin2); | 78 helper->AddLocalStorage(origin2); |
| 66 ASSERT_TRUE(helper->empty()); | 79 ASSERT_TRUE(helper->empty()); |
| 67 } | 80 } |
| 68 | 81 |
| 69 } // namespace | 82 } // namespace |
| OLD | NEW |