| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "bindings/core/v8/BindingSecurity.h" | 5 #include "bindings/core/v8/BindingSecurity.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/UseCounter.h" | 8 #include "core/frame/UseCounter.h" |
| 9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "web/tests/sim/SimRequest.h" | 12 #include "web/tests/sim/SimRequest.h" |
| 13 #include "web/tests/sim/SimTest.h" | 13 #include "web/tests/sim/SimTest.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 const char kMainFrame[] = "https://example.com/main.html"; | 18 const char kMainFrame[] = "https://example.com/main.html"; |
| 19 const char kSameOriginTarget[] = "https://example.com/target.html"; | 19 const char kSameOriginTarget[] = "https://example.com/target.html"; |
| 20 const char kCrossOriginTarget[] = "https://not-example.com/target.html"; | 20 const char kCrossOriginTarget[] = "https://not-example.com/target.html"; |
| 21 } | 21 } // namespace |
| 22 | 22 |
| 23 class BindingSecurityCounterTest | 23 class BindingSecurityCounterTest |
| 24 : public SimTest, | 24 : public SimTest, |
| 25 public ::testing::WithParamInterface<const char*> { | 25 public ::testing::WithParamInterface<const char*> { |
| 26 public: | 26 public: |
| 27 enum class OriginDisposition { CrossOrigin, SameOrigin }; | 27 enum class OriginDisposition { CrossOrigin, SameOrigin }; |
| 28 | 28 |
| 29 BindingSecurityCounterTest() {} | 29 BindingSecurityCounterTest() {} |
| 30 | 30 |
| 31 void LoadWindowAndAccessProperty(OriginDisposition which_origin, | 31 void LoadWindowAndAccessProperty(OriginDisposition which_origin, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 | 130 |
| 131 TEST_P(BindingSecurityCounterTest, SameOriginFrame) { | 131 TEST_P(BindingSecurityCounterTest, SameOriginFrame) { |
| 132 LoadFrameAndAccessProperty(OriginDisposition::SameOrigin, GetParam()); | 132 LoadFrameAndAccessProperty(OriginDisposition::SameOrigin, GetParam()); |
| 133 EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement( | 133 EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement( |
| 134 WebFeature::kCrossOriginPropertyAccess)); | 134 WebFeature::kCrossOriginPropertyAccess)); |
| 135 EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement( | 135 EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement( |
| 136 WebFeature::kCrossOriginPropertyAccessFromOpener)); | 136 WebFeature::kCrossOriginPropertyAccessFromOpener)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace | 139 } // namespace blink |
| OLD | NEW |