OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "content/browser/child_process_security_policy_impl.h" |
12 #include "content/browser/renderer_host/render_view_host_impl.h" | 13 #include "content/browser/renderer_host/render_view_host_impl.h" |
13 #include "content/browser/site_instance_impl.h" | 14 #include "content/browser/site_instance_impl.h" |
14 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
15 #include "content/common/content_constants_internal.h" | 16 #include "content/common/content_constants_internal.h" |
16 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
17 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
18 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 // 3. Send the first tab to the second tab's process. | 1349 // 3. Send the first tab to the second tab's process. |
1349 NavigateToURL(shell(), https_server.GetURL("files/title1.html")); | 1350 NavigateToURL(shell(), https_server.GetURL("files/title1.html")); |
1350 | 1351 |
1351 // Make sure it ends up at the right page. | 1352 // Make sure it ends up at the right page. |
1352 WaitForLoadStop(shell()->web_contents()); | 1353 WaitForLoadStop(shell()->web_contents()); |
1353 EXPECT_EQ(https_server.GetURL("files/title1.html"), | 1354 EXPECT_EQ(https_server.GetURL("files/title1.html"), |
1354 shell()->web_contents()->GetLastCommittedURL()); | 1355 shell()->web_contents()->GetLastCommittedURL()); |
1355 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); | 1356 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); |
1356 } | 1357 } |
1357 | 1358 |
| 1359 // Ensure that renderer-side debug URLs do not cause a process swap, since they |
| 1360 // are meant to run in the current page. We had a bug where we expected a |
| 1361 // BrowsingInstance swap to occur on pages like view-source and extensions, |
| 1362 // which broke chrome://crash and javascript: URLs. |
| 1363 // See http://crbug.com/335503. |
| 1364 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, RendererDebugURLsDontSwap) { |
| 1365 ASSERT_TRUE(test_server()->Start()); |
| 1366 |
| 1367 GURL original_url(test_server()->GetURL("files/title2.html")); |
| 1368 GURL view_source_url(kViewSourceScheme + std::string(":") + |
| 1369 original_url.spec()); |
| 1370 |
| 1371 NavigateToURL(shell(), view_source_url); |
| 1372 |
| 1373 // Check that javascript: URLs work. |
| 1374 base::string16 expected_title = ASCIIToUTF16("msg"); |
| 1375 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 1376 shell()->LoadURL(GURL("javascript:document.title='msg'")); |
| 1377 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 1378 |
| 1379 // Crash the renderer of the view-source page. |
| 1380 RenderProcessHostWatcher crash_observer( |
| 1381 shell()->web_contents(), |
| 1382 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 1383 NavigateToURL(shell(), GURL(kChromeUICrashURL)); |
| 1384 crash_observer.Wait(); |
| 1385 } |
| 1386 |
| 1387 // Ensure that renderer-side debug URLs don't take effect on crashed renderers. |
| 1388 // Otherwise, we might try to load an unprivileged about:blank page into a |
| 1389 // WebUI-enabled RenderProcessHost, failing a safety check in InitRenderView. |
| 1390 // See http://crbug.com/334214. |
| 1391 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| 1392 IgnoreRendererDebugURLsWhenCrashed) { |
| 1393 // Visit a WebUI page with bindings. |
| 1394 GURL webui_url = GURL(std::string(chrome::kChromeUIScheme) + "://" + |
| 1395 std::string(kChromeUIGpuHost)); |
| 1396 NavigateToURL(shell(), webui_url); |
| 1397 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 1398 shell()->web_contents()->GetRenderProcessHost()->GetID())); |
| 1399 |
| 1400 // Crash the renderer of the WebUI page. |
| 1401 RenderProcessHostWatcher crash_observer( |
| 1402 shell()->web_contents(), |
| 1403 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 1404 NavigateToURL(shell(), GURL(kChromeUICrashURL)); |
| 1405 crash_observer.Wait(); |
| 1406 |
| 1407 // Load the crash URL again but don't wait for any action. If it is not |
| 1408 // ignored this time, we will fail the WebUI CHECK in InitRenderView. |
| 1409 shell()->LoadURL(GURL(kChromeUICrashURL)); |
| 1410 } |
| 1411 |
1358 } // namespace content | 1412 } // namespace content |
OLD | NEW |