Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 554743009: remove main_render_frame(), use GetMainRenderFrame() instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/npapi/webplugin_delegate_proxy.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is 495 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is
496 // already swapped out. http://crbug.com/93427. 496 // already swapped out. http://crbug.com/93427.
497 TEST_F(RenderViewImplTest, SendSwapOutACK) { 497 TEST_F(RenderViewImplTest, SendSwapOutACK) {
498 LoadHTML("<div>Page A</div>"); 498 LoadHTML("<div>Page A</div>");
499 int initial_page_id = view_page_id(); 499 int initial_page_id = view_page_id();
500 500
501 // Increment the ref count so that we don't exit when swapping out. 501 // Increment the ref count so that we don't exit when swapping out.
502 RenderProcess::current()->AddRefProcess(); 502 RenderProcess::current()->AddRefProcess();
503 503
504 // Respond to a swap out request. 504 // Respond to a swap out request.
505 view()->main_render_frame()->OnSwapOut(kProxyRoutingId); 505 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
506 506
507 // Ensure the swap out commits synchronously. 507 // Ensure the swap out commits synchronously.
508 EXPECT_NE(initial_page_id, view_page_id()); 508 EXPECT_NE(initial_page_id, view_page_id());
509 509
510 // Check for a valid OnSwapOutACK. 510 // Check for a valid OnSwapOutACK.
511 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 511 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
512 FrameHostMsg_SwapOut_ACK::ID); 512 FrameHostMsg_SwapOut_ACK::ID);
513 ASSERT_TRUE(msg); 513 ASSERT_TRUE(msg);
514 514
515 // It is possible to get another swap out request. Ensure that we send 515 // It is possible to get another swap out request. Ensure that we send
516 // an ACK, even if we don't have to do anything else. 516 // an ACK, even if we don't have to do anything else.
517 render_thread_->sink().ClearMessages(); 517 render_thread_->sink().ClearMessages();
518 view()->main_render_frame()->OnSwapOut(kProxyRoutingId); 518 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
519 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( 519 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
520 FrameHostMsg_SwapOut_ACK::ID); 520 FrameHostMsg_SwapOut_ACK::ID);
521 ASSERT_TRUE(msg2); 521 ASSERT_TRUE(msg2);
522 522
523 // If we navigate back to this RenderView, ensure we don't send a state 523 // If we navigate back to this RenderView, ensure we don't send a state
524 // update for the swapped out URL. (http://crbug.com/72235) 524 // update for the swapped out URL. (http://crbug.com/72235)
525 FrameMsg_Navigate_Params nav_params; 525 FrameMsg_Navigate_Params nav_params;
526 nav_params.url = GURL("data:text/html,<div>Page B</div>"); 526 nav_params.url = GURL("data:text/html,<div>Page B</div>");
527 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 527 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
528 nav_params.transition = PAGE_TRANSITION_TYPED; 528 nav_params.transition = PAGE_TRANSITION_TYPED;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 params_A.current_history_list_length = 2; 566 params_A.current_history_list_length = 2;
567 params_A.current_history_list_offset = 1; 567 params_A.current_history_list_offset = 1;
568 params_A.pending_history_list_offset = 0; 568 params_A.pending_history_list_offset = 0;
569 params_A.page_id = 1; 569 params_A.page_id = 1;
570 params_A.page_state = state_A; 570 params_A.page_state = state_A;
571 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); 571 params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
572 frame()->OnNavigate(params_A); 572 frame()->OnNavigate(params_A);
573 ProcessPendingMessages(); 573 ProcessPendingMessages();
574 574
575 // Respond to a swap out request. 575 // Respond to a swap out request.
576 view()->main_render_frame()->OnSwapOut(kProxyRoutingId); 576 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
577 577
578 // Check for a OnSwapOutACK. 578 // Check for a OnSwapOutACK.
579 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 579 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
580 FrameHostMsg_SwapOut_ACK::ID); 580 FrameHostMsg_SwapOut_ACK::ID);
581 ASSERT_TRUE(msg); 581 ASSERT_TRUE(msg);
582 render_thread_->sink().ClearMessages(); 582 render_thread_->sink().ClearMessages();
583 583
584 // It is possible to get a reload request at this point, containing the 584 // It is possible to get a reload request at this point, containing the
585 // params.page_state of the initial page (e.g., if the new page fails the 585 // params.page_state of the initial page (e.g., if the new page fails the
586 // provisional load in the renderer process, after we unload the old page). 586 // provisional load in the renderer process, after we unload the old page).
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 // Start a load that will reach provisional state synchronously, 1550 // Start a load that will reach provisional state synchronously,
1551 // but won't complete synchronously. 1551 // but won't complete synchronously.
1552 FrameMsg_Navigate_Params params; 1552 FrameMsg_Navigate_Params params;
1553 params.page_id = -1; 1553 params.page_id = -1;
1554 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1554 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1555 params.url = GURL("data:text/html,test data"); 1555 params.url = GURL("data:text/html,test data");
1556 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); 1556 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
1557 frame()->OnNavigate(params); 1557 frame()->OnNavigate(params);
1558 1558
1559 // An error occurred. 1559 // An error occurred.
1560 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 1560 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
1561 // Frame should exit view-source mode. 1561 // Frame should exit view-source mode.
1562 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); 1562 EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
1563 } 1563 }
1564 1564
1565 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { 1565 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) {
1566 GetMainFrame()->enableViewSourceMode(true); 1566 GetMainFrame()->enableViewSourceMode(true);
1567 WebURLError error; 1567 WebURLError error;
1568 error.domain = WebString::fromUTF8(net::kErrorDomain); 1568 error.domain = WebString::fromUTF8(net::kErrorDomain);
1569 error.reason = net::ERR_ABORTED; 1569 error.reason = net::ERR_ABORTED;
1570 error.unreachableURL = GURL("http://foo"); 1570 error.unreachableURL = GURL("http://foo");
1571 WebLocalFrame* web_frame = GetMainFrame(); 1571 WebLocalFrame* web_frame = GetMainFrame();
1572 1572
1573 // Start a load that will reach provisional state synchronously, 1573 // Start a load that will reach provisional state synchronously,
1574 // but won't complete synchronously. 1574 // but won't complete synchronously.
1575 FrameMsg_Navigate_Params params; 1575 FrameMsg_Navigate_Params params;
1576 params.page_id = -1; 1576 params.page_id = -1;
1577 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1577 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1578 params.url = GURL("data:text/html,test data"); 1578 params.url = GURL("data:text/html,test data");
1579 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); 1579 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
1580 frame()->OnNavigate(params); 1580 frame()->OnNavigate(params);
1581 1581
1582 // A cancellation occurred. 1582 // A cancellation occurred.
1583 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 1583 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
1584 // Frame should stay in view-source mode. 1584 // Frame should stay in view-source mode.
1585 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 1585 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
1586 } 1586 }
1587 1587
1588 // Regression test for http://crbug.com/41562 1588 // Regression test for http://crbug.com/41562
1589 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { 1589 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) {
1590 const GURL invalid_gurl("http://"); 1590 const GURL invalid_gurl("http://");
1591 view()->setMouseOverURL(blink::WebURL(invalid_gurl)); 1591 view()->setMouseOverURL(blink::WebURL(invalid_gurl));
1592 EXPECT_EQ(invalid_gurl, view()->target_url_); 1592 EXPECT_EQ(invalid_gurl, view()->target_url_);
1593 } 1593 }
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 // Start a load that will reach provisional state synchronously, 2159 // Start a load that will reach provisional state synchronously,
2160 // but won't complete synchronously. 2160 // but won't complete synchronously.
2161 FrameMsg_Navigate_Params params; 2161 FrameMsg_Navigate_Params params;
2162 params.page_id = -1; 2162 params.page_id = -1;
2163 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2163 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2164 params.url = GURL("data:text/html,test data"); 2164 params.url = GURL("data:text/html,test data");
2165 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); 2165 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
2166 frame()->OnNavigate(params); 2166 frame()->OnNavigate(params);
2167 2167
2168 // An error occurred. 2168 // An error occurred.
2169 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 2169 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
2170 const int kMaxOutputCharacters = 22; 2170 const int kMaxOutputCharacters = 22;
2171 EXPECT_EQ("", 2171 EXPECT_EQ("",
2172 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2172 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2173 } 2173 }
2174 2174
2175 #if defined(OS_ANDROID) 2175 #if defined(OS_ANDROID)
2176 // Crashing on Android: http://crbug.com/311341 2176 // Crashing on Android: http://crbug.com/311341
2177 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2177 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2178 #else 2178 #else
2179 #define MAYBE_DoesNotSuppress DoesNotSuppress 2179 #define MAYBE_DoesNotSuppress DoesNotSuppress
2180 #endif 2180 #endif
2181 2181
2182 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { 2182 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
2183 WebURLError error; 2183 WebURLError error;
2184 error.domain = WebString::fromUTF8(net::kErrorDomain); 2184 error.domain = WebString::fromUTF8(net::kErrorDomain);
2185 error.reason = net::ERR_FILE_NOT_FOUND; 2185 error.reason = net::ERR_FILE_NOT_FOUND;
2186 error.unreachableURL = GURL("http://example.com/dont-suppress"); 2186 error.unreachableURL = GURL("http://example.com/dont-suppress");
2187 WebLocalFrame* web_frame = GetMainFrame(); 2187 WebLocalFrame* web_frame = GetMainFrame();
2188 2188
2189 // Start a load that will reach provisional state synchronously, 2189 // Start a load that will reach provisional state synchronously,
2190 // but won't complete synchronously. 2190 // but won't complete synchronously.
2191 FrameMsg_Navigate_Params params; 2191 FrameMsg_Navigate_Params params;
2192 params.page_id = -1; 2192 params.page_id = -1;
2193 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2193 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2194 params.url = GURL("data:text/html,test data"); 2194 params.url = GURL("data:text/html,test data");
2195 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); 2195 params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
2196 frame()->OnNavigate(params); 2196 frame()->OnNavigate(params);
2197 2197
2198 // An error occurred. 2198 // An error occurred.
2199 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 2199 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
2200 // The error page itself is loaded asynchronously. 2200 // The error page itself is loaded asynchronously.
2201 FrameLoadWaiter(frame()).Wait(); 2201 FrameLoadWaiter(frame()).Wait();
2202 const int kMaxOutputCharacters = 22; 2202 const int kMaxOutputCharacters = 22;
2203 EXPECT_EQ("A suffusion of yellow.", 2203 EXPECT_EQ("A suffusion of yellow.",
2204 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2204 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2205 } 2205 }
2206 2206
2207 // Tests if IME API's candidatewindow* events sent from browser are handled 2207 // Tests if IME API's candidatewindow* events sent from browser are handled
2208 // in renderer. 2208 // in renderer.
2209 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) { 2209 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 ProcessPendingMessages(); 2434 ProcessPendingMessages();
2435 base::Time after_navigation = 2435 base::Time after_navigation =
2436 base::Time::Now() + base::TimeDelta::FromDays(1); 2436 base::Time::Now() + base::TimeDelta::FromDays(1);
2437 2437
2438 base::Time late_nav_reported_start = 2438 base::Time late_nav_reported_start =
2439 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2439 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2440 EXPECT_LE(late_nav_reported_start, after_navigation); 2440 EXPECT_LE(late_nav_reported_start, after_navigation);
2441 } 2441 }
2442 2442
2443 } // namespace content 2443 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/npapi/webplugin_delegate_proxy.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698