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 20 matching lines...) Expand all Loading... |
31 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 31 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
32 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" | 32 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" |
33 #include "content/browser/renderer_host/render_view_host_impl.h" | 33 #include "content/browser/renderer_host/render_view_host_impl.h" |
34 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 34 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
35 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 35 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
36 #include "content/browser/web_contents/web_contents_impl.h" | 36 #include "content/browser/web_contents/web_contents_impl.h" |
37 #include "content/common/child_process_messages.h" | 37 #include "content/common/child_process_messages.h" |
38 #include "content/common/frame_messages.h" | 38 #include "content/common/frame_messages.h" |
39 #include "content/common/input/synthetic_tap_gesture_params.h" | 39 #include "content/common/input/synthetic_tap_gesture_params.h" |
40 #include "content/common/input_messages.h" | 40 #include "content/common/input_messages.h" |
| 41 #include "content/common/renderer.mojom.h" |
41 #include "content/common/view_messages.h" | 42 #include "content/common/view_messages.h" |
42 #include "content/public/browser/interstitial_page_delegate.h" | 43 #include "content/public/browser/interstitial_page_delegate.h" |
43 #include "content/public/browser/notification_observer.h" | 44 #include "content/public/browser/notification_observer.h" |
44 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/notification_types.h" | 46 #include "content/public/browser/notification_types.h" |
46 #include "content/public/browser/resource_dispatcher_host.h" | 47 #include "content/public/browser/resource_dispatcher_host.h" |
47 #include "content/public/common/browser_side_navigation_policy.h" | 48 #include "content/public/common/browser_side_navigation_policy.h" |
48 #include "content/public/common/content_switches.h" | 49 #include "content/public/common/content_switches.h" |
49 #include "content/public/common/url_constants.h" | 50 #include "content/public/common/url_constants.h" |
50 #include "content/public/test/browser_test_utils.h" | 51 #include "content/public/test/browser_test_utils.h" |
51 #include "content/public/test/content_browser_test_utils.h" | 52 #include "content/public/test/content_browser_test_utils.h" |
52 #include "content/public/test/test_navigation_observer.h" | 53 #include "content/public/test/test_navigation_observer.h" |
53 #include "content/public/test/test_utils.h" | 54 #include "content/public/test/test_utils.h" |
54 #include "content/test/content_browser_test_utils_internal.h" | 55 #include "content/test/content_browser_test_utils_internal.h" |
55 #include "content/test/test_frame_navigation_observer.h" | 56 #include "content/test/test_frame_navigation_observer.h" |
| 57 #include "ipc/ipc.mojom.h" |
56 #include "ipc/ipc_security_test_util.h" | 58 #include "ipc/ipc_security_test_util.h" |
57 #include "net/dns/mock_host_resolver.h" | 59 #include "net/dns/mock_host_resolver.h" |
58 #include "net/test/embedded_test_server/embedded_test_server.h" | 60 #include "net/test/embedded_test_server/embedded_test_server.h" |
59 #include "testing/gtest/include/gtest/gtest.h" | 61 #include "testing/gtest/include/gtest/gtest.h" |
60 #include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h" | 62 #include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h" |
61 #include "third_party/WebKit/public/web/WebInputEvent.h" | 63 #include "third_party/WebKit/public/web/WebInputEvent.h" |
62 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 64 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
63 #include "ui/display/display_switches.h" | 65 #include "ui/display/display_switches.h" |
64 #include "ui/display/screen.h" | 66 #include "ui/display/screen.h" |
65 #include "ui/events/event.h" | 67 #include "ui/events/event.h" |
(...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 std::string result; | 3158 std::string result; |
3157 EXPECT_TRUE(ExecuteScriptAndExtractString( | 3159 EXPECT_TRUE(ExecuteScriptAndExtractString( |
3158 tiptop_child, | 3160 tiptop_child, |
3159 "window.domAutomationController.send(location.ancestorOrigins[0]);", | 3161 "window.domAutomationController.send(location.ancestorOrigins[0]);", |
3160 &result)); | 3162 &result)); |
3161 EXPECT_EQ(a_origin, result + "/"); | 3163 EXPECT_EQ(a_origin, result + "/"); |
3162 | 3164 |
3163 // Check that c.com frame's location.ancestorOrigins contains the correct | 3165 // Check that c.com frame's location.ancestorOrigins contains the correct |
3164 // origin for its two ancestors. The topmost parent origin should be | 3166 // origin for its two ancestors. The topmost parent origin should be |
3165 // replicated as part of mojom::Renderer::CreateView, and the middle frame | 3167 // replicated as part of mojom::Renderer::CreateView, and the middle frame |
3166 // (b.com's) origin should be replicated as part of FrameMsg_NewFrameProxy | 3168 // (b.com's) origin should be replicated as part of |
3167 // sent for b.com's frame in c.com's process. | 3169 // mojom::Renderer::CreateFrameProxy sent for b.com's frame in c.com's |
| 3170 // process. |
3168 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 3171 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
3169 middle_child, | 3172 middle_child, |
3170 "window.domAutomationController.send(location.ancestorOrigins.length);", | 3173 "window.domAutomationController.send(location.ancestorOrigins.length);", |
3171 &ancestor_origins_length)); | 3174 &ancestor_origins_length)); |
3172 EXPECT_EQ(2, ancestor_origins_length); | 3175 EXPECT_EQ(2, ancestor_origins_length); |
3173 EXPECT_TRUE(ExecuteScriptAndExtractString( | 3176 EXPECT_TRUE(ExecuteScriptAndExtractString( |
3174 middle_child, | 3177 middle_child, |
3175 "window.domAutomationController.send(location.ancestorOrigins[0]);", | 3178 "window.domAutomationController.send(location.ancestorOrigins[0]);", |
3176 &result)); | 3179 &result)); |
3177 EXPECT_EQ(b_origin, result + "/"); | 3180 EXPECT_EQ(b_origin, result + "/"); |
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4625 root->child_at(1), | 4628 root->child_at(1), |
4626 "window.domAutomationController.send(" | 4629 "window.domAutomationController.send(" |
4627 " parent.frames['frame1'].opener === parent);", | 4630 " parent.frames['frame1'].opener === parent);", |
4628 &success)); | 4631 &success)); |
4629 EXPECT_TRUE(success); | 4632 EXPECT_TRUE(success); |
4630 } | 4633 } |
4631 | 4634 |
4632 // Check that if a subframe has an opener, that opener is preserved when a new | 4635 // Check that if a subframe has an opener, that opener is preserved when a new |
4633 // RenderFrameProxy is created for that subframe in another renderer process. | 4636 // RenderFrameProxy is created for that subframe in another renderer process. |
4634 // Similar to NavigateSubframeWithOpener, but this test verifies the subframe | 4637 // Similar to NavigateSubframeWithOpener, but this test verifies the subframe |
4635 // opener plumbing for FrameMsg_NewFrameProxy, whereas | 4638 // opener plumbing for mojom::Renderer::CreateFrameProxy(), whereas |
4636 // NavigateSubframeWithOpener targets FrameMsg_NewFrame. | 4639 // NavigateSubframeWithOpener targets mojom::Renderer::CreateFrame(). |
4637 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4640 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4638 NewRenderFrameProxyPreservesOpener) { | 4641 NewRenderFrameProxyPreservesOpener) { |
4639 GURL main_url( | 4642 GURL main_url( |
4640 embedded_test_server()->GetURL("foo.com", "/post_message.html")); | 4643 embedded_test_server()->GetURL("foo.com", "/post_message.html")); |
4641 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4644 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4642 | 4645 |
4643 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 4646 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4644 | 4647 |
4645 // Open a popup with a cross-site page that has two subframes. | 4648 // Open a popup with a cross-site page that has two subframes. |
4646 GURL popup_url(embedded_test_server()->GetURL( | 4649 GURL popup_url(embedded_test_server()->GetURL( |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6065 root->child_at(0)->render_manager()->GetProxyToParent()->GetRoutingID(); | 6068 root->child_at(0)->render_manager()->GetProxyToParent()->GetRoutingID(); |
6066 | 6069 |
6067 // Tell main frame A to delete its subframe B. | 6070 // Tell main frame A to delete its subframe B. |
6068 FrameDeletedObserver observer(root->child_at(0)); | 6071 FrameDeletedObserver observer(root->child_at(0)); |
6069 EXPECT_TRUE(ExecuteScript( | 6072 EXPECT_TRUE(ExecuteScript( |
6070 root, "document.body.removeChild(document.querySelector('iframe'));")); | 6073 root, "document.body.removeChild(document.querySelector('iframe'));")); |
6071 | 6074 |
6072 // Send the message to create a proxy for B's new child frame in A. This | 6075 // Send the message to create a proxy for B's new child frame in A. This |
6073 // used to crash, as parent_routing_id refers to a proxy that doesn't exist | 6076 // used to crash, as parent_routing_id refers to a proxy that doesn't exist |
6074 // anymore. | 6077 // anymore. |
6075 process_a->Send(new FrameMsg_NewFrameProxy( | 6078 RenderProcessHostImpl::GetRendererInterface(process_a)->CreateFrameProxy( |
6076 new_routing_id, view_routing_id, MSG_ROUTING_NONE, parent_routing_id, | 6079 new_routing_id, view_routing_id, MSG_ROUTING_NONE, parent_routing_id, |
6077 FrameReplicationState())); | 6080 FrameReplicationState()); |
6078 | 6081 |
6079 // Ensure the subframe is detached in the browser process. | 6082 // Ensure the subframe is detached in the browser process. |
6080 observer.Wait(); | 6083 observer.Wait(); |
6081 EXPECT_EQ(0U, root->child_count()); | 6084 EXPECT_EQ(0U, root->child_count()); |
6082 | 6085 |
6083 // Make sure process A did not crash. | 6086 // Make sure process A did not crash. |
6084 int child_count = 0; | 6087 int child_count = 0; |
6085 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 6088 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
6086 root, "domAutomationController.send(frames.length)", &child_count)); | 6089 root, "domAutomationController.send(frames.length)", &child_count)); |
6087 EXPECT_EQ(0, child_count); | 6090 EXPECT_EQ(0, child_count); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6129 : node->render_manager()->pending_frame_host()->GetRoutingID(); | 6132 : node->render_manager()->pending_frame_host()->GetRoutingID(); |
6130 int proxy_routing_id = | 6133 int proxy_routing_id = |
6131 node->render_manager()->GetProxyToParent()->GetRoutingID(); | 6134 node->render_manager()->GetProxyToParent()->GetRoutingID(); |
6132 | 6135 |
6133 // Now go to c.com so the navigation to a.com is cancelled and send an IPC | 6136 // Now go to c.com so the navigation to a.com is cancelled and send an IPC |
6134 // to create a new RenderFrame with the routing id of the previously pending | 6137 // to create a new RenderFrame with the routing id of the previously pending |
6135 // one. | 6138 // one. |
6136 NavigateFrameToURL(node, | 6139 NavigateFrameToURL(node, |
6137 embedded_test_server()->GetURL("c.com", "/title2.html")); | 6140 embedded_test_server()->GetURL("c.com", "/title2.html")); |
6138 { | 6141 { |
6139 FrameMsg_NewFrame_Params params; | 6142 mojom::CreateFrameParamsPtr params = mojom::CreateFrameParams::New(); |
6140 params.routing_id = frame_routing_id; | 6143 params->routing_id = frame_routing_id; |
6141 params.proxy_routing_id = proxy_routing_id; | 6144 params->proxy_routing_id = proxy_routing_id; |
6142 params.opener_routing_id = MSG_ROUTING_NONE; | 6145 params->opener_routing_id = IPC::mojom::kRoutingIdNone; |
6143 params.parent_routing_id = | 6146 params->parent_routing_id = |
6144 shell()->web_contents()->GetMainFrame()->GetRoutingID(); | 6147 shell()->web_contents()->GetMainFrame()->GetRoutingID(); |
6145 params.previous_sibling_routing_id = MSG_ROUTING_NONE; | 6148 params->previous_sibling_routing_id = IPC::mojom::kRoutingIdNone; |
6146 params.widget_params.routing_id = MSG_ROUTING_NONE; | 6149 params->widget_params = mojom::CreateFrameWidgetParams::New(); |
6147 params.widget_params.hidden = true; | 6150 params->widget_params->routing_id = IPC::mojom::kRoutingIdNone; |
6148 params.replication_state.name = "name"; | 6151 params->widget_params->hidden = true; |
6149 params.replication_state.unique_name = "name"; | 6152 params->replication_state.name = "name"; |
6150 | 6153 params->replication_state.unique_name = "name"; |
6151 process->Send(new FrameMsg_NewFrame(params)); | 6154 RenderProcessHostImpl::GetRendererInterface(process)->CreateFrame( |
| 6155 std::move(params)); |
6152 } | 6156 } |
6153 | 6157 |
6154 // The test must wait for the process to exit, but if there is no leak, the | 6158 // The test must wait for the process to exit, but if there is no leak, the |
6155 // RenderFrame will be properly created and there will be no crash. | 6159 // RenderFrame will be properly created and there will be no crash. |
6156 // Therefore, navigate the main frame to completely different site, which | 6160 // Therefore, navigate the main frame to completely different site, which |
6157 // will cause the original process to exit cleanly. | 6161 // will cause the original process to exit cleanly. |
6158 EXPECT_TRUE(NavigateToURL( | 6162 EXPECT_TRUE(NavigateToURL( |
6159 shell(), embedded_test_server()->GetURL("d.com", "/title3.html"))); | 6163 shell(), embedded_test_server()->GetURL("d.com", "/title3.html"))); |
6160 watcher.Wait(); | 6164 watcher.Wait(); |
6161 EXPECT_TRUE(watcher.did_exit_normally()); | 6165 EXPECT_TRUE(watcher.did_exit_normally()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6195 node->current_frame_host()->GetSiteInstance()); | 6199 node->current_frame_host()->GetSiteInstance()); |
6196 | 6200 |
6197 // Have the parent frame remove the child frame from its DOM. This should | 6201 // Have the parent frame remove the child frame from its DOM. This should |
6198 // result in the child RenderFrame being deleted in the remote process. | 6202 // result in the child RenderFrame being deleted in the remote process. |
6199 EXPECT_TRUE(ExecuteScript(contents, | 6203 EXPECT_TRUE(ExecuteScript(contents, |
6200 "document.body.removeChild(" | 6204 "document.body.removeChild(" |
6201 "document.querySelectorAll('iframe')[0])")); | 6205 "document.querySelectorAll('iframe')[0])")); |
6202 EXPECT_EQ(1U, contents->GetFrameTree()->root()->child_count()); | 6206 EXPECT_EQ(1U, contents->GetFrameTree()->root()->child_count()); |
6203 | 6207 |
6204 { | 6208 { |
6205 FrameMsg_NewFrame_Params params; | 6209 mojom::CreateFrameParamsPtr params = mojom::CreateFrameParams::New(); |
6206 params.routing_id = frame_routing_id; | 6210 params->routing_id = frame_routing_id; |
6207 params.proxy_routing_id = MSG_ROUTING_NONE; | 6211 params->proxy_routing_id = IPC::mojom::kRoutingIdNone; |
6208 params.opener_routing_id = MSG_ROUTING_NONE; | 6212 params->opener_routing_id = IPC::mojom::kRoutingIdNone; |
6209 params.parent_routing_id = parent_routing_id; | 6213 params->parent_routing_id = parent_routing_id; |
6210 params.previous_sibling_routing_id = MSG_ROUTING_NONE; | 6214 params->previous_sibling_routing_id = IPC::mojom::kRoutingIdNone; |
6211 params.widget_params.routing_id = widget_routing_id; | 6215 params->widget_params = mojom::CreateFrameWidgetParams::New(); |
6212 params.widget_params.hidden = true; | 6216 params->widget_params->routing_id = widget_routing_id; |
6213 params.replication_state.name = "name"; | 6217 params->widget_params->hidden = true; |
6214 params.replication_state.unique_name = "name"; | 6218 params->replication_state.name = "name"; |
6215 | 6219 params->replication_state.unique_name = "name"; |
6216 process->Send(new FrameMsg_NewFrame(params)); | 6220 RenderProcessHostImpl::GetRendererInterface(process)->CreateFrame( |
| 6221 std::move(params)); |
6217 } | 6222 } |
6218 | 6223 |
6219 // The test must wait for the process to exit, but if there is no leak, the | 6224 // The test must wait for the process to exit, but if there is no leak, the |
6220 // RenderFrame will be properly created and there will be no crash. | 6225 // RenderFrame will be properly created and there will be no crash. |
6221 // Therefore, navigate the remaining subframe to completely different site, | 6226 // Therefore, navigate the remaining subframe to completely different site, |
6222 // which will cause the original process to exit cleanly. | 6227 // which will cause the original process to exit cleanly. |
6223 NavigateFrameToURL(contents->GetFrameTree()->root()->child_at(0), | 6228 NavigateFrameToURL(contents->GetFrameTree()->root()->child_at(0), |
6224 embedded_test_server()->GetURL("d.com", "/title3.html")); | 6229 embedded_test_server()->GetURL("d.com", "/title3.html")); |
6225 watcher.Wait(); | 6230 watcher.Wait(); |
6226 EXPECT_TRUE(watcher.did_exit_normally()); | 6231 EXPECT_TRUE(watcher.did_exit_normally()); |
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8224 " Site A ------------ proxies for B C\n" | 8229 " Site A ------------ proxies for B C\n" |
8225 " +--Site B ------- proxies for A C\n" | 8230 " +--Site B ------- proxies for A C\n" |
8226 " +--Site C -- proxies for A B\n" | 8231 " +--Site C -- proxies for A B\n" |
8227 "Where A = http://a.com/\n" | 8232 "Where A = http://a.com/\n" |
8228 " B = http://b.com/\n" | 8233 " B = http://b.com/\n" |
8229 " C = http://c.com/", | 8234 " C = http://c.com/", |
8230 DepictFrameTree(root)); | 8235 DepictFrameTree(root)); |
8231 } | 8236 } |
8232 | 8237 |
8233 } // namespace content | 8238 } // namespace content |
OLD | NEW |