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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); | 153 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); |
154 | 154 |
155 // Clean up after the new view so we don't leak it. | 155 // Clean up after the new view so we don't leak it. |
156 new_view->Close(); | 156 new_view->Close(); |
157 new_view->Release(); | 157 new_view->Release(); |
158 } | 158 } |
159 | 159 |
160 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is | 160 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is |
161 // already swapped out. http://crbug.com/93427. | 161 // already swapped out. http://crbug.com/93427. |
162 TEST_F(RenderViewImplTest, SendSwapOutACK) { | 162 TEST_F(RenderViewImplTest, SendSwapOutACK) { |
| 163 LoadHTML("<div>Page A</div>"); |
163 int initial_page_id = view()->GetPageId(); | 164 int initial_page_id = view()->GetPageId(); |
164 | 165 |
165 // Respond to a swap out request. | 166 // Respond to a swap out request. |
166 ViewMsg_SwapOut_Params params; | 167 ViewMsg_SwapOut_Params params; |
167 params.closing_process_id = 10; | 168 params.closing_process_id = 10; |
168 params.closing_route_id = 11; | 169 params.closing_route_id = 11; |
169 params.new_render_process_host_id = 12; | 170 params.new_render_process_host_id = 12; |
170 params.new_request_id = 13; | 171 params.new_request_id = 13; |
171 view()->OnSwapOut(params); | 172 view()->OnSwapOut(params); |
172 | 173 |
(...skipping 12 matching lines...) Expand all Loading... |
185 reply_params.a.new_render_process_host_id); | 186 reply_params.a.new_render_process_host_id); |
186 EXPECT_EQ(params.new_request_id, reply_params.a.new_request_id); | 187 EXPECT_EQ(params.new_request_id, reply_params.a.new_request_id); |
187 | 188 |
188 // It is possible to get another swap out request. Ensure that we send | 189 // It is possible to get another swap out request. Ensure that we send |
189 // an ACK, even if we don't have to do anything else. | 190 // an ACK, even if we don't have to do anything else. |
190 render_thread_->sink().ClearMessages(); | 191 render_thread_->sink().ClearMessages(); |
191 view()->OnSwapOut(params); | 192 view()->OnSwapOut(params); |
192 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 193 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
193 ViewHostMsg_SwapOut_ACK::ID); | 194 ViewHostMsg_SwapOut_ACK::ID); |
194 ASSERT_TRUE(msg2); | 195 ASSERT_TRUE(msg2); |
| 196 |
| 197 // If we navigate back to this RenderView, ensure we don't send a state |
| 198 // update for the swapped out URL. (http://crbug.com/72235) |
| 199 ViewMsg_Navigate_Params nav_params; |
| 200 nav_params.url = GURL("data:text/html,<div>Page B</div>"); |
| 201 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
| 202 nav_params.transition = content::PAGE_TRANSITION_TYPED; |
| 203 nav_params.current_history_list_length = 1; |
| 204 nav_params.current_history_list_offset = 0; |
| 205 nav_params.pending_history_list_offset = 1; |
| 206 nav_params.page_id = -1; |
| 207 view()->OnNavigate(nav_params); |
| 208 ProcessPendingMessages(); |
| 209 const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( |
| 210 ViewHostMsg_UpdateState::ID); |
| 211 EXPECT_FALSE(msg3); |
195 } | 212 } |
196 | 213 |
197 // Test that we get the correct UpdateState message when we go back twice | 214 // Test that we get the correct UpdateState message when we go back twice |
198 // quickly without committing. Regression test for http://crbug.com/58082. | 215 // quickly without committing. Regression test for http://crbug.com/58082. |
199 TEST_F(RenderViewImplTest, LastCommittedUpdateState) { | 216 TEST_F(RenderViewImplTest, LastCommittedUpdateState) { |
200 // Load page A. | 217 // Load page A. |
201 LoadHTML("<div>Page A</div>"); | 218 LoadHTML("<div>Page A</div>"); |
202 | 219 |
203 // Load page B, which will trigger an UpdateState message for page A. | 220 // Load page B, which will trigger an UpdateState message for page A. |
204 LoadHTML("<div>Page B</div>"); | 221 LoadHTML("<div>Page B</div>"); |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 | 1283 |
1267 SendWebMouseEvent(mouse_event); | 1284 SendWebMouseEvent(mouse_event); |
1268 | 1285 |
1269 // Now simulate the corresponding up event which should display the menu | 1286 // Now simulate the corresponding up event which should display the menu |
1270 mouse_event.type = WebInputEvent::MouseUp; | 1287 mouse_event.type = WebInputEvent::MouseUp; |
1271 SendWebMouseEvent(mouse_event); | 1288 SendWebMouseEvent(mouse_event); |
1272 | 1289 |
1273 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 1290 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
1274 ViewHostMsg_ContextMenu::ID)); | 1291 ViewHostMsg_ContextMenu::ID)); |
1275 } | 1292 } |
OLD | NEW |