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/child_process_security_policy_impl.h" |
13 #include "content/browser/renderer_host/render_view_host_impl.h" | 13 #include "content/browser/renderer_host/render_view_host_impl.h" |
14 #include "content/browser/site_instance_impl.h" | 14 #include "content/browser/site_instance_impl.h" |
15 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
| 16 #include "content/browser/webui/web_ui_impl.h" |
16 #include "content/common/content_constants_internal.h" | 17 #include "content/common/content_constants_internal.h" |
17 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
19 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
22 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
23 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
24 #include "content/public/test/test_navigation_observer.h" | 25 #include "content/public/test/test_navigation_observer.h" |
25 #include "content/public/test/test_utils.h" | 26 #include "content/public/test/test_utils.h" |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 Shell* shell2 = Shell::CreateNewWindow( | 1415 Shell* shell2 = Shell::CreateNewWindow( |
1415 shell()->web_contents()->GetBrowserContext(), GURL(), NULL, | 1416 shell()->web_contents()->GetBrowserContext(), GURL(), NULL, |
1416 MSG_ROUTING_NONE, gfx::Size()); | 1417 MSG_ROUTING_NONE, gfx::Size()); |
1417 RenderProcessHostWatcher crash_observer2( | 1418 RenderProcessHostWatcher crash_observer2( |
1418 shell2->web_contents(), | 1419 shell2->web_contents(), |
1419 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 1420 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
1420 NavigateToURL(shell2, GURL(kChromeUIKillURL)); | 1421 NavigateToURL(shell2, GURL(kChromeUIKillURL)); |
1421 crash_observer2.Wait(); | 1422 crash_observer2.Wait(); |
1422 } | 1423 } |
1423 | 1424 |
| 1425 // Ensure that pending_and_current_web_ui_ is cleared when a URL commits. |
| 1426 // Otherwise it might get picked up by InitRenderView when granting bindings |
| 1427 // to other RenderViewHosts. See http://crbug.com/330811. |
| 1428 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ClearPendingWebUIOnCommit) { |
| 1429 // Visit a WebUI page with bindings. |
| 1430 GURL webui_url(GURL(std::string(kChromeUIScheme) + "://" + |
| 1431 std::string(kChromeUIGpuHost))); |
| 1432 NavigateToURL(shell(), webui_url); |
| 1433 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 1434 shell()->web_contents()->GetRenderProcessHost()->GetID())); |
| 1435 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 1436 shell()->web_contents()); |
| 1437 WebUIImpl* webui = web_contents->GetRenderManagerForTesting()->web_ui(); |
| 1438 EXPECT_TRUE(webui); |
| 1439 EXPECT_FALSE(web_contents->GetRenderManagerForTesting()->pending_web_ui()); |
| 1440 |
| 1441 // Navigate to another WebUI URL that reuses the WebUI object. Make sure we |
| 1442 // clear pending_web_ui() when it commits. |
| 1443 GURL webui_url2(webui_url.spec() + "#foo"); |
| 1444 NavigateToURL(shell(), webui_url2); |
| 1445 EXPECT_EQ(webui, web_contents->GetRenderManagerForTesting()->web_ui()); |
| 1446 EXPECT_FALSE(web_contents->GetRenderManagerForTesting()->pending_web_ui()); |
| 1447 } |
| 1448 |
1424 } // namespace content | 1449 } // namespace content |
OLD | NEW |