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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 // These are only used for commented out tests. If someone wants to enable | 11 // These are only used for commented out tests. If someone wants to enable |
12 // them, they should be moved to chrome first. | 12 // them, they should be moved to chrome first. |
13 // #include "chrome/browser/history/history.h" | 13 // #include "chrome/browser/history/history.h" |
14 // #include "chrome/browser/profiles/profile_manager.h" | 14 // #include "chrome/browser/profiles/profile_manager.h" |
15 // #include "chrome/browser/sessions/session_service.h" | 15 // #include "chrome/browser/sessions/session_service.h" |
16 // #include "chrome/browser/sessions/session_service_factory.h" | 16 // #include "chrome/browser/sessions/session_service_factory.h" |
17 // #include "chrome/browser/sessions/session_service_test_helper.h" | 17 // #include "chrome/browser/sessions/session_service_test_helper.h" |
18 // #include "chrome/browser/sessions/session_types.h" | 18 // #include "chrome/browser/sessions/session_types.h" |
| 19 #include "content/browser/renderer_host/mock_render_process_host.h" |
19 #include "content/browser/renderer_host/test_render_view_host.h" | 20 #include "content/browser/renderer_host/test_render_view_host.h" |
20 #include "content/browser/site_instance_impl.h" | 21 #include "content/browser/site_instance_impl.h" |
21 #include "content/browser/tab_contents/navigation_controller_impl.h" | 22 #include "content/browser/tab_contents/navigation_controller_impl.h" |
22 #include "content/browser/tab_contents/navigation_entry_impl.h" | 23 #include "content/browser/tab_contents/navigation_entry_impl.h" |
23 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
24 #include "content/browser/tab_contents/test_tab_contents.h" | 25 #include "content/browser/tab_contents/test_tab_contents.h" |
25 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
26 #include "content/public/browser/navigation_details.h" | 27 #include "content/public/browser/navigation_details.h" |
27 #include "content/public/browser/notification_registrar.h" | 28 #include "content/public/browser/notification_registrar.h" |
28 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
29 #include "content/public/browser/web_contents_delegate.h" | 30 #include "content/public/browser/web_contents_delegate.h" |
30 #include "content/test/test_browser_context.h" | 31 #include "content/test/test_browser_context.h" |
31 #include "content/test/test_notification_tracker.h" | 32 #include "content/test/test_notification_tracker.h" |
32 #include "net/base/net_util.h" | 33 #include "net/base/net_util.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "webkit/glue/webkit_glue.h" | 35 #include "webkit/glue/webkit_glue.h" |
35 | 36 |
36 using base::Time; | 37 using base::Time; |
37 using content::NavigationController; | 38 using content::NavigationController; |
38 using content::NavigationEntry; | 39 using content::NavigationEntry; |
39 using content::NavigationEntryImpl; | 40 using content::NavigationEntryImpl; |
| 41 using content::RenderViewHostImplTestHarness; |
40 using content::SiteInstance; | 42 using content::SiteInstance; |
41 using content::TestRenderViewHost; | 43 using content::TestRenderViewHost; |
42 using content::WebContents; | 44 using content::WebContents; |
43 | 45 |
44 // NavigationControllerTest ---------------------------------------------------- | 46 // NavigationControllerTest ---------------------------------------------------- |
45 | 47 |
46 class NavigationControllerTest : public RenderViewHostTestHarness { | 48 class NavigationControllerTest : public RenderViewHostImplTestHarness { |
47 public: | 49 public: |
48 NavigationControllerTest() {} | 50 NavigationControllerTest() {} |
49 | 51 |
50 NavigationControllerImpl& controller_impl() { | 52 NavigationControllerImpl& controller_impl() { |
51 return static_cast<NavigationControllerImpl&>(controller()); | 53 return static_cast<NavigationControllerImpl&>(controller()); |
52 } | 54 } |
53 }; | 55 }; |
54 | 56 |
55 void RegisterForAllNavNotifications(TestNotificationTracker* tracker, | 57 void RegisterForAllNavNotifications(TestNotificationTracker* tracker, |
56 NavigationController* controller) { | 58 NavigationController* controller) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 125 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
124 EXPECT_FALSE(controller.GetLastCommittedEntry()); | 126 EXPECT_FALSE(controller.GetLastCommittedEntry()); |
125 EXPECT_TRUE(controller.GetPendingEntry()); | 127 EXPECT_TRUE(controller.GetPendingEntry()); |
126 EXPECT_FALSE(controller.CanGoBack()); | 128 EXPECT_FALSE(controller.CanGoBack()); |
127 EXPECT_FALSE(controller.CanGoForward()); | 129 EXPECT_FALSE(controller.CanGoForward()); |
128 EXPECT_EQ(contents()->GetMaxPageID(), -1); | 130 EXPECT_EQ(contents()->GetMaxPageID(), -1); |
129 | 131 |
130 // We should have gotten no notifications from the preceeding checks. | 132 // We should have gotten no notifications from the preceeding checks. |
131 EXPECT_EQ(0U, notifications.size()); | 133 EXPECT_EQ(0U, notifications.size()); |
132 | 134 |
133 rvh()->SendNavigate(0, url1); | 135 test_rvh()->SendNavigate(0, url1); |
134 EXPECT_TRUE(notifications.Check1AndReset( | 136 EXPECT_TRUE(notifications.Check1AndReset( |
135 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 137 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
136 | 138 |
137 // The load should now be committed. | 139 // The load should now be committed. |
138 EXPECT_EQ(controller.GetEntryCount(), 1); | 140 EXPECT_EQ(controller.GetEntryCount(), 1); |
139 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 141 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
140 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 142 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
141 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 143 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
142 EXPECT_FALSE(controller.GetPendingEntry()); | 144 EXPECT_FALSE(controller.GetPendingEntry()); |
143 EXPECT_FALSE(controller.CanGoBack()); | 145 EXPECT_FALSE(controller.CanGoBack()); |
(...skipping 10 matching lines...) Expand all Loading... |
154 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 156 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
155 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 157 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
156 EXPECT_TRUE(controller.GetPendingEntry()); | 158 EXPECT_TRUE(controller.GetPendingEntry()); |
157 // TODO(darin): maybe this should really be true? | 159 // TODO(darin): maybe this should really be true? |
158 EXPECT_FALSE(controller.CanGoBack()); | 160 EXPECT_FALSE(controller.CanGoBack()); |
159 EXPECT_FALSE(controller.CanGoForward()); | 161 EXPECT_FALSE(controller.CanGoForward()); |
160 EXPECT_EQ(contents()->GetMaxPageID(), 0); | 162 EXPECT_EQ(contents()->GetMaxPageID(), 0); |
161 | 163 |
162 // Simulate the beforeunload ack for the cross-site transition, and then the | 164 // Simulate the beforeunload ack for the cross-site transition, and then the |
163 // commit. | 165 // commit. |
164 rvh()->SendShouldCloseACK(true); | 166 test_rvh()->SendShouldCloseACK(true); |
165 contents()->pending_rvh()->SendNavigate(1, url2); | 167 static_cast<TestRenderViewHost*>( |
| 168 contents()->pending_rvh())->SendNavigate(1, url2); |
166 EXPECT_TRUE(notifications.Check1AndReset( | 169 EXPECT_TRUE(notifications.Check1AndReset( |
167 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 170 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
168 | 171 |
169 // The load should now be committed. | 172 // The load should now be committed. |
170 EXPECT_EQ(controller.GetEntryCount(), 2); | 173 EXPECT_EQ(controller.GetEntryCount(), 2); |
171 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 174 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
172 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 175 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
173 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 176 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
174 EXPECT_FALSE(controller.GetPendingEntry()); | 177 EXPECT_FALSE(controller.GetPendingEntry()); |
175 EXPECT_TRUE(controller.CanGoBack()); | 178 EXPECT_TRUE(controller.CanGoBack()); |
176 EXPECT_FALSE(controller.CanGoForward()); | 179 EXPECT_FALSE(controller.CanGoForward()); |
177 EXPECT_EQ(contents()->GetMaxPageID(), 1); | 180 EXPECT_EQ(contents()->GetMaxPageID(), 1); |
178 } | 181 } |
179 | 182 |
180 // Tests what happens when the same page is loaded again. Should not create a | 183 // Tests what happens when the same page is loaded again. Should not create a |
181 // new session history entry. This is what happens when you press enter in the | 184 // new session history entry. This is what happens when you press enter in the |
182 // URL bar to reload: a pending entry is created and then it is discarded when | 185 // URL bar to reload: a pending entry is created and then it is discarded when |
183 // the load commits (because WebCore didn't actually make a new entry). | 186 // the load commits (because WebCore didn't actually make a new entry). |
184 TEST_F(NavigationControllerTest, LoadURL_SamePage) { | 187 TEST_F(NavigationControllerTest, LoadURL_SamePage) { |
185 NavigationControllerImpl& controller = controller_impl(); | 188 NavigationControllerImpl& controller = controller_impl(); |
186 TestNotificationTracker notifications; | 189 TestNotificationTracker notifications; |
187 RegisterForAllNavNotifications(¬ifications, &controller); | 190 RegisterForAllNavNotifications(¬ifications, &controller); |
188 | 191 |
189 const GURL url1("http://foo1"); | 192 const GURL url1("http://foo1"); |
190 | 193 |
191 controller.LoadURL( | 194 controller.LoadURL( |
192 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 195 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
193 EXPECT_EQ(0U, notifications.size()); | 196 EXPECT_EQ(0U, notifications.size()); |
194 rvh()->SendNavigate(0, url1); | 197 test_rvh()->SendNavigate(0, url1); |
195 EXPECT_TRUE(notifications.Check1AndReset( | 198 EXPECT_TRUE(notifications.Check1AndReset( |
196 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 199 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
197 | 200 |
198 controller.LoadURL( | 201 controller.LoadURL( |
199 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 202 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
200 EXPECT_EQ(0U, notifications.size()); | 203 EXPECT_EQ(0U, notifications.size()); |
201 rvh()->SendNavigate(0, url1); | 204 test_rvh()->SendNavigate(0, url1); |
202 EXPECT_TRUE(notifications.Check1AndReset( | 205 EXPECT_TRUE(notifications.Check1AndReset( |
203 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 206 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
204 | 207 |
205 // We should not have produced a new session history entry. | 208 // We should not have produced a new session history entry. |
206 EXPECT_EQ(controller.GetEntryCount(), 1); | 209 EXPECT_EQ(controller.GetEntryCount(), 1); |
207 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 210 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
208 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 211 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
209 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 212 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
210 EXPECT_FALSE(controller.GetPendingEntry()); | 213 EXPECT_FALSE(controller.GetPendingEntry()); |
211 EXPECT_FALSE(controller.CanGoBack()); | 214 EXPECT_FALSE(controller.CanGoBack()); |
212 EXPECT_FALSE(controller.CanGoForward()); | 215 EXPECT_FALSE(controller.CanGoForward()); |
213 } | 216 } |
214 | 217 |
215 // Tests loading a URL but discarding it before the load commits. | 218 // Tests loading a URL but discarding it before the load commits. |
216 TEST_F(NavigationControllerTest, LoadURL_Discarded) { | 219 TEST_F(NavigationControllerTest, LoadURL_Discarded) { |
217 NavigationControllerImpl& controller = controller_impl(); | 220 NavigationControllerImpl& controller = controller_impl(); |
218 TestNotificationTracker notifications; | 221 TestNotificationTracker notifications; |
219 RegisterForAllNavNotifications(¬ifications, &controller); | 222 RegisterForAllNavNotifications(¬ifications, &controller); |
220 | 223 |
221 const GURL url1("http://foo1"); | 224 const GURL url1("http://foo1"); |
222 const GURL url2("http://foo2"); | 225 const GURL url2("http://foo2"); |
223 | 226 |
224 controller.LoadURL( | 227 controller.LoadURL( |
225 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 228 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
226 EXPECT_EQ(0U, notifications.size()); | 229 EXPECT_EQ(0U, notifications.size()); |
227 rvh()->SendNavigate(0, url1); | 230 test_rvh()->SendNavigate(0, url1); |
228 EXPECT_TRUE(notifications.Check1AndReset( | 231 EXPECT_TRUE(notifications.Check1AndReset( |
229 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 232 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
230 | 233 |
231 controller.LoadURL( | 234 controller.LoadURL( |
232 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 235 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
233 controller.DiscardNonCommittedEntries(); | 236 controller.DiscardNonCommittedEntries(); |
234 EXPECT_EQ(0U, notifications.size()); | 237 EXPECT_EQ(0U, notifications.size()); |
235 | 238 |
236 // Should not have produced a new session history entry. | 239 // Should not have produced a new session history entry. |
237 EXPECT_EQ(controller.GetEntryCount(), 1); | 240 EXPECT_EQ(controller.GetEntryCount(), 1); |
238 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 241 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
239 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 242 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
240 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 243 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
241 EXPECT_FALSE(controller.GetPendingEntry()); | 244 EXPECT_FALSE(controller.GetPendingEntry()); |
242 EXPECT_FALSE(controller.CanGoBack()); | 245 EXPECT_FALSE(controller.CanGoBack()); |
243 EXPECT_FALSE(controller.CanGoForward()); | 246 EXPECT_FALSE(controller.CanGoForward()); |
244 } | 247 } |
245 | 248 |
246 // Tests navigations that come in unrequested. This happens when the user | 249 // Tests navigations that come in unrequested. This happens when the user |
247 // navigates from the web page, and here we test that there is no pending entry. | 250 // navigates from the web page, and here we test that there is no pending entry. |
248 TEST_F(NavigationControllerTest, LoadURL_NoPending) { | 251 TEST_F(NavigationControllerTest, LoadURL_NoPending) { |
249 NavigationControllerImpl& controller = controller_impl(); | 252 NavigationControllerImpl& controller = controller_impl(); |
250 TestNotificationTracker notifications; | 253 TestNotificationTracker notifications; |
251 RegisterForAllNavNotifications(¬ifications, &controller); | 254 RegisterForAllNavNotifications(¬ifications, &controller); |
252 | 255 |
253 // First make an existing committed entry. | 256 // First make an existing committed entry. |
254 const GURL kExistingURL1("http://eh"); | 257 const GURL kExistingURL1("http://eh"); |
255 controller.LoadURL(kExistingURL1, content::Referrer(), | 258 controller.LoadURL(kExistingURL1, content::Referrer(), |
256 content::PAGE_TRANSITION_TYPED, std::string()); | 259 content::PAGE_TRANSITION_TYPED, std::string()); |
257 rvh()->SendNavigate(0, kExistingURL1); | 260 test_rvh()->SendNavigate(0, kExistingURL1); |
258 EXPECT_TRUE(notifications.Check1AndReset( | 261 EXPECT_TRUE(notifications.Check1AndReset( |
259 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 262 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
260 | 263 |
261 // Do a new navigation without making a pending one. | 264 // Do a new navigation without making a pending one. |
262 const GURL kNewURL("http://see"); | 265 const GURL kNewURL("http://see"); |
263 rvh()->SendNavigate(99, kNewURL); | 266 test_rvh()->SendNavigate(99, kNewURL); |
264 | 267 |
265 // There should no longer be any pending entry, and the third navigation we | 268 // There should no longer be any pending entry, and the third navigation we |
266 // just made should be committed. | 269 // just made should be committed. |
267 EXPECT_TRUE(notifications.Check1AndReset( | 270 EXPECT_TRUE(notifications.Check1AndReset( |
268 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 271 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
269 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 272 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
270 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 273 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
271 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); | 274 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); |
272 } | 275 } |
273 | 276 |
274 // Tests navigating to a new URL when there is a new pending navigation that is | 277 // Tests navigating to a new URL when there is a new pending navigation that is |
275 // not the one that just loaded. This will happen if the user types in a URL to | 278 // not the one that just loaded. This will happen if the user types in a URL to |
276 // somewhere slow, and then navigates the current page before the typed URL | 279 // somewhere slow, and then navigates the current page before the typed URL |
277 // commits. | 280 // commits. |
278 TEST_F(NavigationControllerTest, LoadURL_NewPending) { | 281 TEST_F(NavigationControllerTest, LoadURL_NewPending) { |
279 NavigationControllerImpl& controller = controller_impl(); | 282 NavigationControllerImpl& controller = controller_impl(); |
280 TestNotificationTracker notifications; | 283 TestNotificationTracker notifications; |
281 RegisterForAllNavNotifications(¬ifications, &controller); | 284 RegisterForAllNavNotifications(¬ifications, &controller); |
282 | 285 |
283 // First make an existing committed entry. | 286 // First make an existing committed entry. |
284 const GURL kExistingURL1("http://eh"); | 287 const GURL kExistingURL1("http://eh"); |
285 controller.LoadURL(kExistingURL1, content::Referrer(), | 288 controller.LoadURL(kExistingURL1, content::Referrer(), |
286 content::PAGE_TRANSITION_TYPED, std::string()); | 289 content::PAGE_TRANSITION_TYPED, std::string()); |
287 rvh()->SendNavigate(0, kExistingURL1); | 290 test_rvh()->SendNavigate(0, kExistingURL1); |
288 EXPECT_TRUE(notifications.Check1AndReset( | 291 EXPECT_TRUE(notifications.Check1AndReset( |
289 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 292 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
290 | 293 |
291 // Make a pending entry to somewhere new. | 294 // Make a pending entry to somewhere new. |
292 const GURL kExistingURL2("http://bee"); | 295 const GURL kExistingURL2("http://bee"); |
293 controller.LoadURL(kExistingURL2, content::Referrer(), | 296 controller.LoadURL(kExistingURL2, content::Referrer(), |
294 content::PAGE_TRANSITION_TYPED, std::string()); | 297 content::PAGE_TRANSITION_TYPED, std::string()); |
295 EXPECT_EQ(0U, notifications.size()); | 298 EXPECT_EQ(0U, notifications.size()); |
296 | 299 |
297 // After the beforeunload but before it commits, do a new navigation. | 300 // After the beforeunload but before it commits, do a new navigation. |
298 rvh()->SendShouldCloseACK(true); | 301 test_rvh()->SendShouldCloseACK(true); |
299 const GURL kNewURL("http://see"); | 302 const GURL kNewURL("http://see"); |
300 contents()->pending_rvh()->SendNavigate(3, kNewURL); | 303 static_cast<TestRenderViewHost*>( |
| 304 contents()->pending_rvh())->SendNavigate(3, kNewURL); |
301 | 305 |
302 // There should no longer be any pending entry, and the third navigation we | 306 // There should no longer be any pending entry, and the third navigation we |
303 // just made should be committed. | 307 // just made should be committed. |
304 EXPECT_TRUE(notifications.Check1AndReset( | 308 EXPECT_TRUE(notifications.Check1AndReset( |
305 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 309 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
306 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 310 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
307 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 311 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
308 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); | 312 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); |
309 } | 313 } |
310 | 314 |
311 // Tests navigating to a new URL when there is a pending back/forward | 315 // Tests navigating to a new URL when there is a pending back/forward |
312 // navigation. This will happen if the user hits back, but before that commits, | 316 // navigation. This will happen if the user hits back, but before that commits, |
313 // they navigate somewhere new. | 317 // they navigate somewhere new. |
314 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { | 318 TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
315 NavigationControllerImpl& controller = controller_impl(); | 319 NavigationControllerImpl& controller = controller_impl(); |
316 TestNotificationTracker notifications; | 320 TestNotificationTracker notifications; |
317 RegisterForAllNavNotifications(¬ifications, &controller); | 321 RegisterForAllNavNotifications(¬ifications, &controller); |
318 | 322 |
319 // First make some history. | 323 // First make some history. |
320 const GURL kExistingURL1("http://foo/eh"); | 324 const GURL kExistingURL1("http://foo/eh"); |
321 controller.LoadURL(kExistingURL1, content::Referrer(), | 325 controller.LoadURL(kExistingURL1, content::Referrer(), |
322 content::PAGE_TRANSITION_TYPED, std::string()); | 326 content::PAGE_TRANSITION_TYPED, std::string()); |
323 rvh()->SendNavigate(0, kExistingURL1); | 327 test_rvh()->SendNavigate(0, kExistingURL1); |
324 EXPECT_TRUE(notifications.Check1AndReset( | 328 EXPECT_TRUE(notifications.Check1AndReset( |
325 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 329 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
326 | 330 |
327 const GURL kExistingURL2("http://foo/bee"); | 331 const GURL kExistingURL2("http://foo/bee"); |
328 controller.LoadURL(kExistingURL2, content::Referrer(), | 332 controller.LoadURL(kExistingURL2, content::Referrer(), |
329 content::PAGE_TRANSITION_TYPED, std::string()); | 333 content::PAGE_TRANSITION_TYPED, std::string()); |
330 rvh()->SendNavigate(1, kExistingURL2); | 334 test_rvh()->SendNavigate(1, kExistingURL2); |
331 EXPECT_TRUE(notifications.Check1AndReset( | 335 EXPECT_TRUE(notifications.Check1AndReset( |
332 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 336 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
333 | 337 |
334 // Now make a pending back/forward navigation. The zeroth entry should be | 338 // Now make a pending back/forward navigation. The zeroth entry should be |
335 // pending. | 339 // pending. |
336 controller.GoBack(); | 340 controller.GoBack(); |
337 EXPECT_EQ(0U, notifications.size()); | 341 EXPECT_EQ(0U, notifications.size()); |
338 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 342 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
339 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 343 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
340 | 344 |
341 // Before that commits, do a new navigation. | 345 // Before that commits, do a new navigation. |
342 const GURL kNewURL("http://foo/see"); | 346 const GURL kNewURL("http://foo/see"); |
343 content::LoadCommittedDetails details; | 347 content::LoadCommittedDetails details; |
344 rvh()->SendNavigate(3, kNewURL); | 348 test_rvh()->SendNavigate(3, kNewURL); |
345 | 349 |
346 // There should no longer be any pending entry, and the third navigation we | 350 // There should no longer be any pending entry, and the third navigation we |
347 // just made should be committed. | 351 // just made should be committed. |
348 EXPECT_TRUE(notifications.Check1AndReset( | 352 EXPECT_TRUE(notifications.Check1AndReset( |
349 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 353 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
350 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 354 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
351 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 355 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
352 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); | 356 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); |
353 } | 357 } |
354 | 358 |
355 // Tests navigating to an existing URL when there is a pending new navigation. | 359 // Tests navigating to an existing URL when there is a pending new navigation. |
356 // This will happen if the user enters a URL, but before that commits, the | 360 // This will happen if the user enters a URL, but before that commits, the |
357 // current page fires history.back(). | 361 // current page fires history.back(). |
358 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { | 362 TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
359 NavigationControllerImpl& controller = controller_impl(); | 363 NavigationControllerImpl& controller = controller_impl(); |
360 TestNotificationTracker notifications; | 364 TestNotificationTracker notifications; |
361 RegisterForAllNavNotifications(¬ifications, &controller); | 365 RegisterForAllNavNotifications(¬ifications, &controller); |
362 | 366 |
363 // First make some history. | 367 // First make some history. |
364 const GURL kExistingURL1("http://foo/eh"); | 368 const GURL kExistingURL1("http://foo/eh"); |
365 controller.LoadURL(kExistingURL1, content::Referrer(), | 369 controller.LoadURL(kExistingURL1, content::Referrer(), |
366 content::PAGE_TRANSITION_TYPED, std::string()); | 370 content::PAGE_TRANSITION_TYPED, std::string()); |
367 rvh()->SendNavigate(0, kExistingURL1); | 371 test_rvh()->SendNavigate(0, kExistingURL1); |
368 EXPECT_TRUE(notifications.Check1AndReset( | 372 EXPECT_TRUE(notifications.Check1AndReset( |
369 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 373 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
370 | 374 |
371 const GURL kExistingURL2("http://foo/bee"); | 375 const GURL kExistingURL2("http://foo/bee"); |
372 controller.LoadURL(kExistingURL2, content::Referrer(), | 376 controller.LoadURL(kExistingURL2, content::Referrer(), |
373 content::PAGE_TRANSITION_TYPED, std::string()); | 377 content::PAGE_TRANSITION_TYPED, std::string()); |
374 rvh()->SendNavigate(1, kExistingURL2); | 378 test_rvh()->SendNavigate(1, kExistingURL2); |
375 EXPECT_TRUE(notifications.Check1AndReset( | 379 EXPECT_TRUE(notifications.Check1AndReset( |
376 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 380 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
377 | 381 |
378 // Now make a pending new navigation. | 382 // Now make a pending new navigation. |
379 const GURL kNewURL("http://foo/see"); | 383 const GURL kNewURL("http://foo/see"); |
380 controller.LoadURL( | 384 controller.LoadURL( |
381 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 385 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
382 std::string()); | 386 std::string()); |
383 EXPECT_EQ(0U, notifications.size()); | 387 EXPECT_EQ(0U, notifications.size()); |
384 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 388 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
385 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 389 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
386 | 390 |
387 // Before that commits, a back navigation from the renderer commits. | 391 // Before that commits, a back navigation from the renderer commits. |
388 rvh()->SendNavigate(0, kExistingURL1); | 392 test_rvh()->SendNavigate(0, kExistingURL1); |
389 | 393 |
390 // There should no longer be any pending entry, and the back navigation we | 394 // There should no longer be any pending entry, and the back navigation we |
391 // just made should be committed. | 395 // just made should be committed. |
392 EXPECT_TRUE(notifications.Check1AndReset( | 396 EXPECT_TRUE(notifications.Check1AndReset( |
393 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 397 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
394 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 398 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
395 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 399 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
396 EXPECT_EQ(kExistingURL1, controller.GetActiveEntry()->GetURL()); | 400 EXPECT_EQ(kExistingURL1, controller.GetActiveEntry()->GetURL()); |
397 } | 401 } |
398 | 402 |
(...skipping 19 matching lines...) Expand all Loading... |
418 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 422 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
419 std::string()); | 423 std::string()); |
420 EXPECT_EQ(0U, notifications.size()); | 424 EXPECT_EQ(0U, notifications.size()); |
421 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 425 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
422 EXPECT_TRUE(controller.GetPendingEntry()); | 426 EXPECT_TRUE(controller.GetPendingEntry()); |
423 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 427 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
424 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 428 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
425 | 429 |
426 // Before that commits, a document.write and location.reload can cause the | 430 // Before that commits, a document.write and location.reload can cause the |
427 // renderer to send a FrameNavigate with page_id -1. | 431 // renderer to send a FrameNavigate with page_id -1. |
428 rvh()->SendNavigate(-1, kExistingURL); | 432 test_rvh()->SendNavigate(-1, kExistingURL); |
429 | 433 |
430 // This should clear the pending entry and notify of a navigation state | 434 // This should clear the pending entry and notify of a navigation state |
431 // change, so that we do not keep displaying kNewURL. | 435 // change, so that we do not keep displaying kNewURL. |
432 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 436 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
433 EXPECT_FALSE(controller.GetPendingEntry()); | 437 EXPECT_FALSE(controller.GetPendingEntry()); |
434 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 438 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
435 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 439 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
436 | 440 |
437 contents()->SetDelegate(NULL); | 441 contents()->SetDelegate(NULL); |
438 } | 442 } |
(...skipping 25 matching lines...) Expand all Loading... |
464 | 468 |
465 // It may abort before committing, if it's a download or due to a stop or | 469 // It may abort before committing, if it's a download or due to a stop or |
466 // a new navigation from the user. | 470 // a new navigation from the user. |
467 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 471 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
468 params.frame_id = 1; | 472 params.frame_id = 1; |
469 params.is_main_frame = true; | 473 params.is_main_frame = true; |
470 params.error_code = net::ERR_ABORTED; | 474 params.error_code = net::ERR_ABORTED; |
471 params.error_description = string16(); | 475 params.error_description = string16(); |
472 params.url = kNewURL; | 476 params.url = kNewURL; |
473 params.showing_repost_interstitial = false; | 477 params.showing_repost_interstitial = false; |
474 rvh()->TestOnMessageReceived( | 478 test_rvh()->TestOnMessageReceived( |
475 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 479 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
476 params)); | 480 params)); |
477 | 481 |
478 // This should clear the pending entry and notify of a navigation state | 482 // This should clear the pending entry and notify of a navigation state |
479 // change, so that we do not keep displaying kNewURL. | 483 // change, so that we do not keep displaying kNewURL. |
480 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 484 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
481 EXPECT_FALSE(controller.GetPendingEntry()); | 485 EXPECT_FALSE(controller.GetPendingEntry()); |
482 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 486 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
483 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 487 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
484 | 488 |
(...skipping 21 matching lines...) Expand all Loading... |
506 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 510 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
507 std::string()); | 511 std::string()); |
508 EXPECT_EQ(0U, notifications.size()); | 512 EXPECT_EQ(0U, notifications.size()); |
509 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 513 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
510 EXPECT_TRUE(controller.GetPendingEntry()); | 514 EXPECT_TRUE(controller.GetPendingEntry()); |
511 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 515 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
512 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 516 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
513 | 517 |
514 // Now the navigation redirects. | 518 // Now the navigation redirects. |
515 const GURL kRedirectURL("http://bee"); | 519 const GURL kRedirectURL("http://bee"); |
516 rvh()->TestOnMessageReceived( | 520 test_rvh()->TestOnMessageReceived( |
517 ViewHostMsg_DidRedirectProvisionalLoad(0, // routing_id | 521 ViewHostMsg_DidRedirectProvisionalLoad(0, // routing_id |
518 -1, // pending page_id | 522 -1, // pending page_id |
519 GURL(), // opener | 523 GURL(), // opener |
520 kNewURL, // old url | 524 kNewURL, // old url |
521 kRedirectURL)); // new url | 525 kRedirectURL)); // new url |
522 | 526 |
523 // We don't want to change the NavigationEntry's url, in case it cancels. | 527 // We don't want to change the NavigationEntry's url, in case it cancels. |
524 // Prevents regression of http://crbug.com/77786. | 528 // Prevents regression of http://crbug.com/77786. |
525 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); | 529 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); |
526 | 530 |
527 // It may abort before committing, if it's a download or due to a stop or | 531 // It may abort before committing, if it's a download or due to a stop or |
528 // a new navigation from the user. | 532 // a new navigation from the user. |
529 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 533 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
530 params.frame_id = 1; | 534 params.frame_id = 1; |
531 params.is_main_frame = true; | 535 params.is_main_frame = true; |
532 params.error_code = net::ERR_ABORTED; | 536 params.error_code = net::ERR_ABORTED; |
533 params.error_description = string16(); | 537 params.error_description = string16(); |
534 params.url = kRedirectURL; | 538 params.url = kRedirectURL; |
535 params.showing_repost_interstitial = false; | 539 params.showing_repost_interstitial = false; |
536 rvh()->TestOnMessageReceived( | 540 test_rvh()->TestOnMessageReceived( |
537 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 541 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
538 params)); | 542 params)); |
539 | 543 |
540 // This should clear the pending entry and notify of a navigation state | 544 // This should clear the pending entry and notify of a navigation state |
541 // change, so that we do not keep displaying kNewURL. | 545 // change, so that we do not keep displaying kNewURL. |
542 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 546 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
543 EXPECT_FALSE(controller.GetPendingEntry()); | 547 EXPECT_FALSE(controller.GetPendingEntry()); |
544 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 548 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
545 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 549 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
546 | 550 |
547 contents()->SetDelegate(NULL); | 551 contents()->SetDelegate(NULL); |
548 } | 552 } |
549 | 553 |
550 TEST_F(NavigationControllerTest, Reload) { | 554 TEST_F(NavigationControllerTest, Reload) { |
551 NavigationControllerImpl& controller = controller_impl(); | 555 NavigationControllerImpl& controller = controller_impl(); |
552 TestNotificationTracker notifications; | 556 TestNotificationTracker notifications; |
553 RegisterForAllNavNotifications(¬ifications, &controller); | 557 RegisterForAllNavNotifications(¬ifications, &controller); |
554 | 558 |
555 const GURL url1("http://foo1"); | 559 const GURL url1("http://foo1"); |
556 | 560 |
557 controller.LoadURL( | 561 controller.LoadURL( |
558 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 562 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
559 EXPECT_EQ(0U, notifications.size()); | 563 EXPECT_EQ(0U, notifications.size()); |
560 rvh()->SendNavigate(0, url1); | 564 test_rvh()->SendNavigate(0, url1); |
561 EXPECT_TRUE(notifications.Check1AndReset( | 565 EXPECT_TRUE(notifications.Check1AndReset( |
562 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 566 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
563 controller.GetActiveEntry()->SetTitle(ASCIIToUTF16("Title")); | 567 controller.GetActiveEntry()->SetTitle(ASCIIToUTF16("Title")); |
564 controller.Reload(true); | 568 controller.Reload(true); |
565 EXPECT_EQ(0U, notifications.size()); | 569 EXPECT_EQ(0U, notifications.size()); |
566 | 570 |
567 // The reload is pending. | 571 // The reload is pending. |
568 EXPECT_EQ(controller.GetEntryCount(), 1); | 572 EXPECT_EQ(controller.GetEntryCount(), 1); |
569 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 573 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
570 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); | 574 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); |
571 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 575 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
572 EXPECT_TRUE(controller.GetPendingEntry()); | 576 EXPECT_TRUE(controller.GetPendingEntry()); |
573 EXPECT_FALSE(controller.CanGoBack()); | 577 EXPECT_FALSE(controller.CanGoBack()); |
574 EXPECT_FALSE(controller.CanGoForward()); | 578 EXPECT_FALSE(controller.CanGoForward()); |
575 // Make sure the title has been cleared (will be redrawn just after reload). | 579 // Make sure the title has been cleared (will be redrawn just after reload). |
576 // Avoids a stale cached title when the new page being reloaded has no title. | 580 // Avoids a stale cached title when the new page being reloaded has no title. |
577 // See http://crbug.com/96041. | 581 // See http://crbug.com/96041. |
578 EXPECT_TRUE(controller.GetActiveEntry()->GetTitle().empty()); | 582 EXPECT_TRUE(controller.GetActiveEntry()->GetTitle().empty()); |
579 | 583 |
580 rvh()->SendNavigate(0, url1); | 584 test_rvh()->SendNavigate(0, url1); |
581 EXPECT_TRUE(notifications.Check1AndReset( | 585 EXPECT_TRUE(notifications.Check1AndReset( |
582 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 586 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
583 | 587 |
584 // Now the reload is committed. | 588 // Now the reload is committed. |
585 EXPECT_EQ(controller.GetEntryCount(), 1); | 589 EXPECT_EQ(controller.GetEntryCount(), 1); |
586 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 590 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
587 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 591 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
588 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 592 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
589 EXPECT_FALSE(controller.GetPendingEntry()); | 593 EXPECT_FALSE(controller.GetPendingEntry()); |
590 EXPECT_FALSE(controller.CanGoBack()); | 594 EXPECT_FALSE(controller.CanGoBack()); |
591 EXPECT_FALSE(controller.CanGoForward()); | 595 EXPECT_FALSE(controller.CanGoForward()); |
592 } | 596 } |
593 | 597 |
594 // Tests what happens when a reload navigation produces a new page. | 598 // Tests what happens when a reload navigation produces a new page. |
595 TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { | 599 TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { |
596 NavigationControllerImpl& controller = controller_impl(); | 600 NavigationControllerImpl& controller = controller_impl(); |
597 TestNotificationTracker notifications; | 601 TestNotificationTracker notifications; |
598 RegisterForAllNavNotifications(¬ifications, &controller); | 602 RegisterForAllNavNotifications(¬ifications, &controller); |
599 | 603 |
600 const GURL url1("http://foo1"); | 604 const GURL url1("http://foo1"); |
601 const GURL url2("http://foo2"); | 605 const GURL url2("http://foo2"); |
602 | 606 |
603 controller.LoadURL( | 607 controller.LoadURL( |
604 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 608 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
605 rvh()->SendNavigate(0, url1); | 609 test_rvh()->SendNavigate(0, url1); |
606 EXPECT_TRUE(notifications.Check1AndReset( | 610 EXPECT_TRUE(notifications.Check1AndReset( |
607 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 611 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
608 | 612 |
609 controller.Reload(true); | 613 controller.Reload(true); |
610 EXPECT_EQ(0U, notifications.size()); | 614 EXPECT_EQ(0U, notifications.size()); |
611 | 615 |
612 rvh()->SendNavigate(1, url2); | 616 test_rvh()->SendNavigate(1, url2); |
613 EXPECT_TRUE(notifications.Check1AndReset( | 617 EXPECT_TRUE(notifications.Check1AndReset( |
614 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 618 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
615 | 619 |
616 // Now the reload is committed. | 620 // Now the reload is committed. |
617 EXPECT_EQ(controller.GetEntryCount(), 2); | 621 EXPECT_EQ(controller.GetEntryCount(), 2); |
618 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 622 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
619 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 623 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
620 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 624 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
621 EXPECT_FALSE(controller.GetPendingEntry()); | 625 EXPECT_FALSE(controller.GetPendingEntry()); |
622 EXPECT_TRUE(controller.CanGoBack()); | 626 EXPECT_TRUE(controller.CanGoBack()); |
623 EXPECT_FALSE(controller.CanGoForward()); | 627 EXPECT_FALSE(controller.CanGoForward()); |
624 } | 628 } |
625 | 629 |
626 // Tests what happens when we navigate back successfully | 630 // Tests what happens when we navigate back successfully |
627 TEST_F(NavigationControllerTest, Back) { | 631 TEST_F(NavigationControllerTest, Back) { |
628 NavigationControllerImpl& controller = controller_impl(); | 632 NavigationControllerImpl& controller = controller_impl(); |
629 TestNotificationTracker notifications; | 633 TestNotificationTracker notifications; |
630 RegisterForAllNavNotifications(¬ifications, &controller); | 634 RegisterForAllNavNotifications(¬ifications, &controller); |
631 | 635 |
632 const GURL url1("http://foo1"); | 636 const GURL url1("http://foo1"); |
633 rvh()->SendNavigate(0, url1); | 637 test_rvh()->SendNavigate(0, url1); |
634 EXPECT_TRUE(notifications.Check1AndReset( | 638 EXPECT_TRUE(notifications.Check1AndReset( |
635 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 639 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
636 | 640 |
637 const GURL url2("http://foo2"); | 641 const GURL url2("http://foo2"); |
638 rvh()->SendNavigate(1, url2); | 642 test_rvh()->SendNavigate(1, url2); |
639 EXPECT_TRUE(notifications.Check1AndReset( | 643 EXPECT_TRUE(notifications.Check1AndReset( |
640 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 644 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
641 | 645 |
642 controller.GoBack(); | 646 controller.GoBack(); |
643 EXPECT_EQ(0U, notifications.size()); | 647 EXPECT_EQ(0U, notifications.size()); |
644 | 648 |
645 // We should now have a pending navigation to go back. | 649 // We should now have a pending navigation to go back. |
646 EXPECT_EQ(controller.GetEntryCount(), 2); | 650 EXPECT_EQ(controller.GetEntryCount(), 2); |
647 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 651 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
648 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); | 652 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); |
649 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 653 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
650 EXPECT_TRUE(controller.GetPendingEntry()); | 654 EXPECT_TRUE(controller.GetPendingEntry()); |
651 EXPECT_FALSE(controller.CanGoBack()); | 655 EXPECT_FALSE(controller.CanGoBack()); |
652 EXPECT_TRUE(controller.CanGoForward()); | 656 EXPECT_TRUE(controller.CanGoForward()); |
653 | 657 |
654 rvh()->SendNavigate(0, url2); | 658 test_rvh()->SendNavigate(0, url2); |
655 EXPECT_TRUE(notifications.Check1AndReset( | 659 EXPECT_TRUE(notifications.Check1AndReset( |
656 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 660 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
657 | 661 |
658 // The back navigation completed successfully. | 662 // The back navigation completed successfully. |
659 EXPECT_EQ(controller.GetEntryCount(), 2); | 663 EXPECT_EQ(controller.GetEntryCount(), 2); |
660 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 664 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
661 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 665 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
662 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 666 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
663 EXPECT_FALSE(controller.GetPendingEntry()); | 667 EXPECT_FALSE(controller.GetPendingEntry()); |
664 EXPECT_FALSE(controller.CanGoBack()); | 668 EXPECT_FALSE(controller.CanGoBack()); |
665 EXPECT_TRUE(controller.CanGoForward()); | 669 EXPECT_TRUE(controller.CanGoForward()); |
666 } | 670 } |
667 | 671 |
668 // Tests what happens when a back navigation produces a new page. | 672 // Tests what happens when a back navigation produces a new page. |
669 TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { | 673 TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { |
670 NavigationControllerImpl& controller = controller_impl(); | 674 NavigationControllerImpl& controller = controller_impl(); |
671 TestNotificationTracker notifications; | 675 TestNotificationTracker notifications; |
672 RegisterForAllNavNotifications(¬ifications, &controller); | 676 RegisterForAllNavNotifications(¬ifications, &controller); |
673 | 677 |
674 const GURL url1("http://foo/1"); | 678 const GURL url1("http://foo/1"); |
675 const GURL url2("http://foo/2"); | 679 const GURL url2("http://foo/2"); |
676 const GURL url3("http://foo/3"); | 680 const GURL url3("http://foo/3"); |
677 | 681 |
678 controller.LoadURL( | 682 controller.LoadURL( |
679 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 683 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
680 rvh()->SendNavigate(0, url1); | 684 test_rvh()->SendNavigate(0, url1); |
681 EXPECT_TRUE(notifications.Check1AndReset( | 685 EXPECT_TRUE(notifications.Check1AndReset( |
682 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 686 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
683 | 687 |
684 controller.LoadURL( | 688 controller.LoadURL( |
685 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 689 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
686 rvh()->SendNavigate(1, url2); | 690 test_rvh()->SendNavigate(1, url2); |
687 EXPECT_TRUE(notifications.Check1AndReset( | 691 EXPECT_TRUE(notifications.Check1AndReset( |
688 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 692 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
689 | 693 |
690 controller.GoBack(); | 694 controller.GoBack(); |
691 EXPECT_EQ(0U, notifications.size()); | 695 EXPECT_EQ(0U, notifications.size()); |
692 | 696 |
693 // We should now have a pending navigation to go back. | 697 // We should now have a pending navigation to go back. |
694 EXPECT_EQ(controller.GetEntryCount(), 2); | 698 EXPECT_EQ(controller.GetEntryCount(), 2); |
695 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 699 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
696 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); | 700 EXPECT_EQ(controller.GetPendingEntryIndex(), 0); |
697 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 701 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
698 EXPECT_TRUE(controller.GetPendingEntry()); | 702 EXPECT_TRUE(controller.GetPendingEntry()); |
699 EXPECT_FALSE(controller.CanGoBack()); | 703 EXPECT_FALSE(controller.CanGoBack()); |
700 EXPECT_TRUE(controller.CanGoForward()); | 704 EXPECT_TRUE(controller.CanGoForward()); |
701 | 705 |
702 rvh()->SendNavigate(2, url3); | 706 test_rvh()->SendNavigate(2, url3); |
703 EXPECT_TRUE(notifications.Check1AndReset( | 707 EXPECT_TRUE(notifications.Check1AndReset( |
704 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 708 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
705 | 709 |
706 // The back navigation resulted in a completely new navigation. | 710 // The back navigation resulted in a completely new navigation. |
707 // TODO(darin): perhaps this behavior will be confusing to users? | 711 // TODO(darin): perhaps this behavior will be confusing to users? |
708 EXPECT_EQ(controller.GetEntryCount(), 3); | 712 EXPECT_EQ(controller.GetEntryCount(), 3); |
709 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 2); | 713 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 2); |
710 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 714 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
711 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 715 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
712 EXPECT_FALSE(controller.GetPendingEntry()); | 716 EXPECT_FALSE(controller.GetPendingEntry()); |
713 EXPECT_TRUE(controller.CanGoBack()); | 717 EXPECT_TRUE(controller.CanGoBack()); |
714 EXPECT_FALSE(controller.CanGoForward()); | 718 EXPECT_FALSE(controller.CanGoForward()); |
715 } | 719 } |
716 | 720 |
717 // Receives a back message when there is a new pending navigation entry. | 721 // Receives a back message when there is a new pending navigation entry. |
718 TEST_F(NavigationControllerTest, Back_NewPending) { | 722 TEST_F(NavigationControllerTest, Back_NewPending) { |
719 NavigationControllerImpl& controller = controller_impl(); | 723 NavigationControllerImpl& controller = controller_impl(); |
720 TestNotificationTracker notifications; | 724 TestNotificationTracker notifications; |
721 RegisterForAllNavNotifications(¬ifications, &controller); | 725 RegisterForAllNavNotifications(¬ifications, &controller); |
722 | 726 |
723 const GURL kUrl1("http://foo1"); | 727 const GURL kUrl1("http://foo1"); |
724 const GURL kUrl2("http://foo2"); | 728 const GURL kUrl2("http://foo2"); |
725 const GURL kUrl3("http://foo3"); | 729 const GURL kUrl3("http://foo3"); |
726 | 730 |
727 // First navigate two places so we have some back history. | 731 // First navigate two places so we have some back history. |
728 rvh()->SendNavigate(0, kUrl1); | 732 test_rvh()->SendNavigate(0, kUrl1); |
729 EXPECT_TRUE(notifications.Check1AndReset( | 733 EXPECT_TRUE(notifications.Check1AndReset( |
730 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 734 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
731 | 735 |
732 // controller.LoadURL(kUrl2, content::PAGE_TRANSITION_TYPED); | 736 // controller.LoadURL(kUrl2, content::PAGE_TRANSITION_TYPED); |
733 rvh()->SendNavigate(1, kUrl2); | 737 test_rvh()->SendNavigate(1, kUrl2); |
734 EXPECT_TRUE(notifications.Check1AndReset( | 738 EXPECT_TRUE(notifications.Check1AndReset( |
735 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 739 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
736 | 740 |
737 // Now start a new pending navigation and go back before it commits. | 741 // Now start a new pending navigation and go back before it commits. |
738 controller.LoadURL( | 742 controller.LoadURL( |
739 kUrl3, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 743 kUrl3, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
740 std::string()); | 744 std::string()); |
741 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 745 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
742 EXPECT_EQ(kUrl3, controller.GetPendingEntry()->GetURL()); | 746 EXPECT_EQ(kUrl3, controller.GetPendingEntry()->GetURL()); |
743 controller.GoBack(); | 747 controller.GoBack(); |
744 | 748 |
745 // The pending navigation should now be the "back" item and the new one | 749 // The pending navigation should now be the "back" item and the new one |
746 // should be gone. | 750 // should be gone. |
747 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 751 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
748 EXPECT_EQ(kUrl1, controller.GetPendingEntry()->GetURL()); | 752 EXPECT_EQ(kUrl1, controller.GetPendingEntry()->GetURL()); |
749 } | 753 } |
750 | 754 |
751 // Receives a back message when there is a different renavigation already | 755 // Receives a back message when there is a different renavigation already |
752 // pending. | 756 // pending. |
753 TEST_F(NavigationControllerTest, Back_OtherBackPending) { | 757 TEST_F(NavigationControllerTest, Back_OtherBackPending) { |
754 NavigationControllerImpl& controller = controller_impl(); | 758 NavigationControllerImpl& controller = controller_impl(); |
755 const GURL kUrl1("http://foo/1"); | 759 const GURL kUrl1("http://foo/1"); |
756 const GURL kUrl2("http://foo/2"); | 760 const GURL kUrl2("http://foo/2"); |
757 const GURL kUrl3("http://foo/3"); | 761 const GURL kUrl3("http://foo/3"); |
758 | 762 |
759 // First navigate three places so we have some back history. | 763 // First navigate three places so we have some back history. |
760 rvh()->SendNavigate(0, kUrl1); | 764 test_rvh()->SendNavigate(0, kUrl1); |
761 rvh()->SendNavigate(1, kUrl2); | 765 test_rvh()->SendNavigate(1, kUrl2); |
762 rvh()->SendNavigate(2, kUrl3); | 766 test_rvh()->SendNavigate(2, kUrl3); |
763 | 767 |
764 // With nothing pending, say we get a navigation to the second entry. | 768 // With nothing pending, say we get a navigation to the second entry. |
765 rvh()->SendNavigate(1, kUrl2); | 769 test_rvh()->SendNavigate(1, kUrl2); |
766 | 770 |
767 // We know all the entries have the same site instance, so we can just grab | 771 // We know all the entries have the same site instance, so we can just grab |
768 // a random one for looking up other entries. | 772 // a random one for looking up other entries. |
769 SiteInstance* site_instance = | 773 SiteInstance* site_instance = |
770 NavigationEntryImpl::FromNavigationEntry( | 774 NavigationEntryImpl::FromNavigationEntry( |
771 controller.GetLastCommittedEntry())->site_instance(); | 775 controller.GetLastCommittedEntry())->site_instance(); |
772 | 776 |
773 // That second URL should be the last committed and it should have gotten the | 777 // That second URL should be the last committed and it should have gotten the |
774 // new title. | 778 // new title. |
775 EXPECT_EQ(kUrl2, controller.GetEntryWithPageID(site_instance, 1)->GetURL()); | 779 EXPECT_EQ(kUrl2, controller.GetEntryWithPageID(site_instance, 1)->GetURL()); |
776 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 780 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
777 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 781 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
778 | 782 |
779 // Now go forward to the last item again and say it was committed. | 783 // Now go forward to the last item again and say it was committed. |
780 controller.GoForward(); | 784 controller.GoForward(); |
781 rvh()->SendNavigate(2, kUrl3); | 785 test_rvh()->SendNavigate(2, kUrl3); |
782 | 786 |
783 // Now start going back one to the second page. It will be pending. | 787 // Now start going back one to the second page. It will be pending. |
784 controller.GoBack(); | 788 controller.GoBack(); |
785 EXPECT_EQ(1, controller.GetPendingEntryIndex()); | 789 EXPECT_EQ(1, controller.GetPendingEntryIndex()); |
786 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 790 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
787 | 791 |
788 // Not synthesize a totally new back event to the first page. This will not | 792 // Not synthesize a totally new back event to the first page. This will not |
789 // match the pending one. | 793 // match the pending one. |
790 rvh()->SendNavigate(0, kUrl1); | 794 test_rvh()->SendNavigate(0, kUrl1); |
791 | 795 |
792 // The committed navigation should clear the pending entry. | 796 // The committed navigation should clear the pending entry. |
793 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 797 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
794 | 798 |
795 // But the navigated entry should be the last committed. | 799 // But the navigated entry should be the last committed. |
796 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 800 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
797 EXPECT_EQ(kUrl1, controller.GetLastCommittedEntry()->GetURL()); | 801 EXPECT_EQ(kUrl1, controller.GetLastCommittedEntry()->GetURL()); |
798 } | 802 } |
799 | 803 |
800 // Tests what happens when we navigate forward successfully. | 804 // Tests what happens when we navigate forward successfully. |
801 TEST_F(NavigationControllerTest, Forward) { | 805 TEST_F(NavigationControllerTest, Forward) { |
802 NavigationControllerImpl& controller = controller_impl(); | 806 NavigationControllerImpl& controller = controller_impl(); |
803 TestNotificationTracker notifications; | 807 TestNotificationTracker notifications; |
804 RegisterForAllNavNotifications(¬ifications, &controller); | 808 RegisterForAllNavNotifications(¬ifications, &controller); |
805 | 809 |
806 const GURL url1("http://foo1"); | 810 const GURL url1("http://foo1"); |
807 const GURL url2("http://foo2"); | 811 const GURL url2("http://foo2"); |
808 | 812 |
809 rvh()->SendNavigate(0, url1); | 813 test_rvh()->SendNavigate(0, url1); |
810 EXPECT_TRUE(notifications.Check1AndReset( | 814 EXPECT_TRUE(notifications.Check1AndReset( |
811 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 815 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
812 | 816 |
813 rvh()->SendNavigate(1, url2); | 817 test_rvh()->SendNavigate(1, url2); |
814 EXPECT_TRUE(notifications.Check1AndReset( | 818 EXPECT_TRUE(notifications.Check1AndReset( |
815 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 819 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
816 | 820 |
817 controller.GoBack(); | 821 controller.GoBack(); |
818 rvh()->SendNavigate(0, url1); | 822 test_rvh()->SendNavigate(0, url1); |
819 EXPECT_TRUE(notifications.Check1AndReset( | 823 EXPECT_TRUE(notifications.Check1AndReset( |
820 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 824 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
821 | 825 |
822 controller.GoForward(); | 826 controller.GoForward(); |
823 | 827 |
824 // We should now have a pending navigation to go forward. | 828 // We should now have a pending navigation to go forward. |
825 EXPECT_EQ(controller.GetEntryCount(), 2); | 829 EXPECT_EQ(controller.GetEntryCount(), 2); |
826 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 830 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
827 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); | 831 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); |
828 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 832 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
829 EXPECT_TRUE(controller.GetPendingEntry()); | 833 EXPECT_TRUE(controller.GetPendingEntry()); |
830 EXPECT_TRUE(controller.CanGoBack()); | 834 EXPECT_TRUE(controller.CanGoBack()); |
831 EXPECT_FALSE(controller.CanGoForward()); | 835 EXPECT_FALSE(controller.CanGoForward()); |
832 | 836 |
833 rvh()->SendNavigate(1, url2); | 837 test_rvh()->SendNavigate(1, url2); |
834 EXPECT_TRUE(notifications.Check1AndReset( | 838 EXPECT_TRUE(notifications.Check1AndReset( |
835 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 839 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
836 | 840 |
837 // The forward navigation completed successfully. | 841 // The forward navigation completed successfully. |
838 EXPECT_EQ(controller.GetEntryCount(), 2); | 842 EXPECT_EQ(controller.GetEntryCount(), 2); |
839 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 843 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
840 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 844 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
841 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 845 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
842 EXPECT_FALSE(controller.GetPendingEntry()); | 846 EXPECT_FALSE(controller.GetPendingEntry()); |
843 EXPECT_TRUE(controller.CanGoBack()); | 847 EXPECT_TRUE(controller.CanGoBack()); |
844 EXPECT_FALSE(controller.CanGoForward()); | 848 EXPECT_FALSE(controller.CanGoForward()); |
845 } | 849 } |
846 | 850 |
847 // Tests what happens when a forward navigation produces a new page. | 851 // Tests what happens when a forward navigation produces a new page. |
848 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { | 852 TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { |
849 NavigationControllerImpl& controller = controller_impl(); | 853 NavigationControllerImpl& controller = controller_impl(); |
850 TestNotificationTracker notifications; | 854 TestNotificationTracker notifications; |
851 RegisterForAllNavNotifications(¬ifications, &controller); | 855 RegisterForAllNavNotifications(¬ifications, &controller); |
852 | 856 |
853 const GURL url1("http://foo1"); | 857 const GURL url1("http://foo1"); |
854 const GURL url2("http://foo2"); | 858 const GURL url2("http://foo2"); |
855 const GURL url3("http://foo3"); | 859 const GURL url3("http://foo3"); |
856 | 860 |
857 rvh()->SendNavigate(0, url1); | 861 test_rvh()->SendNavigate(0, url1); |
858 EXPECT_TRUE(notifications.Check1AndReset( | 862 EXPECT_TRUE(notifications.Check1AndReset( |
859 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 863 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
860 rvh()->SendNavigate(1, url2); | 864 test_rvh()->SendNavigate(1, url2); |
861 EXPECT_TRUE(notifications.Check1AndReset( | 865 EXPECT_TRUE(notifications.Check1AndReset( |
862 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 866 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
863 | 867 |
864 controller.GoBack(); | 868 controller.GoBack(); |
865 rvh()->SendNavigate(0, url1); | 869 test_rvh()->SendNavigate(0, url1); |
866 EXPECT_TRUE(notifications.Check1AndReset( | 870 EXPECT_TRUE(notifications.Check1AndReset( |
867 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 871 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
868 | 872 |
869 controller.GoForward(); | 873 controller.GoForward(); |
870 EXPECT_EQ(0U, notifications.size()); | 874 EXPECT_EQ(0U, notifications.size()); |
871 | 875 |
872 // Should now have a pending navigation to go forward. | 876 // Should now have a pending navigation to go forward. |
873 EXPECT_EQ(controller.GetEntryCount(), 2); | 877 EXPECT_EQ(controller.GetEntryCount(), 2); |
874 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 878 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
875 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); | 879 EXPECT_EQ(controller.GetPendingEntryIndex(), 1); |
876 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 880 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
877 EXPECT_TRUE(controller.GetPendingEntry()); | 881 EXPECT_TRUE(controller.GetPendingEntry()); |
878 EXPECT_TRUE(controller.CanGoBack()); | 882 EXPECT_TRUE(controller.CanGoBack()); |
879 EXPECT_FALSE(controller.CanGoForward()); | 883 EXPECT_FALSE(controller.CanGoForward()); |
880 | 884 |
881 rvh()->SendNavigate(2, url3); | 885 test_rvh()->SendNavigate(2, url3); |
882 EXPECT_TRUE(notifications.Check2AndReset( | 886 EXPECT_TRUE(notifications.Check2AndReset( |
883 content::NOTIFICATION_NAV_LIST_PRUNED, | 887 content::NOTIFICATION_NAV_LIST_PRUNED, |
884 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 888 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
885 | 889 |
886 EXPECT_EQ(controller.GetEntryCount(), 2); | 890 EXPECT_EQ(controller.GetEntryCount(), 2); |
887 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 891 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
888 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 892 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
889 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 893 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
890 EXPECT_FALSE(controller.GetPendingEntry()); | 894 EXPECT_FALSE(controller.GetPendingEntry()); |
891 EXPECT_TRUE(controller.CanGoBack()); | 895 EXPECT_TRUE(controller.CanGoBack()); |
892 EXPECT_FALSE(controller.CanGoForward()); | 896 EXPECT_FALSE(controller.CanGoForward()); |
893 } | 897 } |
894 | 898 |
895 // Two consequent navigation for the same URL entered in should be considered | 899 // Two consequent navigation for the same URL entered in should be considered |
896 // as SAME_PAGE navigation even when we are redirected to some other page. | 900 // as SAME_PAGE navigation even when we are redirected to some other page. |
897 TEST_F(NavigationControllerTest, Redirect) { | 901 TEST_F(NavigationControllerTest, Redirect) { |
898 NavigationControllerImpl& controller = controller_impl(); | 902 NavigationControllerImpl& controller = controller_impl(); |
899 TestNotificationTracker notifications; | 903 TestNotificationTracker notifications; |
900 RegisterForAllNavNotifications(¬ifications, &controller); | 904 RegisterForAllNavNotifications(¬ifications, &controller); |
901 | 905 |
902 const GURL url1("http://foo1"); | 906 const GURL url1("http://foo1"); |
903 const GURL url2("http://foo2"); // Redirection target | 907 const GURL url2("http://foo2"); // Redirection target |
904 | 908 |
905 // First request | 909 // First request |
906 controller.LoadURL( | 910 controller.LoadURL( |
907 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 911 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
908 | 912 |
909 EXPECT_EQ(0U, notifications.size()); | 913 EXPECT_EQ(0U, notifications.size()); |
910 rvh()->SendNavigate(0, url2); | 914 test_rvh()->SendNavigate(0, url2); |
911 EXPECT_TRUE(notifications.Check1AndReset( | 915 EXPECT_TRUE(notifications.Check1AndReset( |
912 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 916 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
913 | 917 |
914 // Second request | 918 // Second request |
915 controller.LoadURL( | 919 controller.LoadURL( |
916 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 920 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
917 | 921 |
918 EXPECT_TRUE(controller.GetPendingEntry()); | 922 EXPECT_TRUE(controller.GetPendingEntry()); |
919 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 923 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
920 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); | 924 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 963 |
960 const GURL url1("http://foo1"); | 964 const GURL url1("http://foo1"); |
961 const GURL url2("http://foo2"); // Redirection target | 965 const GURL url2("http://foo2"); // Redirection target |
962 | 966 |
963 // First request as POST | 967 // First request as POST |
964 controller.LoadURL( | 968 controller.LoadURL( |
965 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 969 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
966 controller.GetActiveEntry()->SetHasPostData(true); | 970 controller.GetActiveEntry()->SetHasPostData(true); |
967 | 971 |
968 EXPECT_EQ(0U, notifications.size()); | 972 EXPECT_EQ(0U, notifications.size()); |
969 rvh()->SendNavigate(0, url2); | 973 test_rvh()->SendNavigate(0, url2); |
970 EXPECT_TRUE(notifications.Check1AndReset( | 974 EXPECT_TRUE(notifications.Check1AndReset( |
971 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 975 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
972 | 976 |
973 // Second request | 977 // Second request |
974 controller.LoadURL( | 978 controller.LoadURL( |
975 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 979 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
976 | 980 |
977 EXPECT_TRUE(controller.GetPendingEntry()); | 981 EXPECT_TRUE(controller.GetPendingEntry()); |
978 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 982 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
979 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); | 983 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 } | 1061 } |
1058 | 1062 |
1059 // Tests navigation via link click within a subframe. A new navigation entry | 1063 // Tests navigation via link click within a subframe. A new navigation entry |
1060 // should be created. | 1064 // should be created. |
1061 TEST_F(NavigationControllerTest, NewSubframe) { | 1065 TEST_F(NavigationControllerTest, NewSubframe) { |
1062 NavigationControllerImpl& controller = controller_impl(); | 1066 NavigationControllerImpl& controller = controller_impl(); |
1063 TestNotificationTracker notifications; | 1067 TestNotificationTracker notifications; |
1064 RegisterForAllNavNotifications(¬ifications, &controller); | 1068 RegisterForAllNavNotifications(¬ifications, &controller); |
1065 | 1069 |
1066 const GURL url1("http://foo1"); | 1070 const GURL url1("http://foo1"); |
1067 rvh()->SendNavigate(0, url1); | 1071 test_rvh()->SendNavigate(0, url1); |
1068 EXPECT_TRUE(notifications.Check1AndReset( | 1072 EXPECT_TRUE(notifications.Check1AndReset( |
1069 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1073 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1070 | 1074 |
1071 const GURL url2("http://foo2"); | 1075 const GURL url2("http://foo2"); |
1072 ViewHostMsg_FrameNavigate_Params params; | 1076 ViewHostMsg_FrameNavigate_Params params; |
1073 params.page_id = 1; | 1077 params.page_id = 1; |
1074 params.url = url2; | 1078 params.url = url2; |
1075 params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; | 1079 params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; |
1076 params.should_update_history = false; | 1080 params.should_update_history = false; |
1077 params.gesture = NavigationGestureUser; | 1081 params.gesture = NavigationGestureUser; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 } | 1124 } |
1121 | 1125 |
1122 // Auto subframes are ones the page loads automatically like ads. They should | 1126 // Auto subframes are ones the page loads automatically like ads. They should |
1123 // not create new navigation entries. | 1127 // not create new navigation entries. |
1124 TEST_F(NavigationControllerTest, AutoSubframe) { | 1128 TEST_F(NavigationControllerTest, AutoSubframe) { |
1125 NavigationControllerImpl& controller = controller_impl(); | 1129 NavigationControllerImpl& controller = controller_impl(); |
1126 TestNotificationTracker notifications; | 1130 TestNotificationTracker notifications; |
1127 RegisterForAllNavNotifications(¬ifications, &controller); | 1131 RegisterForAllNavNotifications(¬ifications, &controller); |
1128 | 1132 |
1129 const GURL url1("http://foo1"); | 1133 const GURL url1("http://foo1"); |
1130 rvh()->SendNavigate(0, url1); | 1134 test_rvh()->SendNavigate(0, url1); |
1131 EXPECT_TRUE(notifications.Check1AndReset( | 1135 EXPECT_TRUE(notifications.Check1AndReset( |
1132 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1136 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1133 | 1137 |
1134 const GURL url2("http://foo2"); | 1138 const GURL url2("http://foo2"); |
1135 ViewHostMsg_FrameNavigate_Params params; | 1139 ViewHostMsg_FrameNavigate_Params params; |
1136 params.page_id = 0; | 1140 params.page_id = 0; |
1137 params.url = url2; | 1141 params.url = url2; |
1138 params.transition = content::PAGE_TRANSITION_AUTO_SUBFRAME; | 1142 params.transition = content::PAGE_TRANSITION_AUTO_SUBFRAME; |
1139 params.should_update_history = false; | 1143 params.should_update_history = false; |
1140 params.gesture = NavigationGestureUser; | 1144 params.gesture = NavigationGestureUser; |
(...skipping 10 matching lines...) Expand all Loading... |
1151 } | 1155 } |
1152 | 1156 |
1153 // Tests navigation and then going back to a subframe navigation. | 1157 // Tests navigation and then going back to a subframe navigation. |
1154 TEST_F(NavigationControllerTest, BackSubframe) { | 1158 TEST_F(NavigationControllerTest, BackSubframe) { |
1155 NavigationControllerImpl& controller = controller_impl(); | 1159 NavigationControllerImpl& controller = controller_impl(); |
1156 TestNotificationTracker notifications; | 1160 TestNotificationTracker notifications; |
1157 RegisterForAllNavNotifications(¬ifications, &controller); | 1161 RegisterForAllNavNotifications(¬ifications, &controller); |
1158 | 1162 |
1159 // Main page. | 1163 // Main page. |
1160 const GURL url1("http://foo1"); | 1164 const GURL url1("http://foo1"); |
1161 rvh()->SendNavigate(0, url1); | 1165 test_rvh()->SendNavigate(0, url1); |
1162 EXPECT_TRUE(notifications.Check1AndReset( | 1166 EXPECT_TRUE(notifications.Check1AndReset( |
1163 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1167 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1164 | 1168 |
1165 // First manual subframe navigation. | 1169 // First manual subframe navigation. |
1166 const GURL url2("http://foo2"); | 1170 const GURL url2("http://foo2"); |
1167 ViewHostMsg_FrameNavigate_Params params; | 1171 ViewHostMsg_FrameNavigate_Params params; |
1168 params.page_id = 1; | 1172 params.page_id = 1; |
1169 params.url = url2; | 1173 params.url = url2; |
1170 params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; | 1174 params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; |
1171 params.should_update_history = false; | 1175 params.should_update_history = false; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 } | 1216 } |
1213 | 1217 |
1214 TEST_F(NavigationControllerTest, LinkClick) { | 1218 TEST_F(NavigationControllerTest, LinkClick) { |
1215 NavigationControllerImpl& controller = controller_impl(); | 1219 NavigationControllerImpl& controller = controller_impl(); |
1216 TestNotificationTracker notifications; | 1220 TestNotificationTracker notifications; |
1217 RegisterForAllNavNotifications(¬ifications, &controller); | 1221 RegisterForAllNavNotifications(¬ifications, &controller); |
1218 | 1222 |
1219 const GURL url1("http://foo1"); | 1223 const GURL url1("http://foo1"); |
1220 const GURL url2("http://foo2"); | 1224 const GURL url2("http://foo2"); |
1221 | 1225 |
1222 rvh()->SendNavigate(0, url1); | 1226 test_rvh()->SendNavigate(0, url1); |
1223 EXPECT_TRUE(notifications.Check1AndReset( | 1227 EXPECT_TRUE(notifications.Check1AndReset( |
1224 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1228 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1225 | 1229 |
1226 rvh()->SendNavigate(1, url2); | 1230 test_rvh()->SendNavigate(1, url2); |
1227 EXPECT_TRUE(notifications.Check1AndReset( | 1231 EXPECT_TRUE(notifications.Check1AndReset( |
1228 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1232 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1229 | 1233 |
1230 // Should not have produced a new session history entry. | 1234 // Should not have produced a new session history entry. |
1231 EXPECT_EQ(controller.GetEntryCount(), 2); | 1235 EXPECT_EQ(controller.GetEntryCount(), 2); |
1232 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1236 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
1233 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1237 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1234 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1238 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
1235 EXPECT_FALSE(controller.GetPendingEntry()); | 1239 EXPECT_FALSE(controller.GetPendingEntry()); |
1236 EXPECT_TRUE(controller.CanGoBack()); | 1240 EXPECT_TRUE(controller.CanGoBack()); |
1237 EXPECT_FALSE(controller.CanGoForward()); | 1241 EXPECT_FALSE(controller.CanGoForward()); |
1238 } | 1242 } |
1239 | 1243 |
1240 TEST_F(NavigationControllerTest, InPage) { | 1244 TEST_F(NavigationControllerTest, InPage) { |
1241 NavigationControllerImpl& controller = controller_impl(); | 1245 NavigationControllerImpl& controller = controller_impl(); |
1242 TestNotificationTracker notifications; | 1246 TestNotificationTracker notifications; |
1243 RegisterForAllNavNotifications(¬ifications, &controller); | 1247 RegisterForAllNavNotifications(¬ifications, &controller); |
1244 | 1248 |
1245 // Main page. | 1249 // Main page. |
1246 const GURL url1("http://foo"); | 1250 const GURL url1("http://foo"); |
1247 rvh()->SendNavigate(0, url1); | 1251 test_rvh()->SendNavigate(0, url1); |
1248 EXPECT_TRUE(notifications.Check1AndReset( | 1252 EXPECT_TRUE(notifications.Check1AndReset( |
1249 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1253 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1250 | 1254 |
1251 // First navigation. | 1255 // First navigation. |
1252 const GURL url2("http://foo#a"); | 1256 const GURL url2("http://foo#a"); |
1253 ViewHostMsg_FrameNavigate_Params params; | 1257 ViewHostMsg_FrameNavigate_Params params; |
1254 params.page_id = 1; | 1258 params.page_id = 1; |
1255 params.url = url2; | 1259 params.url = url2; |
1256 params.transition = content::PAGE_TRANSITION_LINK; | 1260 params.transition = content::PAGE_TRANSITION_LINK; |
1257 params.should_update_history = false; | 1261 params.should_update_history = false; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 EXPECT_FALSE(details.is_in_page); | 1323 EXPECT_FALSE(details.is_in_page); |
1320 } | 1324 } |
1321 | 1325 |
1322 TEST_F(NavigationControllerTest, InPage_Replace) { | 1326 TEST_F(NavigationControllerTest, InPage_Replace) { |
1323 NavigationControllerImpl& controller = controller_impl(); | 1327 NavigationControllerImpl& controller = controller_impl(); |
1324 TestNotificationTracker notifications; | 1328 TestNotificationTracker notifications; |
1325 RegisterForAllNavNotifications(¬ifications, &controller); | 1329 RegisterForAllNavNotifications(¬ifications, &controller); |
1326 | 1330 |
1327 // Main page. | 1331 // Main page. |
1328 const GURL url1("http://foo"); | 1332 const GURL url1("http://foo"); |
1329 rvh()->SendNavigate(0, url1); | 1333 test_rvh()->SendNavigate(0, url1); |
1330 EXPECT_TRUE(notifications.Check1AndReset( | 1334 EXPECT_TRUE(notifications.Check1AndReset( |
1331 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1335 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1332 | 1336 |
1333 // First navigation. | 1337 // First navigation. |
1334 const GURL url2("http://foo#a"); | 1338 const GURL url2("http://foo#a"); |
1335 ViewHostMsg_FrameNavigate_Params params; | 1339 ViewHostMsg_FrameNavigate_Params params; |
1336 params.page_id = 0; // Same page_id | 1340 params.page_id = 0; // Same page_id |
1337 params.url = url2; | 1341 params.url = url2; |
1338 params.transition = content::PAGE_TRANSITION_LINK; | 1342 params.transition = content::PAGE_TRANSITION_LINK; |
1339 params.should_update_history = false; | 1343 params.should_update_history = false; |
(...skipping 18 matching lines...) Expand all Loading... |
1358 // window.location='http://foo3/'; | 1362 // window.location='http://foo3/'; |
1359 // </script> | 1363 // </script> |
1360 TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) { | 1364 TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) { |
1361 NavigationControllerImpl& controller = controller_impl(); | 1365 NavigationControllerImpl& controller = controller_impl(); |
1362 TestNotificationTracker notifications; | 1366 TestNotificationTracker notifications; |
1363 RegisterForAllNavNotifications(¬ifications, &controller); | 1367 RegisterForAllNavNotifications(¬ifications, &controller); |
1364 | 1368 |
1365 // Load an initial page. | 1369 // Load an initial page. |
1366 { | 1370 { |
1367 const GURL url("http://foo/"); | 1371 const GURL url("http://foo/"); |
1368 rvh()->SendNavigate(0, url); | 1372 test_rvh()->SendNavigate(0, url); |
1369 EXPECT_TRUE(notifications.Check1AndReset( | 1373 EXPECT_TRUE(notifications.Check1AndReset( |
1370 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1374 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1371 } | 1375 } |
1372 | 1376 |
1373 // Navigate to a new page. | 1377 // Navigate to a new page. |
1374 { | 1378 { |
1375 const GURL url("http://foo2/"); | 1379 const GURL url("http://foo2/"); |
1376 rvh()->SendNavigate(1, url); | 1380 test_rvh()->SendNavigate(1, url); |
1377 controller.DocumentLoadedInFrame(); | 1381 controller.DocumentLoadedInFrame(); |
1378 EXPECT_TRUE(notifications.Check1AndReset( | 1382 EXPECT_TRUE(notifications.Check1AndReset( |
1379 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1383 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1380 } | 1384 } |
1381 | 1385 |
1382 // Navigate within the page. | 1386 // Navigate within the page. |
1383 { | 1387 { |
1384 const GURL url("http://foo2/#a"); | 1388 const GURL url("http://foo2/#a"); |
1385 ViewHostMsg_FrameNavigate_Params params; | 1389 ViewHostMsg_FrameNavigate_Params params; |
1386 params.page_id = 1; // Same page_id | 1390 params.page_id = 1; // Same page_id |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 EXPECT_TRUE(notifications.Check1AndReset( | 1426 EXPECT_TRUE(notifications.Check1AndReset( |
1423 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1427 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1424 EXPECT_FALSE(details.is_in_page); | 1428 EXPECT_FALSE(details.is_in_page); |
1425 EXPECT_EQ(3, controller.GetEntryCount()); | 1429 EXPECT_EQ(3, controller.GetEntryCount()); |
1426 } | 1430 } |
1427 | 1431 |
1428 // Verify that BACK brings us back to http://foo2/. | 1432 // Verify that BACK brings us back to http://foo2/. |
1429 { | 1433 { |
1430 const GURL url("http://foo2/"); | 1434 const GURL url("http://foo2/"); |
1431 controller.GoBack(); | 1435 controller.GoBack(); |
1432 rvh()->SendNavigate(1, url); | 1436 test_rvh()->SendNavigate(1, url); |
1433 EXPECT_TRUE(notifications.Check1AndReset( | 1437 EXPECT_TRUE(notifications.Check1AndReset( |
1434 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 1438 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
1435 EXPECT_EQ(url, controller.GetActiveEntry()->GetURL()); | 1439 EXPECT_EQ(url, controller.GetActiveEntry()->GetURL()); |
1436 } | 1440 } |
1437 } | 1441 } |
1438 | 1442 |
1439 // NotificationObserver implementation used in verifying we've received the | 1443 // NotificationObserver implementation used in verifying we've received the |
1440 // content::NOTIFICATION_NAV_LIST_PRUNED method. | 1444 // content::NOTIFICATION_NAV_LIST_PRUNED method. |
1441 class PrunedListener : public content::NotificationObserver { | 1445 class PrunedListener : public content::NotificationObserver { |
1442 public: | 1446 public: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 | 1479 |
1476 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); | 1480 NavigationControllerImpl::set_max_entry_count_for_testing(kMaxEntryCount); |
1477 | 1481 |
1478 int url_index; | 1482 int url_index; |
1479 // Load up to the max count, all entries should be there. | 1483 // Load up to the max count, all entries should be there. |
1480 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { | 1484 for (url_index = 0; url_index < kMaxEntryCount; url_index++) { |
1481 GURL url(StringPrintf("http://www.a.com/%d", url_index)); | 1485 GURL url(StringPrintf("http://www.a.com/%d", url_index)); |
1482 controller.LoadURL( | 1486 controller.LoadURL( |
1483 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 1487 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
1484 std::string()); | 1488 std::string()); |
1485 rvh()->SendNavigate(url_index, url); | 1489 test_rvh()->SendNavigate(url_index, url); |
1486 } | 1490 } |
1487 | 1491 |
1488 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 1492 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
1489 | 1493 |
1490 // Created a PrunedListener to observe prune notifications. | 1494 // Created a PrunedListener to observe prune notifications. |
1491 PrunedListener listener(&controller); | 1495 PrunedListener listener(&controller); |
1492 | 1496 |
1493 // Navigate some more. | 1497 // Navigate some more. |
1494 GURL url(StringPrintf("http://www.a.com/%d", url_index)); | 1498 GURL url(StringPrintf("http://www.a.com/%d", url_index)); |
1495 controller.LoadURL( | 1499 controller.LoadURL( |
1496 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1500 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1497 rvh()->SendNavigate(url_index, url); | 1501 test_rvh()->SendNavigate(url_index, url); |
1498 url_index++; | 1502 url_index++; |
1499 | 1503 |
1500 // We should have got a pruned navigation. | 1504 // We should have got a pruned navigation. |
1501 EXPECT_EQ(1, listener.notification_count_); | 1505 EXPECT_EQ(1, listener.notification_count_); |
1502 EXPECT_TRUE(listener.details_.from_front); | 1506 EXPECT_TRUE(listener.details_.from_front); |
1503 EXPECT_EQ(1, listener.details_.count); | 1507 EXPECT_EQ(1, listener.details_.count); |
1504 | 1508 |
1505 // We expect http://www.a.com/0 to be gone. | 1509 // We expect http://www.a.com/0 to be gone. |
1506 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 1510 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
1507 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 1511 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
1508 GURL("http:////www.a.com/1")); | 1512 GURL("http:////www.a.com/1")); |
1509 | 1513 |
1510 // More navigations. | 1514 // More navigations. |
1511 for (int i = 0; i < 3; i++) { | 1515 for (int i = 0; i < 3; i++) { |
1512 url = GURL(StringPrintf("http:////www.a.com/%d", url_index)); | 1516 url = GURL(StringPrintf("http:////www.a.com/%d", url_index)); |
1513 controller.LoadURL( | 1517 controller.LoadURL( |
1514 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 1518 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
1515 std::string()); | 1519 std::string()); |
1516 rvh()->SendNavigate(url_index, url); | 1520 test_rvh()->SendNavigate(url_index, url); |
1517 url_index++; | 1521 url_index++; |
1518 } | 1522 } |
1519 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); | 1523 EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount); |
1520 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), | 1524 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), |
1521 GURL("http:////www.a.com/4")); | 1525 GURL("http:////www.a.com/4")); |
1522 | 1526 |
1523 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); | 1527 NavigationControllerImpl::set_max_entry_count_for_testing(original_count); |
1524 } | 1528 } |
1525 | 1529 |
1526 // Tests that we can do a restore and navigate to the restored entries and | 1530 // Tests that we can do a restore and navigate to the restored entries and |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 our_controller.GetEntryAtIndex(0))->restore_type()); | 1675 our_controller.GetEntryAtIndex(0))->restore_type()); |
1672 } | 1676 } |
1673 | 1677 |
1674 // Make sure that the page type and stuff is correct after an interstitial. | 1678 // Make sure that the page type and stuff is correct after an interstitial. |
1675 TEST_F(NavigationControllerTest, Interstitial) { | 1679 TEST_F(NavigationControllerTest, Interstitial) { |
1676 NavigationControllerImpl& controller = controller_impl(); | 1680 NavigationControllerImpl& controller = controller_impl(); |
1677 // First navigate somewhere normal. | 1681 // First navigate somewhere normal. |
1678 const GURL url1("http://foo"); | 1682 const GURL url1("http://foo"); |
1679 controller.LoadURL( | 1683 controller.LoadURL( |
1680 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1684 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1681 rvh()->SendNavigate(0, url1); | 1685 test_rvh()->SendNavigate(0, url1); |
1682 | 1686 |
1683 // Now navigate somewhere with an interstitial. | 1687 // Now navigate somewhere with an interstitial. |
1684 const GURL url2("http://bar"); | 1688 const GURL url2("http://bar"); |
1685 controller.LoadURL( | 1689 controller.LoadURL( |
1686 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1690 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1687 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 1691 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
1688 set_page_type(content::PAGE_TYPE_INTERSTITIAL); | 1692 set_page_type(content::PAGE_TYPE_INTERSTITIAL); |
1689 | 1693 |
1690 // At this point the interstitial will be displayed and the load will still | 1694 // At this point the interstitial will be displayed and the load will still |
1691 // be pending. If the user continues, the load will commit. | 1695 // be pending. If the user continues, the load will commit. |
1692 rvh()->SendNavigate(1, url2); | 1696 test_rvh()->SendNavigate(1, url2); |
1693 | 1697 |
1694 // The page should be a normal page again. | 1698 // The page should be a normal page again. |
1695 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 1699 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
1696 EXPECT_EQ(content::PAGE_TYPE_NORMAL, | 1700 EXPECT_EQ(content::PAGE_TYPE_NORMAL, |
1697 controller.GetLastCommittedEntry()->GetPageType()); | 1701 controller.GetLastCommittedEntry()->GetPageType()); |
1698 } | 1702 } |
1699 | 1703 |
1700 TEST_F(NavigationControllerTest, RemoveEntry) { | 1704 TEST_F(NavigationControllerTest, RemoveEntry) { |
1701 NavigationControllerImpl& controller = controller_impl(); | 1705 NavigationControllerImpl& controller = controller_impl(); |
1702 const GURL url1("http://foo/1"); | 1706 const GURL url1("http://foo/1"); |
1703 const GURL url2("http://foo/2"); | 1707 const GURL url2("http://foo/2"); |
1704 const GURL url3("http://foo/3"); | 1708 const GURL url3("http://foo/3"); |
1705 const GURL url4("http://foo/4"); | 1709 const GURL url4("http://foo/4"); |
1706 const GURL url5("http://foo/5"); | 1710 const GURL url5("http://foo/5"); |
1707 const GURL pending_url("http://foo/pending"); | 1711 const GURL pending_url("http://foo/pending"); |
1708 const GURL default_url("http://foo/default"); | 1712 const GURL default_url("http://foo/default"); |
1709 | 1713 |
1710 controller.LoadURL( | 1714 controller.LoadURL( |
1711 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1715 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1712 rvh()->SendNavigate(0, url1); | 1716 test_rvh()->SendNavigate(0, url1); |
1713 controller.LoadURL( | 1717 controller.LoadURL( |
1714 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1718 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1715 rvh()->SendNavigate(1, url2); | 1719 test_rvh()->SendNavigate(1, url2); |
1716 controller.LoadURL( | 1720 controller.LoadURL( |
1717 url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1721 url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1718 rvh()->SendNavigate(2, url3); | 1722 test_rvh()->SendNavigate(2, url3); |
1719 controller.LoadURL( | 1723 controller.LoadURL( |
1720 url4, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1724 url4, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1721 rvh()->SendNavigate(3, url4); | 1725 test_rvh()->SendNavigate(3, url4); |
1722 controller.LoadURL( | 1726 controller.LoadURL( |
1723 url5, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1727 url5, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1724 rvh()->SendNavigate(4, url5); | 1728 test_rvh()->SendNavigate(4, url5); |
1725 | 1729 |
1726 // Try to remove the last entry. Will fail because it is the current entry. | 1730 // Try to remove the last entry. Will fail because it is the current entry. |
1727 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); | 1731 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); |
1728 EXPECT_EQ(5, controller.GetEntryCount()); | 1732 EXPECT_EQ(5, controller.GetEntryCount()); |
1729 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); | 1733 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); |
1730 | 1734 |
1731 // Go back and remove the last entry. | 1735 // Go back and remove the last entry. |
1732 controller.GoBack(); | 1736 controller.GoBack(); |
1733 rvh()->SendNavigate(3, url4); | 1737 test_rvh()->SendNavigate(3, url4); |
1734 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); | 1738 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); |
1735 EXPECT_EQ(4, controller.GetEntryCount()); | 1739 EXPECT_EQ(4, controller.GetEntryCount()); |
1736 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 1740 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
1737 EXPECT_FALSE(controller.GetPendingEntry()); | 1741 EXPECT_FALSE(controller.GetPendingEntry()); |
1738 | 1742 |
1739 // Remove an entry which is not the last committed one. | 1743 // Remove an entry which is not the last committed one. |
1740 controller.RemoveEntryAtIndex(0); | 1744 controller.RemoveEntryAtIndex(0); |
1741 EXPECT_EQ(3, controller.GetEntryCount()); | 1745 EXPECT_EQ(3, controller.GetEntryCount()); |
1742 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 1746 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
1743 EXPECT_FALSE(controller.GetPendingEntry()); | 1747 EXPECT_FALSE(controller.GetPendingEntry()); |
(...skipping 15 matching lines...) Expand all Loading... |
1759 | 1763 |
1760 const GURL url0("http://foo/0"); | 1764 const GURL url0("http://foo/0"); |
1761 const GURL url1("http://foo/1"); | 1765 const GURL url1("http://foo/1"); |
1762 const GURL url2("http://foo/2"); | 1766 const GURL url2("http://foo/2"); |
1763 const GURL url3("http://foo/3"); | 1767 const GURL url3("http://foo/3"); |
1764 const GURL url4("http://foo/4"); | 1768 const GURL url4("http://foo/4"); |
1765 const GURL transient_url("http://foo/transient"); | 1769 const GURL transient_url("http://foo/transient"); |
1766 | 1770 |
1767 controller.LoadURL( | 1771 controller.LoadURL( |
1768 url0, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1772 url0, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1769 rvh()->SendNavigate(0, url0); | 1773 test_rvh()->SendNavigate(0, url0); |
1770 controller.LoadURL( | 1774 controller.LoadURL( |
1771 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1775 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1772 rvh()->SendNavigate(1, url1); | 1776 test_rvh()->SendNavigate(1, url1); |
1773 | 1777 |
1774 notifications.Reset(); | 1778 notifications.Reset(); |
1775 | 1779 |
1776 // Adding a transient with no pending entry. | 1780 // Adding a transient with no pending entry. |
1777 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; | 1781 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; |
1778 transient_entry->SetURL(transient_url); | 1782 transient_entry->SetURL(transient_url); |
1779 controller.AddTransientEntry(transient_entry); | 1783 controller.AddTransientEntry(transient_entry); |
1780 | 1784 |
1781 // We should not have received any notifications. | 1785 // We should not have received any notifications. |
1782 EXPECT_EQ(0U, notifications.size()); | 1786 EXPECT_EQ(0U, notifications.size()); |
1783 | 1787 |
1784 // Check our state. | 1788 // Check our state. |
1785 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 1789 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
1786 EXPECT_EQ(controller.GetEntryCount(), 3); | 1790 EXPECT_EQ(controller.GetEntryCount(), 3); |
1787 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 1791 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
1788 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1792 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
1789 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1793 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
1790 EXPECT_FALSE(controller.GetPendingEntry()); | 1794 EXPECT_FALSE(controller.GetPendingEntry()); |
1791 EXPECT_TRUE(controller.CanGoBack()); | 1795 EXPECT_TRUE(controller.CanGoBack()); |
1792 EXPECT_FALSE(controller.CanGoForward()); | 1796 EXPECT_FALSE(controller.CanGoForward()); |
1793 EXPECT_EQ(contents()->GetMaxPageID(), 1); | 1797 EXPECT_EQ(contents()->GetMaxPageID(), 1); |
1794 | 1798 |
1795 // Navigate. | 1799 // Navigate. |
1796 controller.LoadURL( | 1800 controller.LoadURL( |
1797 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1801 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1798 rvh()->SendNavigate(2, url2); | 1802 test_rvh()->SendNavigate(2, url2); |
1799 | 1803 |
1800 // We should have navigated, transient entry should be gone. | 1804 // We should have navigated, transient entry should be gone. |
1801 EXPECT_EQ(url2, controller.GetActiveEntry()->GetURL()); | 1805 EXPECT_EQ(url2, controller.GetActiveEntry()->GetURL()); |
1802 EXPECT_EQ(controller.GetEntryCount(), 3); | 1806 EXPECT_EQ(controller.GetEntryCount(), 3); |
1803 | 1807 |
1804 // Add a transient again, then navigate with no pending entry this time. | 1808 // Add a transient again, then navigate with no pending entry this time. |
1805 transient_entry = new NavigationEntryImpl; | 1809 transient_entry = new NavigationEntryImpl; |
1806 transient_entry->SetURL(transient_url); | 1810 transient_entry->SetURL(transient_url); |
1807 controller.AddTransientEntry(transient_entry); | 1811 controller.AddTransientEntry(transient_entry); |
1808 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 1812 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
1809 rvh()->SendNavigate(3, url3); | 1813 test_rvh()->SendNavigate(3, url3); |
1810 // Transient entry should be gone. | 1814 // Transient entry should be gone. |
1811 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); | 1815 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); |
1812 EXPECT_EQ(controller.GetEntryCount(), 4); | 1816 EXPECT_EQ(controller.GetEntryCount(), 4); |
1813 | 1817 |
1814 // Initiate a navigation, add a transient then commit navigation. | 1818 // Initiate a navigation, add a transient then commit navigation. |
1815 controller.LoadURL( | 1819 controller.LoadURL( |
1816 url4, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 1820 url4, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
1817 transient_entry = new NavigationEntryImpl; | 1821 transient_entry = new NavigationEntryImpl; |
1818 transient_entry->SetURL(transient_url); | 1822 transient_entry->SetURL(transient_url); |
1819 controller.AddTransientEntry(transient_entry); | 1823 controller.AddTransientEntry(transient_entry); |
1820 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 1824 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
1821 rvh()->SendNavigate(4, url4); | 1825 test_rvh()->SendNavigate(4, url4); |
1822 EXPECT_EQ(url4, controller.GetActiveEntry()->GetURL()); | 1826 EXPECT_EQ(url4, controller.GetActiveEntry()->GetURL()); |
1823 EXPECT_EQ(controller.GetEntryCount(), 5); | 1827 EXPECT_EQ(controller.GetEntryCount(), 5); |
1824 | 1828 |
1825 // Add a transient and go back. This should simply remove the transient. | 1829 // Add a transient and go back. This should simply remove the transient. |
1826 transient_entry = new NavigationEntryImpl; | 1830 transient_entry = new NavigationEntryImpl; |
1827 transient_entry->SetURL(transient_url); | 1831 transient_entry->SetURL(transient_url); |
1828 controller.AddTransientEntry(transient_entry); | 1832 controller.AddTransientEntry(transient_entry); |
1829 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 1833 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
1830 EXPECT_TRUE(controller.CanGoBack()); | 1834 EXPECT_TRUE(controller.CanGoBack()); |
1831 EXPECT_FALSE(controller.CanGoForward()); | 1835 EXPECT_FALSE(controller.CanGoForward()); |
1832 controller.GoBack(); | 1836 controller.GoBack(); |
1833 // Transient entry should be gone. | 1837 // Transient entry should be gone. |
1834 EXPECT_EQ(url4, controller.GetActiveEntry()->GetURL()); | 1838 EXPECT_EQ(url4, controller.GetActiveEntry()->GetURL()); |
1835 EXPECT_EQ(controller.GetEntryCount(), 5); | 1839 EXPECT_EQ(controller.GetEntryCount(), 5); |
1836 rvh()->SendNavigate(3, url3); | 1840 test_rvh()->SendNavigate(3, url3); |
1837 | 1841 |
1838 // Add a transient and go to an entry before the current one. | 1842 // Add a transient and go to an entry before the current one. |
1839 transient_entry = new NavigationEntryImpl; | 1843 transient_entry = new NavigationEntryImpl; |
1840 transient_entry->SetURL(transient_url); | 1844 transient_entry->SetURL(transient_url); |
1841 controller.AddTransientEntry(transient_entry); | 1845 controller.AddTransientEntry(transient_entry); |
1842 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 1846 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
1843 controller.GoToIndex(1); | 1847 controller.GoToIndex(1); |
1844 // The navigation should have been initiated, transient entry should be gone. | 1848 // The navigation should have been initiated, transient entry should be gone. |
1845 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); | 1849 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); |
1846 // Visible entry does not update for history navigations until commit. | 1850 // Visible entry does not update for history navigations until commit. |
1847 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 1851 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
1848 rvh()->SendNavigate(1, url1); | 1852 test_rvh()->SendNavigate(1, url1); |
1849 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1853 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1850 | 1854 |
1851 // Add a transient and go to an entry after the current one. | 1855 // Add a transient and go to an entry after the current one. |
1852 transient_entry = new NavigationEntryImpl; | 1856 transient_entry = new NavigationEntryImpl; |
1853 transient_entry->SetURL(transient_url); | 1857 transient_entry->SetURL(transient_url); |
1854 controller.AddTransientEntry(transient_entry); | 1858 controller.AddTransientEntry(transient_entry); |
1855 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 1859 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
1856 controller.GoToIndex(3); | 1860 controller.GoToIndex(3); |
1857 // The navigation should have been initiated, transient entry should be gone. | 1861 // The navigation should have been initiated, transient entry should be gone. |
1858 // Because of the transient entry that is removed, going to index 3 makes us | 1862 // Because of the transient entry that is removed, going to index 3 makes us |
1859 // land on url2 (which is visible after the commit). | 1863 // land on url2 (which is visible after the commit). |
1860 EXPECT_EQ(url2, controller.GetActiveEntry()->GetURL()); | 1864 EXPECT_EQ(url2, controller.GetActiveEntry()->GetURL()); |
1861 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1865 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1862 rvh()->SendNavigate(2, url2); | 1866 test_rvh()->SendNavigate(2, url2); |
1863 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 1867 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
1864 | 1868 |
1865 // Add a transient and go forward. | 1869 // Add a transient and go forward. |
1866 transient_entry = new NavigationEntryImpl; | 1870 transient_entry = new NavigationEntryImpl; |
1867 transient_entry->SetURL(transient_url); | 1871 transient_entry->SetURL(transient_url); |
1868 controller.AddTransientEntry(transient_entry); | 1872 controller.AddTransientEntry(transient_entry); |
1869 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); | 1873 EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
1870 EXPECT_TRUE(controller.CanGoForward()); | 1874 EXPECT_TRUE(controller.CanGoForward()); |
1871 controller.GoForward(); | 1875 controller.GoForward(); |
1872 // We should have navigated, transient entry should be gone. | 1876 // We should have navigated, transient entry should be gone. |
1873 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); | 1877 EXPECT_EQ(url3, controller.GetActiveEntry()->GetURL()); |
1874 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 1878 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
1875 rvh()->SendNavigate(3, url3); | 1879 test_rvh()->SendNavigate(3, url3); |
1876 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 1880 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
1877 | 1881 |
1878 // Ensure the URLS are correct. | 1882 // Ensure the URLS are correct. |
1879 EXPECT_EQ(controller.GetEntryCount(), 5); | 1883 EXPECT_EQ(controller.GetEntryCount(), 5); |
1880 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); | 1884 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
1881 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); | 1885 EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); |
1882 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); | 1886 EXPECT_EQ(controller.GetEntryAtIndex(2)->GetURL(), url2); |
1883 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3); | 1887 EXPECT_EQ(controller.GetEntryAtIndex(3)->GetURL(), url3); |
1884 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); | 1888 EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); |
1885 } | 1889 } |
1886 | 1890 |
1887 // Tests that the URLs for renderer-initiated navigations are not displayed to | 1891 // Tests that the URLs for renderer-initiated navigations are not displayed to |
1888 // the user until the navigation commits, to prevent URL spoof attacks. | 1892 // the user until the navigation commits, to prevent URL spoof attacks. |
1889 // See http://crbug.com/99016. | 1893 // See http://crbug.com/99016. |
1890 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { | 1894 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { |
1891 NavigationControllerImpl& controller = controller_impl(); | 1895 NavigationControllerImpl& controller = controller_impl(); |
1892 TestNotificationTracker notifications; | 1896 TestNotificationTracker notifications; |
1893 RegisterForAllNavNotifications(¬ifications, &controller); | 1897 RegisterForAllNavNotifications(¬ifications, &controller); |
1894 | 1898 |
1895 const GURL url0("http://foo/0"); | 1899 const GURL url0("http://foo/0"); |
1896 const GURL url1("http://foo/1"); | 1900 const GURL url1("http://foo/1"); |
1897 | 1901 |
1898 // For typed navigations (browser-initiated), both active and visible entries | 1902 // For typed navigations (browser-initiated), both active and visible entries |
1899 // should update before commit. | 1903 // should update before commit. |
1900 controller.LoadURL(url0, content::Referrer(), | 1904 controller.LoadURL(url0, content::Referrer(), |
1901 content::PAGE_TRANSITION_TYPED, std::string()); | 1905 content::PAGE_TRANSITION_TYPED, std::string()); |
1902 EXPECT_EQ(url0, controller.GetActiveEntry()->GetURL()); | 1906 EXPECT_EQ(url0, controller.GetActiveEntry()->GetURL()); |
1903 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); | 1907 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); |
1904 rvh()->SendNavigate(0, url0); | 1908 test_rvh()->SendNavigate(0, url0); |
1905 | 1909 |
1906 // For link clicks (renderer-initiated navigations), the active entry should | 1910 // For link clicks (renderer-initiated navigations), the active entry should |
1907 // update before commit but the visible should not. | 1911 // update before commit but the visible should not. |
1908 controller.LoadURLFromRenderer(url1, content::Referrer(), | 1912 controller.LoadURLFromRenderer(url1, content::Referrer(), |
1909 content::PAGE_TRANSITION_LINK, | 1913 content::PAGE_TRANSITION_LINK, |
1910 std::string()); | 1914 std::string()); |
1911 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); | 1915 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); |
1912 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); | 1916 EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); |
1913 EXPECT_TRUE( | 1917 EXPECT_TRUE( |
1914 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 1918 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
1915 is_renderer_initiated()); | 1919 is_renderer_initiated()); |
1916 | 1920 |
1917 // After commit, both should be updated, and we should no longer treat the | 1921 // After commit, both should be updated, and we should no longer treat the |
1918 // entry as renderer-initiated. | 1922 // entry as renderer-initiated. |
1919 rvh()->SendNavigate(1, url1); | 1923 test_rvh()->SendNavigate(1, url1); |
1920 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); | 1924 EXPECT_EQ(url1, controller.GetActiveEntry()->GetURL()); |
1921 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 1925 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
1922 EXPECT_FALSE( | 1926 EXPECT_FALSE( |
1923 NavigationEntryImpl::FromNavigationEntry( | 1927 NavigationEntryImpl::FromNavigationEntry( |
1924 controller.GetLastCommittedEntry())->is_renderer_initiated()); | 1928 controller.GetLastCommittedEntry())->is_renderer_initiated()); |
1925 | 1929 |
1926 notifications.Reset(); | 1930 notifications.Reset(); |
1927 } | 1931 } |
1928 | 1932 |
1929 // Tests that IsInPageNavigation returns appropriate results. Prevents | 1933 // Tests that IsInPageNavigation returns appropriate results. Prevents |
1930 // regression for bug 1126349. | 1934 // regression for bug 1126349. |
1931 TEST_F(NavigationControllerTest, IsInPageNavigation) { | 1935 TEST_F(NavigationControllerTest, IsInPageNavigation) { |
1932 NavigationControllerImpl& controller = controller_impl(); | 1936 NavigationControllerImpl& controller = controller_impl(); |
1933 // Navigate to URL with no refs. | 1937 // Navigate to URL with no refs. |
1934 const GURL url("http://www.google.com/home.html"); | 1938 const GURL url("http://www.google.com/home.html"); |
1935 rvh()->SendNavigate(0, url); | 1939 test_rvh()->SendNavigate(0, url); |
1936 | 1940 |
1937 // Reloading the page is not an in-page navigation. | 1941 // Reloading the page is not an in-page navigation. |
1938 EXPECT_FALSE(controller.IsURLInPageNavigation(url)); | 1942 EXPECT_FALSE(controller.IsURLInPageNavigation(url)); |
1939 const GURL other_url("http://www.google.com/add.html"); | 1943 const GURL other_url("http://www.google.com/add.html"); |
1940 EXPECT_FALSE(controller.IsURLInPageNavigation(other_url)); | 1944 EXPECT_FALSE(controller.IsURLInPageNavigation(other_url)); |
1941 const GURL url_with_ref("http://www.google.com/home.html#my_ref"); | 1945 const GURL url_with_ref("http://www.google.com/home.html#my_ref"); |
1942 EXPECT_TRUE(controller.IsURLInPageNavigation(url_with_ref)); | 1946 EXPECT_TRUE(controller.IsURLInPageNavigation(url_with_ref)); |
1943 | 1947 |
1944 // Navigate to URL with refs. | 1948 // Navigate to URL with refs. |
1945 rvh()->SendNavigate(1, url_with_ref); | 1949 test_rvh()->SendNavigate(1, url_with_ref); |
1946 | 1950 |
1947 // Reloading the page is not an in-page navigation. | 1951 // Reloading the page is not an in-page navigation. |
1948 EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref)); | 1952 EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref)); |
1949 EXPECT_FALSE(controller.IsURLInPageNavigation(url)); | 1953 EXPECT_FALSE(controller.IsURLInPageNavigation(url)); |
1950 EXPECT_FALSE(controller.IsURLInPageNavigation(other_url)); | 1954 EXPECT_FALSE(controller.IsURLInPageNavigation(other_url)); |
1951 const GURL other_url_with_ref("http://www.google.com/home.html#my_other_ref"); | 1955 const GURL other_url_with_ref("http://www.google.com/home.html#my_other_ref"); |
1952 EXPECT_TRUE(controller.IsURLInPageNavigation( | 1956 EXPECT_TRUE(controller.IsURLInPageNavigation( |
1953 other_url_with_ref)); | 1957 other_url_with_ref)); |
1954 } | 1958 } |
1955 | 1959 |
1956 // Some pages can have subframes with the same base URL (minus the reference) as | 1960 // Some pages can have subframes with the same base URL (minus the reference) as |
1957 // the main page. Even though this is hard, it can happen, and we don't want | 1961 // the main page. Even though this is hard, it can happen, and we don't want |
1958 // these subframe navigations to affect the toplevel document. They should | 1962 // these subframe navigations to affect the toplevel document. They should |
1959 // instead be ignored. http://crbug.com/5585 | 1963 // instead be ignored. http://crbug.com/5585 |
1960 TEST_F(NavigationControllerTest, SameSubframe) { | 1964 TEST_F(NavigationControllerTest, SameSubframe) { |
1961 NavigationControllerImpl& controller = controller_impl(); | 1965 NavigationControllerImpl& controller = controller_impl(); |
1962 // Navigate the main frame. | 1966 // Navigate the main frame. |
1963 const GURL url("http://www.google.com/"); | 1967 const GURL url("http://www.google.com/"); |
1964 rvh()->SendNavigate(0, url); | 1968 test_rvh()->SendNavigate(0, url); |
1965 | 1969 |
1966 // We should be at the first navigation entry. | 1970 // We should be at the first navigation entry. |
1967 EXPECT_EQ(controller.GetEntryCount(), 1); | 1971 EXPECT_EQ(controller.GetEntryCount(), 1); |
1968 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1972 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
1969 | 1973 |
1970 // Navigate a subframe that would normally count as in-page. | 1974 // Navigate a subframe that would normally count as in-page. |
1971 const GURL subframe("http://www.google.com/#"); | 1975 const GURL subframe("http://www.google.com/#"); |
1972 ViewHostMsg_FrameNavigate_Params params; | 1976 ViewHostMsg_FrameNavigate_Params params; |
1973 params.page_id = 0; | 1977 params.page_id = 0; |
1974 params.url = subframe; | 1978 params.url = subframe; |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 | 2360 |
2357 // Test call to PruneAllButActive for transient entry. | 2361 // Test call to PruneAllButActive for transient entry. |
2358 TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { | 2362 TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { |
2359 NavigationControllerImpl& controller = controller_impl(); | 2363 NavigationControllerImpl& controller = controller_impl(); |
2360 const GURL url0("http://foo/0"); | 2364 const GURL url0("http://foo/0"); |
2361 const GURL url1("http://foo/1"); | 2365 const GURL url1("http://foo/1"); |
2362 const GURL transient_url("http://foo/transient"); | 2366 const GURL transient_url("http://foo/transient"); |
2363 | 2367 |
2364 controller.LoadURL( | 2368 controller.LoadURL( |
2365 url0, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 2369 url0, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
2366 rvh()->SendNavigate(0, url0); | 2370 test_rvh()->SendNavigate(0, url0); |
2367 controller.LoadURL( | 2371 controller.LoadURL( |
2368 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 2372 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
2369 rvh()->SendNavigate(1, url1); | 2373 test_rvh()->SendNavigate(1, url1); |
2370 | 2374 |
2371 // Adding a transient with no pending entry. | 2375 // Adding a transient with no pending entry. |
2372 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; | 2376 NavigationEntryImpl* transient_entry = new NavigationEntryImpl; |
2373 transient_entry->SetURL(transient_url); | 2377 transient_entry->SetURL(transient_url); |
2374 controller.AddTransientEntry(transient_entry); | 2378 controller.AddTransientEntry(transient_entry); |
2375 | 2379 |
2376 controller.PruneAllButActive(); | 2380 controller.PruneAllButActive(); |
2377 | 2381 |
2378 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2382 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2379 EXPECT_EQ(controller.GetTransientEntry()->GetURL(), transient_url); | 2383 EXPECT_EQ(controller.GetTransientEntry()->GetURL(), transient_url); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 private: | 2504 private: |
2501 ProfileManager* profile_manager_; | 2505 ProfileManager* profile_manager_; |
2502 FilePath test_dir_; | 2506 FilePath test_dir_; |
2503 }; | 2507 }; |
2504 | 2508 |
2505 // A basic test case. Navigates to a single url, and make sure the history | 2509 // A basic test case. Navigates to a single url, and make sure the history |
2506 // db matches. | 2510 // db matches. |
2507 TEST_F(NavigationControllerHistoryTest, Basic) { | 2511 TEST_F(NavigationControllerHistoryTest, Basic) { |
2508 NavigationControllerImpl& controller = controller_impl(); | 2512 NavigationControllerImpl& controller = controller_impl(); |
2509 controller.LoadURL(url0, GURL(), content::PAGE_TRANSITION_LINK); | 2513 controller.LoadURL(url0, GURL(), content::PAGE_TRANSITION_LINK); |
2510 rvh()->SendNavigate(0, url0); | 2514 test_rvh()->SendNavigate(0, url0); |
2511 | 2515 |
2512 GetLastSession(); | 2516 GetLastSession(); |
2513 | 2517 |
2514 session_helper_.AssertSingleWindowWithSingleTab(windows_, 1); | 2518 session_helper_.AssertSingleWindowWithSingleTab(windows_, 1); |
2515 session_helper_.AssertTabEquals(0, 0, 1, *(windows_[0]->tabs[0])); | 2519 session_helper_.AssertTabEquals(0, 0, 1, *(windows_[0]->tabs[0])); |
2516 TabNavigation nav1(0, url0, GURL(), string16(), | 2520 TabNavigation nav1(0, url0, GURL(), string16(), |
2517 webkit_glue::CreateHistoryStateForURL(url0), | 2521 webkit_glue::CreateHistoryStateForURL(url0), |
2518 content::PAGE_TRANSITION_LINK); | 2522 content::PAGE_TRANSITION_LINK); |
2519 session_helper_.AssertNavigationEquals(nav1, | 2523 session_helper_.AssertNavigationEquals(nav1, |
2520 windows_[0]->tabs[0]->navigations[0]); | 2524 windows_[0]->tabs[0]->navigations[0]); |
2521 } | 2525 } |
2522 | 2526 |
2523 // Navigates to three urls, then goes back and make sure the history database | 2527 // Navigates to three urls, then goes back and make sure the history database |
2524 // is in sync. | 2528 // is in sync. |
2525 TEST_F(NavigationControllerHistoryTest, NavigationThenBack) { | 2529 TEST_F(NavigationControllerHistoryTest, NavigationThenBack) { |
2526 NavigationControllerImpl& controller = controller_impl(); | 2530 NavigationControllerImpl& controller = controller_impl(); |
2527 rvh()->SendNavigate(0, url0); | 2531 test_rvh()->SendNavigate(0, url0); |
2528 rvh()->SendNavigate(1, url1); | 2532 test_rvh()->SendNavigate(1, url1); |
2529 rvh()->SendNavigate(2, url2); | 2533 test_rvh()->SendNavigate(2, url2); |
2530 | 2534 |
2531 controller.GoBack(); | 2535 controller.GoBack(); |
2532 rvh()->SendNavigate(1, url1); | 2536 test_rvh()->SendNavigate(1, url1); |
2533 | 2537 |
2534 GetLastSession(); | 2538 GetLastSession(); |
2535 | 2539 |
2536 session_helper_.AssertSingleWindowWithSingleTab(windows_, 3); | 2540 session_helper_.AssertSingleWindowWithSingleTab(windows_, 3); |
2537 session_helper_.AssertTabEquals(0, 1, 3, *(windows_[0]->tabs[0])); | 2541 session_helper_.AssertTabEquals(0, 1, 3, *(windows_[0]->tabs[0])); |
2538 | 2542 |
2539 TabNavigation nav(0, url0, GURL(), string16(), | 2543 TabNavigation nav(0, url0, GURL(), string16(), |
2540 webkit_glue::CreateHistoryStateForURL(url0), | 2544 webkit_glue::CreateHistoryStateForURL(url0), |
2541 content::PAGE_TRANSITION_LINK); | 2545 content::PAGE_TRANSITION_LINK); |
2542 session_helper_.AssertNavigationEquals(nav, | 2546 session_helper_.AssertNavigationEquals(nav, |
2543 windows_[0]->tabs[0]->navigations[0]); | 2547 windows_[0]->tabs[0]->navigations[0]); |
2544 nav.set_url(url1); | 2548 nav.set_url(url1); |
2545 session_helper_.AssertNavigationEquals(nav, | 2549 session_helper_.AssertNavigationEquals(nav, |
2546 windows_[0]->tabs[0]->navigations[1]); | 2550 windows_[0]->tabs[0]->navigations[1]); |
2547 nav.set_url(url2); | 2551 nav.set_url(url2); |
2548 session_helper_.AssertNavigationEquals(nav, | 2552 session_helper_.AssertNavigationEquals(nav, |
2549 windows_[0]->tabs[0]->navigations[2]); | 2553 windows_[0]->tabs[0]->navigations[2]); |
2550 } | 2554 } |
2551 | 2555 |
2552 // Navigates to three urls, then goes back twice, then loads a new url. | 2556 // Navigates to three urls, then goes back twice, then loads a new url. |
2553 TEST_F(NavigationControllerHistoryTest, NavigationPruning) { | 2557 TEST_F(NavigationControllerHistoryTest, NavigationPruning) { |
2554 NavigationControllerImpl& controller = controller_impl(); | 2558 NavigationControllerImpl& controller = controller_impl(); |
2555 rvh()->SendNavigate(0, url0); | 2559 test_rvh()->SendNavigate(0, url0); |
2556 rvh()->SendNavigate(1, url1); | 2560 test_rvh()->SendNavigate(1, url1); |
2557 rvh()->SendNavigate(2, url2); | 2561 test_rvh()->SendNavigate(2, url2); |
2558 | 2562 |
2559 controller.GoBack(); | 2563 controller.GoBack(); |
2560 rvh()->SendNavigate(1, url1); | 2564 test_rvh()->SendNavigate(1, url1); |
2561 | 2565 |
2562 controller.GoBack(); | 2566 controller.GoBack(); |
2563 rvh()->SendNavigate(0, url0); | 2567 test_rvh()->SendNavigate(0, url0); |
2564 | 2568 |
2565 rvh()->SendNavigate(3, url2); | 2569 test_rvh()->SendNavigate(3, url2); |
2566 | 2570 |
2567 // Now have url0, and url2. | 2571 // Now have url0, and url2. |
2568 | 2572 |
2569 GetLastSession(); | 2573 GetLastSession(); |
2570 | 2574 |
2571 session_helper_.AssertSingleWindowWithSingleTab(windows_, 2); | 2575 session_helper_.AssertSingleWindowWithSingleTab(windows_, 2); |
2572 session_helper_.AssertTabEquals(0, 1, 2, *(windows_[0]->tabs[0])); | 2576 session_helper_.AssertTabEquals(0, 1, 2, *(windows_[0]->tabs[0])); |
2573 | 2577 |
2574 TabNavigation nav(0, url0, GURL(), string16(), | 2578 TabNavigation nav(0, url0, GURL(), string16(), |
2575 webkit_glue::CreateHistoryStateForURL(url0), | 2579 webkit_glue::CreateHistoryStateForURL(url0), |
2576 content::PAGE_TRANSITION_LINK); | 2580 content::PAGE_TRANSITION_LINK); |
2577 session_helper_.AssertNavigationEquals(nav, | 2581 session_helper_.AssertNavigationEquals(nav, |
2578 windows_[0]->tabs[0]->navigations[0]); | 2582 windows_[0]->tabs[0]->navigations[0]); |
2579 nav.set_url(url2); | 2583 nav.set_url(url2); |
2580 session_helper_.AssertNavigationEquals(nav, | 2584 session_helper_.AssertNavigationEquals(nav, |
2581 windows_[0]->tabs[0]->navigations[1]); | 2585 windows_[0]->tabs[0]->navigations[1]); |
2582 } | 2586 } |
2583 */ | 2587 */ |
OLD | NEW |