| 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 "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/browser/child_process_security_policy_impl.h" | 7 #include "content/browser/child_process_security_policy_impl.h" |
| 8 #include "content/browser/frame_host/render_frame_host_impl.h" | 8 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 9 #include "content/common/input_messages.h" | 9 #include "content/common/input_messages.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ASSERT_TRUE(controller().GetVisibleEntry()); | 65 ASSERT_TRUE(controller().GetVisibleEntry()); |
| 66 EXPECT_EQ(GURL(kAboutBlankURL), controller().GetVisibleEntry()->GetURL()); | 66 EXPECT_EQ(GURL(kAboutBlankURL), controller().GetVisibleEntry()->GetURL()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Create a full screen popup RenderWidgetHost and View. | 69 // Create a full screen popup RenderWidgetHost and View. |
| 70 TEST_F(RenderViewHostTest, CreateFullscreenWidget) { | 70 TEST_F(RenderViewHostTest, CreateFullscreenWidget) { |
| 71 int routing_id = process()->GetNextRoutingID(); | 71 int routing_id = process()->GetNextRoutingID(); |
| 72 test_rvh()->CreateNewFullscreenWidget(routing_id); | 72 test_rvh()->CreateNewFullscreenWidget(routing_id); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Makes sure that RenderViewHost::is_waiting_for_unload_ack_ is false when | 75 // Makes sure that the RenderViewHost is not waiting for an unload ack when |
| 76 // reloading a page. If is_waiting_for_unload_ack_ is not false when reloading | 76 // reloading a page. If this is not the case, when reloading, the contents may |
| 77 // the contents may get closed out even though the user pressed the reload | 77 // get closed out even though the user pressed the reload button. |
| 78 // button. | |
| 79 TEST_F(RenderViewHostTest, ResetUnloadOnReload) { | 78 TEST_F(RenderViewHostTest, ResetUnloadOnReload) { |
| 80 const GURL url1("http://foo1"); | 79 const GURL url1("http://foo1"); |
| 81 const GURL url2("http://foo2"); | 80 const GURL url2("http://foo2"); |
| 82 | 81 |
| 83 // This test is for a subtle timing bug. Here's the sequence that triggered | 82 // This test is for a subtle timing bug. Here's the sequence that triggered |
| 84 // the bug: | 83 // the bug: |
| 85 // . go to a page. | 84 // . go to a page. |
| 86 // . go to a new page, preferably one that takes a while to resolve, such | 85 // . go to a new page, preferably one that takes a while to resolve, such |
| 87 // as one on a site that doesn't exist. | 86 // as one on a site that doesn't exist. |
| 88 // . After this step is_waiting_for_unload_ack_ has been set to true on | 87 // . After this step IsWaitingForUnloadACK returns true on the first RVH. |
| 89 // the first RVH. | |
| 90 // . click stop before the page has been commited. | 88 // . click stop before the page has been commited. |
| 91 // . click reload. | 89 // . click reload. |
| 92 // . is_waiting_for_unload_ack_ is still true, and the if the hang monitor | 90 // . IsWaitingForUnloadACK still returns true, and if the hang monitor fires |
| 93 // fires the contents gets closed. | 91 // the contents gets closed. |
| 94 | 92 |
| 95 NavigateAndCommit(url1); | 93 NavigateAndCommit(url1); |
| 96 controller().LoadURL( | 94 controller().LoadURL( |
| 97 url2, Referrer(), PAGE_TRANSITION_LINK, std::string()); | 95 url2, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
| 98 // Simulate the ClosePage call which is normally sent by the net::URLRequest. | 96 // Simulate the ClosePage call which is normally sent by the net::URLRequest. |
| 99 rvh()->ClosePage(); | 97 rvh()->ClosePage(); |
| 100 // Needed so that navigations are not suspended on the RVH. | 98 // Needed so that navigations are not suspended on the RVH. |
| 101 test_rvh()->SendShouldCloseACK(true); | 99 test_rvh()->SendShouldCloseACK(true); |
| 102 contents()->Stop(); | 100 contents()->Stop(); |
| 103 controller().Reload(false); | 101 controller().Reload(false); |
| 104 EXPECT_FALSE(test_rvh()->is_waiting_for_unload_ack()); | 102 EXPECT_FALSE(test_rvh()->IsWaitingForUnloadACK()); |
| 105 } | 103 } |
| 106 | 104 |
| 107 // Ensure we do not grant bindings to a process shared with unprivileged views. | 105 // Ensure we do not grant bindings to a process shared with unprivileged views. |
| 108 TEST_F(RenderViewHostTest, DontGrantBindingsToSharedProcess) { | 106 TEST_F(RenderViewHostTest, DontGrantBindingsToSharedProcess) { |
| 109 // Create another view in the same process. | 107 // Create another view in the same process. |
| 110 scoped_ptr<TestWebContents> new_web_contents( | 108 scoped_ptr<TestWebContents> new_web_contents( |
| 111 TestWebContents::Create(browser_context(), rvh()->GetSiteInstance())); | 109 TestWebContents::Create(browser_context(), rvh()->GetSiteInstance())); |
| 112 | 110 |
| 113 rvh()->AllowBindings(BINDINGS_POLICY_WEB_UI); | 111 rvh()->AllowBindings(BINDINGS_POLICY_WEB_UI); |
| 114 EXPECT_FALSE(rvh()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 112 EXPECT_FALSE(rvh()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 287 } |
| 290 | 288 |
| 291 TEST_F(RenderViewHostTest, RoutingIdSane) { | 289 TEST_F(RenderViewHostTest, RoutingIdSane) { |
| 292 RenderFrameHostImpl* root_rfh = | 290 RenderFrameHostImpl* root_rfh = |
| 293 contents()->GetFrameTree()->root()->current_frame_host(); | 291 contents()->GetFrameTree()->root()->current_frame_host(); |
| 294 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); | 292 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); |
| 295 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); | 293 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); |
| 296 } | 294 } |
| 297 | 295 |
| 298 } // namespace content | 296 } // namespace content |
| OLD | NEW |