| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3270 | 3270 |
| 3271 // Make sure the renderer is still alive. | 3271 // Make sure the renderer is still alive. |
| 3272 EXPECT_TRUE( | 3272 EXPECT_TRUE( |
| 3273 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 3273 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
| 3274 } | 3274 } |
| 3275 | 3275 |
| 3276 // This tests that 1) the initial "about:blank" URL is elided from the | 3276 // This tests that 1) the initial "about:blank" URL is elided from the |
| 3277 // navigation history of a subframe when it is loaded, and 2) that that initial | 3277 // navigation history of a subframe when it is loaded, and 2) that that initial |
| 3278 // "about:blank" returns if it is navigated to as part of a history navigation. | 3278 // "about:blank" returns if it is navigated to as part of a history navigation. |
| 3279 // See http://crbug.com/542299 and https://github.com/whatwg/html/issues/546 . | 3279 // See http://crbug.com/542299 and https://github.com/whatwg/html/issues/546 . |
| 3280 // TODO(avi, creis): This test is partially neutered; fix it. |
| 3280 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3281 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 3281 BackToAboutBlankIframe) { | 3282 BackToAboutBlankIframe) { |
| 3282 GURL original_url(embedded_test_server()->GetURL( | 3283 GURL original_url(embedded_test_server()->GetURL( |
| 3283 "/navigation_controller/simple_page_1.html")); | 3284 "/navigation_controller/simple_page_1.html")); |
| 3284 NavigateToURL(shell(), original_url); | 3285 NavigateToURL(shell(), original_url); |
| 3285 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3286 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3286 | 3287 |
| 3287 NavigationController& controller = shell()->web_contents()->GetController(); | 3288 NavigationController& controller = shell()->web_contents()->GetController(); |
| 3288 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3289 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 3289 ->GetFrameTree() | 3290 ->GetFrameTree() |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3329 "/navigation_controller/simple_page_2.html"); | 3330 "/navigation_controller/simple_page_2.html"); |
| 3330 NavigateFrameToURL(frame, frame_url); | 3331 NavigateFrameToURL(frame, frame_url); |
| 3331 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3332 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3332 | 3333 |
| 3333 EXPECT_EQ(2, controller.GetEntryCount()); | 3334 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3334 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3335 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 3335 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3336 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 3336 | 3337 |
| 3337 EXPECT_EQ(frame_url, frame->current_url()); | 3338 EXPECT_EQ(frame_url, frame->current_url()); |
| 3338 | 3339 |
| 3340 // At this point the rest of the test is inapplicable. The bug that it tests |
| 3341 // to be gone had to be reintroduced. |
| 3342 // |
| 3343 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for |
| 3344 // more information. |
| 3345 |
| 3346 #if 0 |
| 3339 // Go back. Because the old state had an empty frame, that should be restored | 3347 // Go back. Because the old state had an empty frame, that should be restored |
| 3340 // even though it was replaced in the second navigation entry. | 3348 // even though it was replaced in the second navigation entry. |
| 3341 | 3349 |
| 3342 TestFrameNavigationObserver observer(frame); | 3350 TestFrameNavigationObserver observer(frame); |
| 3343 ASSERT_TRUE(controller.CanGoBack()); | 3351 ASSERT_TRUE(controller.CanGoBack()); |
| 3344 controller.GoBack(); | 3352 controller.GoBack(); |
| 3345 observer.Wait(); | 3353 observer.Wait(); |
| 3346 | 3354 |
| 3347 EXPECT_EQ(2, controller.GetEntryCount()); | 3355 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3348 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3356 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 3349 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3357 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 3350 | 3358 |
| 3351 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url()); | 3359 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url()); |
| 3360 #endif |
| 3352 } | 3361 } |
| 3353 | 3362 |
| 3354 // This test is similar to "BackToAboutBlankIframe" above, except that a | 3363 // This test is similar to "BackToAboutBlankIframe" above, except that a |
| 3355 // fragment navigation is used rather than pushState (both create an in-page | 3364 // fragment navigation is used rather than pushState (both create an in-page |
| 3356 // navigation, so we need to test both), and an initial 'src' is given to the | 3365 // navigation, so we need to test both), and an initial 'src' is given to the |
| 3357 // iframe to test proper restoration in that case. | 3366 // iframe to test proper restoration in that case. |
| 3367 // TODO(avi, creis): This test is partially neutered; fix it. |
| 3358 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3368 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 3359 BackToIframeWithContent) { | 3369 BackToIframeWithContent) { |
| 3360 GURL links_url(embedded_test_server()->GetURL( | 3370 GURL links_url(embedded_test_server()->GetURL( |
| 3361 "/navigation_controller/page_with_links.html")); | 3371 "/navigation_controller/page_with_links.html")); |
| 3362 NavigateToURL(shell(), links_url); | 3372 NavigateToURL(shell(), links_url); |
| 3363 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3373 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3364 | 3374 |
| 3365 NavigationController& controller = shell()->web_contents()->GetController(); | 3375 NavigationController& controller = shell()->web_contents()->GetController(); |
| 3366 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3376 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 3367 ->GetFrameTree() | 3377 ->GetFrameTree() |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3412 "/navigation_controller/simple_page_2.html"); | 3422 "/navigation_controller/simple_page_2.html"); |
| 3413 NavigateFrameToURL(frame, frame_url_2); | 3423 NavigateFrameToURL(frame, frame_url_2); |
| 3414 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3424 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3415 | 3425 |
| 3416 EXPECT_EQ(3, controller.GetEntryCount()); | 3426 EXPECT_EQ(3, controller.GetEntryCount()); |
| 3417 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3427 EXPECT_EQ(3, RendererHistoryLength(shell())); |
| 3418 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3428 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 3419 | 3429 |
| 3420 EXPECT_EQ(frame_url_2, frame->current_url()); | 3430 EXPECT_EQ(frame_url_2, frame->current_url()); |
| 3421 | 3431 |
| 3432 // At this point the rest of the test is inapplicable. The bug that it tests |
| 3433 // to be gone had to be reintroduced. |
| 3434 // |
| 3435 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for |
| 3436 // more information. |
| 3437 |
| 3438 #if 0 |
| 3422 // Go back two entries. The original frame URL should be back. | 3439 // Go back two entries. The original frame URL should be back. |
| 3423 | 3440 |
| 3424 TestFrameNavigationObserver observer(frame); | 3441 TestFrameNavigationObserver observer(frame); |
| 3425 ASSERT_TRUE(controller.CanGoToOffset(-2)); | 3442 ASSERT_TRUE(controller.CanGoToOffset(-2)); |
| 3426 controller.GoToOffset(-2); | 3443 controller.GoToOffset(-2); |
| 3427 observer.Wait(); | 3444 observer.Wait(); |
| 3428 | 3445 |
| 3429 EXPECT_EQ(3, controller.GetEntryCount()); | 3446 EXPECT_EQ(3, controller.GetEntryCount()); |
| 3430 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3447 EXPECT_EQ(3, RendererHistoryLength(shell())); |
| 3431 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3448 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 3432 | 3449 |
| 3433 EXPECT_EQ(frame_url_1, frame->current_url()); | 3450 EXPECT_EQ(frame_url_1, frame->current_url()); |
| 3451 #endif |
| 3434 } | 3452 } |
| 3435 | 3453 |
| 3436 } // namespace content | 3454 } // namespace content |
| OLD | NEW |