| 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 6126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6137 root->child_at(0)->render_manager()->GetProxyToParent()->GetRoutingID(); | 6137 root->child_at(0)->render_manager()->GetProxyToParent()->GetRoutingID(); |
| 6138 | 6138 |
| 6139 // Tell main frame A to delete its subframe B. | 6139 // Tell main frame A to delete its subframe B. |
| 6140 FrameDeletedObserver observer(root->child_at(0)); | 6140 FrameDeletedObserver observer(root->child_at(0)); |
| 6141 EXPECT_TRUE(ExecuteScript( | 6141 EXPECT_TRUE(ExecuteScript( |
| 6142 root, "document.body.removeChild(document.querySelector('iframe'));")); | 6142 root, "document.body.removeChild(document.querySelector('iframe'));")); |
| 6143 | 6143 |
| 6144 // Send the message to create a proxy for B's new child frame in A. This | 6144 // Send the message to create a proxy for B's new child frame in A. This |
| 6145 // used to crash, as parent_routing_id refers to a proxy that doesn't exist | 6145 // used to crash, as parent_routing_id refers to a proxy that doesn't exist |
| 6146 // anymore. | 6146 // anymore. |
| 6147 RenderProcessHostImpl::GetRendererInterface(process_a)->CreateFrameProxy( | 6147 process_a->GetRendererInterface()->CreateFrameProxy( |
| 6148 new_routing_id, view_routing_id, MSG_ROUTING_NONE, parent_routing_id, | 6148 new_routing_id, view_routing_id, MSG_ROUTING_NONE, parent_routing_id, |
| 6149 FrameReplicationState()); | 6149 FrameReplicationState()); |
| 6150 | 6150 |
| 6151 // Ensure the subframe is detached in the browser process. | 6151 // Ensure the subframe is detached in the browser process. |
| 6152 observer.Wait(); | 6152 observer.Wait(); |
| 6153 EXPECT_EQ(0U, root->child_count()); | 6153 EXPECT_EQ(0U, root->child_count()); |
| 6154 | 6154 |
| 6155 // Make sure process A did not crash. | 6155 // Make sure process A did not crash. |
| 6156 int child_count = 0; | 6156 int child_count = 0; |
| 6157 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 6157 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6213 params->proxy_routing_id = proxy_routing_id; | 6213 params->proxy_routing_id = proxy_routing_id; |
| 6214 params->opener_routing_id = IPC::mojom::kRoutingIdNone; | 6214 params->opener_routing_id = IPC::mojom::kRoutingIdNone; |
| 6215 params->parent_routing_id = | 6215 params->parent_routing_id = |
| 6216 shell()->web_contents()->GetMainFrame()->GetRoutingID(); | 6216 shell()->web_contents()->GetMainFrame()->GetRoutingID(); |
| 6217 params->previous_sibling_routing_id = IPC::mojom::kRoutingIdNone; | 6217 params->previous_sibling_routing_id = IPC::mojom::kRoutingIdNone; |
| 6218 params->widget_params = mojom::CreateFrameWidgetParams::New(); | 6218 params->widget_params = mojom::CreateFrameWidgetParams::New(); |
| 6219 params->widget_params->routing_id = IPC::mojom::kRoutingIdNone; | 6219 params->widget_params->routing_id = IPC::mojom::kRoutingIdNone; |
| 6220 params->widget_params->hidden = true; | 6220 params->widget_params->hidden = true; |
| 6221 params->replication_state.name = "name"; | 6221 params->replication_state.name = "name"; |
| 6222 params->replication_state.unique_name = "name"; | 6222 params->replication_state.unique_name = "name"; |
| 6223 RenderProcessHostImpl::GetRendererInterface(process)->CreateFrame( | 6223 process->GetRendererInterface()->CreateFrame(std::move(params)); |
| 6224 std::move(params)); | |
| 6225 } | 6224 } |
| 6226 | 6225 |
| 6227 // The test must wait for the process to exit, but if there is no leak, the | 6226 // The test must wait for the process to exit, but if there is no leak, the |
| 6228 // RenderFrame will be properly created and there will be no crash. | 6227 // RenderFrame will be properly created and there will be no crash. |
| 6229 // Therefore, navigate the main frame to completely different site, which | 6228 // Therefore, navigate the main frame to completely different site, which |
| 6230 // will cause the original process to exit cleanly. | 6229 // will cause the original process to exit cleanly. |
| 6231 EXPECT_TRUE(NavigateToURL( | 6230 EXPECT_TRUE(NavigateToURL( |
| 6232 shell(), embedded_test_server()->GetURL("d.com", "/title3.html"))); | 6231 shell(), embedded_test_server()->GetURL("d.com", "/title3.html"))); |
| 6233 watcher.Wait(); | 6232 watcher.Wait(); |
| 6234 EXPECT_TRUE(watcher.did_exit_normally()); | 6233 EXPECT_TRUE(watcher.did_exit_normally()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6279 params->routing_id = frame_routing_id; | 6278 params->routing_id = frame_routing_id; |
| 6280 params->proxy_routing_id = IPC::mojom::kRoutingIdNone; | 6279 params->proxy_routing_id = IPC::mojom::kRoutingIdNone; |
| 6281 params->opener_routing_id = IPC::mojom::kRoutingIdNone; | 6280 params->opener_routing_id = IPC::mojom::kRoutingIdNone; |
| 6282 params->parent_routing_id = parent_routing_id; | 6281 params->parent_routing_id = parent_routing_id; |
| 6283 params->previous_sibling_routing_id = IPC::mojom::kRoutingIdNone; | 6282 params->previous_sibling_routing_id = IPC::mojom::kRoutingIdNone; |
| 6284 params->widget_params = mojom::CreateFrameWidgetParams::New(); | 6283 params->widget_params = mojom::CreateFrameWidgetParams::New(); |
| 6285 params->widget_params->routing_id = widget_routing_id; | 6284 params->widget_params->routing_id = widget_routing_id; |
| 6286 params->widget_params->hidden = true; | 6285 params->widget_params->hidden = true; |
| 6287 params->replication_state.name = "name"; | 6286 params->replication_state.name = "name"; |
| 6288 params->replication_state.unique_name = "name"; | 6287 params->replication_state.unique_name = "name"; |
| 6289 RenderProcessHostImpl::GetRendererInterface(process)->CreateFrame( | 6288 process->GetRendererInterface()->CreateFrame(std::move(params)); |
| 6290 std::move(params)); | |
| 6291 } | 6289 } |
| 6292 | 6290 |
| 6293 // The test must wait for the process to exit, but if there is no leak, the | 6291 // The test must wait for the process to exit, but if there is no leak, the |
| 6294 // RenderFrame will be properly created and there will be no crash. | 6292 // RenderFrame will be properly created and there will be no crash. |
| 6295 // Therefore, navigate the remaining subframe to completely different site, | 6293 // Therefore, navigate the remaining subframe to completely different site, |
| 6296 // which will cause the original process to exit cleanly. | 6294 // which will cause the original process to exit cleanly. |
| 6297 NavigateFrameToURL(contents->GetFrameTree()->root()->child_at(0), | 6295 NavigateFrameToURL(contents->GetFrameTree()->root()->child_at(0), |
| 6298 embedded_test_server()->GetURL("d.com", "/title3.html")); | 6296 embedded_test_server()->GetURL("d.com", "/title3.html")); |
| 6299 watcher.Wait(); | 6297 watcher.Wait(); |
| 6300 EXPECT_TRUE(watcher.did_exit_normally()); | 6298 EXPECT_TRUE(watcher.did_exit_normally()); |
| (...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8518 EXPECT_TRUE(NavigateToURL(shell(), b_url)); | 8516 EXPECT_TRUE(NavigateToURL(shell(), b_url)); |
| 8519 | 8517 |
| 8520 base::string16 expected_title(base::UTF8ToUTF16("foo")); | 8518 base::string16 expected_title(base::UTF8ToUTF16("foo")); |
| 8521 TitleWatcher title_watcher(popup2->web_contents(), expected_title); | 8519 TitleWatcher title_watcher(popup2->web_contents(), expected_title); |
| 8522 EXPECT_TRUE(ExecuteScript( | 8520 EXPECT_TRUE(ExecuteScript( |
| 8523 shell(), "window.open('','popup2').postMessage('foo', '*');")); | 8521 shell(), "window.open('','popup2').postMessage('foo', '*');")); |
| 8524 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 8522 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 8525 } | 8523 } |
| 8526 | 8524 |
| 8527 } // namespace content | 8525 } // namespace content |
| OLD | NEW |