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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 | 733 |
734 ParsedFeaturePolicyHeader CreateFPHeaderMatchesAll( | 734 ParsedFeaturePolicyHeader CreateFPHeaderMatchesAll( |
735 blink::WebFeaturePolicyFeature feature) { | 735 blink::WebFeaturePolicyFeature feature) { |
736 ParsedFeaturePolicyHeader result(1); | 736 ParsedFeaturePolicyHeader result(1); |
737 result[0].feature = feature; | 737 result[0].feature = feature; |
738 result[0].matches_all_origins = true; | 738 result[0].matches_all_origins = true; |
739 return result; | 739 return result; |
740 } | 740 } |
741 }; | 741 }; |
742 | 742 |
743 bool operator==(const ParsedFeaturePolicyDeclaration& first, | |
744 const ParsedFeaturePolicyDeclaration& second) { | |
745 return std::tie(first.feature, first.matches_all_origins, first.origins) == | |
746 std::tie(second.feature, second.matches_all_origins, second.origins); | |
747 } | |
748 | |
749 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, | 743 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, |
750 SubframeLoadsWithCorrectDeviceScaleFactor) { | 744 SubframeLoadsWithCorrectDeviceScaleFactor) { |
751 GURL main_url(embedded_test_server()->GetURL( | 745 GURL main_url(embedded_test_server()->GetURL( |
752 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 746 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
753 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 747 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
754 | 748 |
755 // On Android forcing device scale factor does not work for tests, therefore | 749 // On Android forcing device scale factor does not work for tests, therefore |
756 // we ensure that make frame and iframe have the same DIP scale there, but | 750 // we ensure that make frame and iframe have the same DIP scale there, but |
757 // not necessarily kDeviceScaleFactor. | 751 // not necessarily kDeviceScaleFactor. |
758 const double expected_dip_scale = | 752 const double expected_dip_scale = |
(...skipping 8745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9504 EXPECT_TRUE(ExecuteScript( | 9498 EXPECT_TRUE(ExecuteScript( |
9505 root, "document.getElementById('child-3').allow='fullscreen vibrate'")); | 9499 root, "document.getElementById('child-3').allow='fullscreen vibrate'")); |
9506 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features.size(), | 9500 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features.size(), |
9507 2u); | 9501 2u); |
9508 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[0], | 9502 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[0], |
9509 blink::WebFeaturePolicyFeature::kFullscreen); | 9503 blink::WebFeaturePolicyFeature::kFullscreen); |
9510 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[1], | 9504 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[1], |
9511 blink::WebFeaturePolicyFeature::kVibrate); | 9505 blink::WebFeaturePolicyFeature::kVibrate); |
9512 } | 9506 } |
9513 | 9507 |
| 9508 // Test iframe container policy is replicated properly to the browser. |
| 9509 IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest, |
| 9510 ContainerPolicy) { |
| 9511 GURL url(embedded_test_server()->GetURL("/allowed_frames.html")); |
| 9512 EXPECT_TRUE(NavigateToURL(shell(), url)); |
| 9513 |
| 9514 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 9515 |
| 9516 EXPECT_EQ(0UL, root->effective_container_policy().size()); |
| 9517 EXPECT_EQ(0UL, root->child_at(0)->effective_container_policy().size()); |
| 9518 EXPECT_EQ(0UL, root->child_at(1)->effective_container_policy().size()); |
| 9519 EXPECT_EQ(2UL, root->child_at(2)->effective_container_policy().size()); |
| 9520 EXPECT_EQ(2UL, root->child_at(3)->effective_container_policy().size()); |
| 9521 } |
| 9522 |
| 9523 // Test dynamic updates to iframe "allow" attribute are propagated correctly. |
| 9524 IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest, |
| 9525 ContainerPolicyDynamic) { |
| 9526 GURL main_url(embedded_test_server()->GetURL("/allowed_frames.html")); |
| 9527 GURL nav_url( |
| 9528 embedded_test_server()->GetURL("b.com", "/feature-policy2.html")); |
| 9529 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 9530 |
| 9531 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 9532 |
| 9533 EXPECT_EQ(2UL, root->child_at(2)->effective_container_policy().size()); |
| 9534 |
| 9535 // Removing the "allow" attribute; pending policy should update, but effective |
| 9536 // policy remains unchanged. |
| 9537 EXPECT_TRUE(ExecuteScript( |
| 9538 root, "document.getElementById('child-2').setAttribute('allow','')")); |
| 9539 EXPECT_EQ(2UL, root->child_at(2)->effective_container_policy().size()); |
| 9540 EXPECT_EQ(0UL, root->child_at(2)->pending_container_policy_.size()); |
| 9541 |
| 9542 // Navigate the frame; pending policy should be committed. |
| 9543 NavigateFrameToURL(root->child_at(2), nav_url); |
| 9544 EXPECT_EQ(0UL, root->child_at(2)->effective_container_policy().size()); |
| 9545 } |
| 9546 |
9514 // Test harness that allows for "barrier" style delaying of requests matching | 9547 // Test harness that allows for "barrier" style delaying of requests matching |
9515 // certain paths. Call SetDelayedRequestsForPath to delay requests, then | 9548 // certain paths. Call SetDelayedRequestsForPath to delay requests, then |
9516 // SetUpEmbeddedTestServer to register handlers and start the server. | 9549 // SetUpEmbeddedTestServer to register handlers and start the server. |
9517 class RequestDelayingSitePerProcessBrowserTest | 9550 class RequestDelayingSitePerProcessBrowserTest |
9518 : public SitePerProcessBrowserTest { | 9551 : public SitePerProcessBrowserTest { |
9519 public: | 9552 public: |
9520 RequestDelayingSitePerProcessBrowserTest() | 9553 RequestDelayingSitePerProcessBrowserTest() |
9521 : test_server_(base::MakeUnique<net::EmbeddedTestServer>()) {} | 9554 : test_server_(base::MakeUnique<net::EmbeddedTestServer>()) {} |
9522 | 9555 |
9523 // Must be called after any calls to SetDelayedRequestsForPath. | 9556 // Must be called after any calls to SetDelayedRequestsForPath. |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9861 names.insert(root->children[0]->frame_entry->frame_unique_name()); | 9894 names.insert(root->children[0]->frame_entry->frame_unique_name()); |
9862 } | 9895 } |
9863 | 9896 |
9864 // More than one entry in the set means that the subframe frame navigation | 9897 // More than one entry in the set means that the subframe frame navigation |
9865 // entries didn't have a consistent unique name. This will break history | 9898 // entries didn't have a consistent unique name. This will break history |
9866 // navigations =( | 9899 // navigations =( |
9867 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | 9900 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; |
9868 } | 9901 } |
9869 | 9902 |
9870 } // namespace content | 9903 } // namespace content |
OLD | NEW |