| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/peripheral_content_heuristic.h" | 5 #include "content/renderer/peripheral_content_heuristic.h" |
| 6 | 6 |
| 7 #include "base/test/scoped_feature_list.h" |
| 8 #include "content/public/common/content_features.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
| 9 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 10 #include "url/origin.h" | 12 #include "url/origin.h" |
| 11 | 13 |
| 12 namespace content { | 14 namespace content { |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 const char kSameOrigin[] = "http://same.com"; | 18 const char kSameOrigin[] = "http://same.com"; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 EXPECT_EQ(RenderFrame::CONTENT_STATUS_TINY, | 54 EXPECT_EQ(RenderFrame::CONTENT_STATUS_TINY, |
| 53 PeripheralContentHeuristic::GetPeripheralStatus( | 55 PeripheralContentHeuristic::GetPeripheralStatus( |
| 54 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), | 56 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), |
| 55 url::Origin(GURL(kOtherOrigin)), gfx::Size(5, 5))); | 57 url::Origin(GURL(kOtherOrigin)), gfx::Size(5, 5))); |
| 56 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL, | 58 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL, |
| 57 PeripheralContentHeuristic::GetPeripheralStatus( | 59 PeripheralContentHeuristic::GetPeripheralStatus( |
| 58 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), | 60 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), |
| 59 url::Origin(GURL(kOtherOrigin)), gfx::Size(10, 10))); | 61 url::Origin(GURL(kOtherOrigin)), gfx::Size(10, 10))); |
| 60 } | 62 } |
| 61 | 63 |
| 64 TEST(PeripheralContentHeuristic, FilterSameOriginTinyPlugins) { |
| 65 base::test::ScopedFeatureList feature_list; |
| 66 feature_list.InitAndEnableFeature(features::kFilterSameOriginTinyPlugin); |
| 67 |
| 68 EXPECT_EQ(RenderFrame::CONTENT_STATUS_TINY, |
| 69 PeripheralContentHeuristic::GetPeripheralStatus( |
| 70 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), |
| 71 url::Origin(GURL(kSameOrigin)), gfx::Size(1, 1))); |
| 72 } |
| 73 |
| 62 TEST(PeripheralContentHeuristic, TemporaryOriginWhitelist) { | 74 TEST(PeripheralContentHeuristic, TemporaryOriginWhitelist) { |
| 63 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL, | 75 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL, |
| 64 PeripheralContentHeuristic::GetPeripheralStatus( | 76 PeripheralContentHeuristic::GetPeripheralStatus( |
| 65 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), | 77 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), |
| 66 url::Origin(GURL(kOtherOrigin)), gfx::Size(100, 100))); | 78 url::Origin(GURL(kOtherOrigin)), gfx::Size(100, 100))); |
| 67 | 79 |
| 68 std::set<url::Origin> whitelist; | 80 std::set<url::Origin> whitelist; |
| 69 whitelist.insert(url::Origin(GURL(kOtherOrigin))); | 81 whitelist.insert(url::Origin(GURL(kOtherOrigin))); |
| 70 | 82 |
| 71 EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED, | 83 EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 87 whitelist, url::Origin(GURL(kSameOrigin)), | 99 whitelist, url::Origin(GURL(kSameOrigin)), |
| 88 url::Origin(GURL(kOtherOrigin)), gfx::Size())); | 100 url::Origin(GURL(kOtherOrigin)), gfx::Size())); |
| 89 | 101 |
| 90 EXPECT_EQ(RenderFrame::CONTENT_STATUS_UNKNOWN_SIZE, | 102 EXPECT_EQ(RenderFrame::CONTENT_STATUS_UNKNOWN_SIZE, |
| 91 PeripheralContentHeuristic::GetPeripheralStatus( | 103 PeripheralContentHeuristic::GetPeripheralStatus( |
| 92 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), | 104 std::set<url::Origin>(), url::Origin(GURL(kSameOrigin)), |
| 93 url::Origin(GURL(kOtherOrigin)), gfx::Size())); | 105 url::Origin(GURL(kOtherOrigin)), gfx::Size())); |
| 94 } | 106 } |
| 95 | 107 |
| 96 } // namespace content | 108 } // namespace content |
| OLD | NEW |