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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <tuple> | 7 #include <tuple> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // replicated correctly. | 839 // replicated correctly. |
840 replication_state.origin = url::Origin(); | 840 replication_state.origin = url::Origin(); |
841 TestRenderFrame* child_frame2 = static_cast<TestRenderFrame*>( | 841 TestRenderFrame* child_frame2 = static_cast<TestRenderFrame*>( |
842 RenderFrame::FromWebFrame(web_frame->firstChild()->nextSibling())); | 842 RenderFrame::FromWebFrame(web_frame->firstChild()->nextSibling())); |
843 child_frame2->SwapOut(kProxyRoutingId + 1, true, replication_state); | 843 child_frame2->SwapOut(kProxyRoutingId + 1, true, replication_state); |
844 EXPECT_TRUE(web_frame->firstChild()->nextSibling()->isWebRemoteFrame()); | 844 EXPECT_TRUE(web_frame->firstChild()->nextSibling()->isWebRemoteFrame()); |
845 EXPECT_TRUE( | 845 EXPECT_TRUE( |
846 web_frame->firstChild()->nextSibling()->getSecurityOrigin().isUnique()); | 846 web_frame->firstChild()->nextSibling()->getSecurityOrigin().isUnique()); |
847 } | 847 } |
848 | 848 |
849 // Test for https://crbug.com/568676, where a parent detaches a remote child | 849 // Test that when a parent detaches a remote child after the provisional |
850 // while the browser navigates it to the parent's site in parallel, with the | 850 // RenderFrame is created but before it is navigated, the RenderFrame is |
851 // detach happening after the provisional RenderFrame is created but before | 851 // destroyed along with the proxy. This protects against races in |
852 // FrameMsg_Navigate is received. This is a variant of | 852 // https://crbug.com/526304 and https://crbug.com/568676. |
853 // https://crbug.com/526304. | 853 TEST_F(RenderViewImplTest, DetachingProxyAlsoDestroysProvisionalFrame) { |
854 TEST_F(RenderViewImplTest, NavigateProxyAndDetachBeforeOnNavigate) { | |
855 // This test should only run with --site-per-process. | 854 // This test should only run with --site-per-process. |
856 if (!AreAllSitesIsolatedForTesting()) | 855 if (!AreAllSitesIsolatedForTesting()) |
857 return; | 856 return; |
858 | 857 |
859 LoadHTML("Hello <iframe src='data:text/html,frame 1'></iframe>"); | 858 LoadHTML("Hello <iframe src='data:text/html,frame 1'></iframe>"); |
860 WebFrame* web_frame = frame()->GetWebFrame(); | 859 WebFrame* web_frame = frame()->GetWebFrame(); |
861 TestRenderFrame* child_frame = static_cast<TestRenderFrame*>( | 860 TestRenderFrame* child_frame = static_cast<TestRenderFrame*>( |
862 RenderFrame::FromWebFrame(web_frame->firstChild())); | 861 RenderFrame::FromWebFrame(web_frame->firstChild())); |
863 | 862 |
864 // Swap the child frame out. | 863 // Swap the child frame out. |
865 FrameReplicationState replication_state = | 864 FrameReplicationState replication_state = |
866 ReconstructReplicationStateForTesting(child_frame); | 865 ReconstructReplicationStateForTesting(child_frame); |
867 child_frame->SwapOut(kProxyRoutingId, true, replication_state); | 866 child_frame->SwapOut(kProxyRoutingId, true, replication_state); |
868 EXPECT_TRUE(web_frame->firstChild()->isWebRemoteFrame()); | 867 EXPECT_TRUE(web_frame->firstChild()->isWebRemoteFrame()); |
869 | 868 |
870 // Do the first step of a remote-to-local transition for the child proxy, | 869 // Do the first step of a remote-to-local transition for the child proxy, |
871 // which is to create a provisional local frame. | 870 // which is to create a provisional local frame. |
872 int routing_id = kProxyRoutingId + 1; | 871 int routing_id = kProxyRoutingId + 1; |
873 mojom::CreateFrameWidgetParams widget_params; | 872 mojom::CreateFrameWidgetParams widget_params; |
874 widget_params.routing_id = MSG_ROUTING_NONE; | 873 widget_params.routing_id = MSG_ROUTING_NONE; |
875 widget_params.hidden = false; | 874 widget_params.hidden = false; |
876 RenderFrameImpl::CreateFrame(routing_id, kProxyRoutingId, MSG_ROUTING_NONE, | 875 RenderFrameImpl::CreateFrame(routing_id, kProxyRoutingId, MSG_ROUTING_NONE, |
877 frame()->GetRoutingID(), MSG_ROUTING_NONE, | 876 frame()->GetRoutingID(), MSG_ROUTING_NONE, |
878 replication_state, nullptr, widget_params, | 877 replication_state, nullptr, widget_params, |
879 FrameOwnerProperties()); | 878 FrameOwnerProperties()); |
880 TestRenderFrame* provisional_frame = | 879 { |
881 static_cast<TestRenderFrame*>(RenderFrameImpl::FromRoutingID(routing_id)); | 880 TestRenderFrame* provisional_frame = static_cast<TestRenderFrame*>( |
882 EXPECT_TRUE(provisional_frame); | 881 RenderFrameImpl::FromRoutingID(routing_id)); |
| 882 EXPECT_TRUE(provisional_frame); |
| 883 } |
883 | 884 |
884 // Detach the child frame (currently remote) in the main frame. | 885 // Detach the child frame (currently remote) in the main frame. |
885 ExecuteJavaScriptForTests( | 886 ExecuteJavaScriptForTests( |
886 "document.body.removeChild(document.querySelector('iframe'));"); | 887 "document.body.removeChild(document.querySelector('iframe'));"); |
887 RenderFrameProxy* child_proxy = | 888 RenderFrameProxy* child_proxy = |
888 RenderFrameProxy::FromRoutingID(kProxyRoutingId); | 889 RenderFrameProxy::FromRoutingID(kProxyRoutingId); |
889 EXPECT_FALSE(child_proxy); | 890 EXPECT_FALSE(child_proxy); |
890 | 891 |
891 // Attempt to start a navigation on the RenderFrame that was created to | 892 // The provisional frame should have been deleted along with the proxy, and |
892 // replace the now-detached RenderFrameProxy. This shouldn't crash and | 893 // thus any subsequent messages (such as OnNavigate) already in flight for it |
893 // should abort the navigation, since the frame no longer exists. | 894 // should be dropped. |
894 CommonNavigationParams common_params; | 895 { |
895 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 896 TestRenderFrame* provisional_frame = static_cast<TestRenderFrame*>( |
896 common_params.url = GURL(url::kAboutBlankURL); | 897 RenderFrameImpl::FromRoutingID(routing_id)); |
897 provisional_frame->Navigate(common_params, StartNavigationParams(), | 898 EXPECT_FALSE(provisional_frame); |
898 RequestNavigationParams()); | 899 } |
899 ProcessPendingMessages(); | |
900 | |
901 // Check that there was no DidCommitProvisionalLoad. | |
902 const IPC::Message* frame_navigate_msg = | |
903 render_thread_->sink().GetUniqueMessageMatching( | |
904 FrameHostMsg_DidCommitProvisionalLoad::ID); | |
905 EXPECT_FALSE(frame_navigate_msg); | |
906 | |
907 // Detach the provisional frame to clean it up. Normally, the browser | |
908 // process would trigger this via FrameMsg_Delete. | |
909 provisional_frame->GetWebFrame()->detach(); | |
910 } | 900 } |
911 | 901 |
912 // Verify that the renderer process doesn't crash when device scale factor | 902 // Verify that the renderer process doesn't crash when device scale factor |
913 // changes after a cross-process navigation has commited. | 903 // changes after a cross-process navigation has commited. |
914 // See https://crbug.com/571603. | 904 // See https://crbug.com/571603. |
915 TEST_F(RenderViewImplTest, SetZoomLevelAfterCrossProcessNavigation) { | 905 TEST_F(RenderViewImplTest, SetZoomLevelAfterCrossProcessNavigation) { |
916 // This test should only run with out-of-process iframes enabled. | 906 // This test should only run with out-of-process iframes enabled. |
917 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) | 907 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
918 return; | 908 return; |
919 | 909 |
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 ExpectPauseAndResume(3); | 2555 ExpectPauseAndResume(3); |
2566 blink::WebScriptSource source2( | 2556 blink::WebScriptSource source2( |
2567 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2557 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
2568 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); | 2558 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); |
2569 | 2559 |
2570 EXPECT_FALSE(IsPaused()); | 2560 EXPECT_FALSE(IsPaused()); |
2571 Detach(); | 2561 Detach(); |
2572 } | 2562 } |
2573 | 2563 |
2574 } // namespace content | 2564 } // namespace content |
OLD | NEW |