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 | 6 |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/common/intents_messages.h" | 10 #include "content/common/intents_messages.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // notification. We need to spin the message loop to catch this update. | 53 // notification. We need to spin the message loop to catch this update. |
54 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); | 54 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); |
55 ProcessPendingMessages(); | 55 ProcessPendingMessages(); |
56 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 56 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
57 ViewHostMsg_UpdateState::ID)); | 57 ViewHostMsg_UpdateState::ID)); |
58 } | 58 } |
59 | 59 |
60 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is | 60 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is |
61 // already swapped out. http://crbug.com/93427. | 61 // already swapped out. http://crbug.com/93427. |
62 TEST_F(RenderViewImplTest, SendSwapOutACK) { | 62 TEST_F(RenderViewImplTest, SendSwapOutACK) { |
| 63 LoadHTML("<div>Page A</div>"); |
63 int initial_page_id = view()->GetPageId(); | 64 int initial_page_id = view()->GetPageId(); |
64 | 65 |
65 // Respond to a swap out request. | 66 // Respond to a swap out request. |
66 ViewMsg_SwapOut_Params params; | 67 ViewMsg_SwapOut_Params params; |
67 params.closing_process_id = 10; | 68 params.closing_process_id = 10; |
68 params.closing_route_id = 11; | 69 params.closing_route_id = 11; |
69 params.new_render_process_host_id = 12; | 70 params.new_render_process_host_id = 12; |
70 params.new_request_id = 13; | 71 params.new_request_id = 13; |
71 view()->OnSwapOut(params); | 72 view()->OnSwapOut(params); |
72 | 73 |
(...skipping 12 matching lines...) Expand all Loading... |
85 reply_params.a.new_render_process_host_id); | 86 reply_params.a.new_render_process_host_id); |
86 EXPECT_EQ(params.new_request_id, reply_params.a.new_request_id); | 87 EXPECT_EQ(params.new_request_id, reply_params.a.new_request_id); |
87 | 88 |
88 // It is possible to get another swap out request. Ensure that we send | 89 // It is possible to get another swap out request. Ensure that we send |
89 // an ACK, even if we don't have to do anything else. | 90 // an ACK, even if we don't have to do anything else. |
90 render_thread_->sink().ClearMessages(); | 91 render_thread_->sink().ClearMessages(); |
91 view()->OnSwapOut(params); | 92 view()->OnSwapOut(params); |
92 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 93 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
93 ViewHostMsg_SwapOut_ACK::ID); | 94 ViewHostMsg_SwapOut_ACK::ID); |
94 ASSERT_TRUE(msg2); | 95 ASSERT_TRUE(msg2); |
| 96 |
| 97 // If we navigate back to this RenderView, ensure we don't send a state |
| 98 // update for the swapped out URL. (http://crbug.com/72235) |
| 99 ViewMsg_Navigate_Params nav_params; |
| 100 nav_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 101 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
| 102 nav_params.transition = content::PAGE_TRANSITION_TYPED; |
| 103 nav_params.current_history_list_length = 1; |
| 104 nav_params.current_history_list_offset = 0; |
| 105 nav_params.pending_history_list_offset = 1; |
| 106 nav_params.page_id = -1; |
| 107 view()->OnNavigate(nav_params); |
| 108 ProcessPendingMessages(); |
| 109 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
| 110 ViewHostMsg_UpdateState::ID); |
| 111 EXPECT_FALSE(msg3); |
95 } | 112 } |
96 | 113 |
97 // Test that we get the correct UpdateState message when we go back twice | 114 // Test that we get the correct UpdateState message when we go back twice |
98 // quickly without committing. Regression test for http://crbug.com/58082. | 115 // quickly without committing. Regression test for http://crbug.com/58082. |
99 TEST_F(RenderViewImplTest, LastCommittedUpdateState) { | 116 TEST_F(RenderViewImplTest, LastCommittedUpdateState) { |
100 // Load page A. | 117 // Load page A. |
101 LoadHTML("<div>Page A</div>"); | 118 LoadHTML("<div>Page A</div>"); |
102 | 119 |
103 // Load page B, which will trigger an UpdateState message for page A. | 120 // Load page B, which will trigger an UpdateState message for page A. |
104 LoadHTML("<div>Page B</div>"); | 121 LoadHTML("<div>Page B</div>"); |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 string16 type; | 1160 string16 type; |
1144 string16 href; | 1161 string16 href; |
1145 string16 title; | 1162 string16 title; |
1146 string16 disposition; | 1163 string16 disposition; |
1147 IntentsHostMsg_RegisterIntentService::Read( | 1164 IntentsHostMsg_RegisterIntentService::Read( |
1148 msg, &action, &type, &href, &title, &disposition); | 1165 msg, &action, &type, &href, &title, &disposition); |
1149 EXPECT_EQ(ASCIIToUTF16("a"), action); | 1166 EXPECT_EQ(ASCIIToUTF16("a"), action); |
1150 EXPECT_EQ(ASCIIToUTF16("t"), type); | 1167 EXPECT_EQ(ASCIIToUTF16("t"), type); |
1151 EXPECT_EQ(ASCIIToUTF16("title"), title); | 1168 EXPECT_EQ(ASCIIToUTF16("title"), title); |
1152 } | 1169 } |
OLD | NEW |