| 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/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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 new_view->Release(); | 512 new_view->Release(); |
| 513 } | 513 } |
| 514 | 514 |
| 515 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is | 515 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is |
| 516 // already swapped out. http://crbug.com/93427. | 516 // already swapped out. http://crbug.com/93427. |
| 517 TEST_F(RenderViewImplTest, SendSwapOutACK) { | 517 TEST_F(RenderViewImplTest, SendSwapOutACK) { |
| 518 LoadHTML("<div>Page A</div>"); | 518 LoadHTML("<div>Page A</div>"); |
| 519 int initial_page_id = view()->GetPageId(); | 519 int initial_page_id = view()->GetPageId(); |
| 520 | 520 |
| 521 // Respond to a swap out request. | 521 // Respond to a swap out request. |
| 522 view()->OnSwapOut(); | 522 view()->main_render_frame()->OnSwapOut(); |
| 523 | 523 |
| 524 // Ensure the swap out commits synchronously. | 524 // Ensure the swap out commits synchronously. |
| 525 EXPECT_NE(initial_page_id, view()->GetPageId()); | 525 EXPECT_NE(initial_page_id, view()->GetPageId()); |
| 526 | 526 |
| 527 // Check for a valid OnSwapOutACK. | 527 // Check for a valid OnSwapOutACK. |
| 528 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 528 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 529 ViewHostMsg_SwapOut_ACK::ID); | 529 FrameHostMsg_SwapOut_ACK::ID); |
| 530 ASSERT_TRUE(msg); | 530 ASSERT_TRUE(msg); |
| 531 | 531 |
| 532 // It is possible to get another swap out request. Ensure that we send | 532 // It is possible to get another swap out request. Ensure that we send |
| 533 // an ACK, even if we don't have to do anything else. | 533 // an ACK, even if we don't have to do anything else. |
| 534 render_thread_->sink().ClearMessages(); | 534 render_thread_->sink().ClearMessages(); |
| 535 view()->OnSwapOut(); | 535 view()->main_render_frame()->OnSwapOut(); |
| 536 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 536 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
| 537 ViewHostMsg_SwapOut_ACK::ID); | 537 FrameHostMsg_SwapOut_ACK::ID); |
| 538 ASSERT_TRUE(msg2); | 538 ASSERT_TRUE(msg2); |
| 539 | 539 |
| 540 // If we navigate back to this RenderView, ensure we don't send a state | 540 // If we navigate back to this RenderView, ensure we don't send a state |
| 541 // update for the swapped out URL. (http://crbug.com/72235) | 541 // update for the swapped out URL. (http://crbug.com/72235) |
| 542 FrameMsg_Navigate_Params nav_params; | 542 FrameMsg_Navigate_Params nav_params; |
| 543 nav_params.url = GURL("data:text/html,<div>Page B</div>"); | 543 nav_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 544 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 544 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 545 nav_params.transition = PAGE_TRANSITION_TYPED; | 545 nav_params.transition = PAGE_TRANSITION_TYPED; |
| 546 nav_params.current_history_list_length = 1; | 546 nav_params.current_history_list_length = 1; |
| 547 nav_params.current_history_list_offset = 0; | 547 nav_params.current_history_list_offset = 0; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; | 580 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; |
| 581 params_A.current_history_list_length = 2; | 581 params_A.current_history_list_length = 2; |
| 582 params_A.current_history_list_offset = 1; | 582 params_A.current_history_list_offset = 1; |
| 583 params_A.pending_history_list_offset = 0; | 583 params_A.pending_history_list_offset = 0; |
| 584 params_A.page_id = 1; | 584 params_A.page_id = 1; |
| 585 params_A.page_state = state_A; | 585 params_A.page_state = state_A; |
| 586 frame()->OnNavigate(params_A); | 586 frame()->OnNavigate(params_A); |
| 587 ProcessPendingMessages(); | 587 ProcessPendingMessages(); |
| 588 | 588 |
| 589 // Respond to a swap out request. | 589 // Respond to a swap out request. |
| 590 view()->OnSwapOut(); | 590 view()->main_render_frame()->OnSwapOut(); |
| 591 | 591 |
| 592 // Check for a OnSwapOutACK. | 592 // Check for a OnSwapOutACK. |
| 593 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 593 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 594 ViewHostMsg_SwapOut_ACK::ID); | 594 FrameHostMsg_SwapOut_ACK::ID); |
| 595 ASSERT_TRUE(msg); | 595 ASSERT_TRUE(msg); |
| 596 render_thread_->sink().ClearMessages(); | 596 render_thread_->sink().ClearMessages(); |
| 597 | 597 |
| 598 // It is possible to get a reload request at this point, containing the | 598 // It is possible to get a reload request at this point, containing the |
| 599 // params.page_state of the initial page (e.g., if the new page fails the | 599 // params.page_state of the initial page (e.g., if the new page fails the |
| 600 // provisional load in the renderer process, after we unload the old page). | 600 // provisional load in the renderer process, after we unload the old page). |
| 601 // Ensure the old page gets reloaded, not swappedout://. | 601 // Ensure the old page gets reloaded, not swappedout://. |
| 602 FrameMsg_Navigate_Params nav_params; | 602 FrameMsg_Navigate_Params nav_params; |
| 603 nav_params.url = GURL("data:text/html,<div>Page A</div>"); | 603 nav_params.url = GURL("data:text/html,<div>Page A</div>"); |
| 604 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; | 604 nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; |
| (...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 request.setTargetType(blink::WebURLRequest::TargetIsSubresource); | 2321 request.setTargetType(blink::WebURLRequest::TargetIsSubresource); |
| 2322 blink::WebURLResponse redirect_response; | 2322 blink::WebURLResponse redirect_response; |
| 2323 frame()->willSendRequest(GetMainFrame(), 0, request, redirect_response); | 2323 frame()->willSendRequest(GetMainFrame(), 0, request, redirect_response); |
| 2324 extra_data = static_cast<RequestExtraData*>(request.extraData()); | 2324 extra_data = static_cast<RequestExtraData*>(request.extraData()); |
| 2325 ASSERT_TRUE(extra_data); | 2325 ASSERT_TRUE(extra_data); |
| 2326 EXPECT_EQ(extra_data->service_worker_provider_id(), | 2326 EXPECT_EQ(extra_data->service_worker_provider_id(), |
| 2327 provider->provider_id()); | 2327 provider->provider_id()); |
| 2328 } | 2328 } |
| 2329 | 2329 |
| 2330 } // namespace content | 2330 } // namespace content |
| OLD | NEW |