| 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 3347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3358 | 3358 |
| 3359 // Make sure the renderer is still alive. | 3359 // Make sure the renderer is still alive. |
| 3360 EXPECT_TRUE( | 3360 EXPECT_TRUE( |
| 3361 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 3361 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
| 3362 } | 3362 } |
| 3363 | 3363 |
| 3364 // This tests that 1) the initial "about:blank" URL is elided from the | 3364 // This tests that 1) the initial "about:blank" URL is elided from the |
| 3365 // navigation history of a subframe when it is loaded, and 2) that that initial | 3365 // navigation history of a subframe when it is loaded, and 2) that that initial |
| 3366 // "about:blank" returns if it is navigated to as part of a history navigation. | 3366 // "about:blank" returns if it is navigated to as part of a history navigation. |
| 3367 // See http://crbug.com/542299 and https://github.com/whatwg/html/issues/546 . | 3367 // See http://crbug.com/542299 and https://github.com/whatwg/html/issues/546 . |
| 3368 // TODO(avi, creis): This test is partially neutered; fix it. |
| 3368 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3369 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 3369 BackToAboutBlankIframe) { | 3370 BackToAboutBlankIframe) { |
| 3370 GURL original_url(embedded_test_server()->GetURL( | 3371 GURL original_url(embedded_test_server()->GetURL( |
| 3371 "/navigation_controller/simple_page_1.html")); | 3372 "/navigation_controller/simple_page_1.html")); |
| 3372 NavigateToURL(shell(), original_url); | 3373 NavigateToURL(shell(), original_url); |
| 3373 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3374 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3374 | 3375 |
| 3375 NavigationController& controller = shell()->web_contents()->GetController(); | 3376 NavigationController& controller = shell()->web_contents()->GetController(); |
| 3376 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3377 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 3377 ->GetFrameTree() | 3378 ->GetFrameTree() |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3417 "/navigation_controller/simple_page_2.html"); | 3418 "/navigation_controller/simple_page_2.html"); |
| 3418 NavigateFrameToURL(frame, frame_url); | 3419 NavigateFrameToURL(frame, frame_url); |
| 3419 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3420 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3420 | 3421 |
| 3421 EXPECT_EQ(2, controller.GetEntryCount()); | 3422 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3422 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3423 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 3423 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3424 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 3424 | 3425 |
| 3425 EXPECT_EQ(frame_url, frame->current_url()); | 3426 EXPECT_EQ(frame_url, frame->current_url()); |
| 3426 | 3427 |
| 3428 // At this point the rest of the test is inapplicable. The bug that it tests |
| 3429 // to be gone had to be reintroduced. |
| 3430 // |
| 3431 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for |
| 3432 // more information. |
| 3433 |
| 3434 #if 0 |
| 3427 // Go back. Because the old state had an empty frame, that should be restored | 3435 // Go back. Because the old state had an empty frame, that should be restored |
| 3428 // even though it was replaced in the second navigation entry. | 3436 // even though it was replaced in the second navigation entry. |
| 3429 | 3437 |
| 3430 TestFrameNavigationObserver observer(frame); | 3438 TestFrameNavigationObserver observer(frame); |
| 3431 ASSERT_TRUE(controller.CanGoBack()); | 3439 ASSERT_TRUE(controller.CanGoBack()); |
| 3432 controller.GoBack(); | 3440 controller.GoBack(); |
| 3433 observer.Wait(); | 3441 observer.Wait(); |
| 3434 | 3442 |
| 3435 EXPECT_EQ(2, controller.GetEntryCount()); | 3443 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3436 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3444 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 3437 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3445 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 3438 | 3446 |
| 3439 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url()); | 3447 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url()); |
| 3448 #endif |
| 3440 } | 3449 } |
| 3441 | 3450 |
| 3442 // This test is similar to "BackToAboutBlankIframe" above, except that a | 3451 // This test is similar to "BackToAboutBlankIframe" above, except that a |
| 3443 // fragment navigation is used rather than pushState (both create an in-page | 3452 // fragment navigation is used rather than pushState (both create an in-page |
| 3444 // navigation, so we need to test both), and an initial 'src' is given to the | 3453 // navigation, so we need to test both), and an initial 'src' is given to the |
| 3445 // iframe to test proper restoration in that case. | 3454 // iframe to test proper restoration in that case. |
| 3455 // TODO(avi, creis): This test is partially neutered; fix it. |
| 3446 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3456 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 3447 BackToIframeWithContent) { | 3457 BackToIframeWithContent) { |
| 3448 GURL links_url(embedded_test_server()->GetURL( | 3458 GURL links_url(embedded_test_server()->GetURL( |
| 3449 "/navigation_controller/page_with_links.html")); | 3459 "/navigation_controller/page_with_links.html")); |
| 3450 NavigateToURL(shell(), links_url); | 3460 NavigateToURL(shell(), links_url); |
| 3451 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3461 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3452 | 3462 |
| 3453 NavigationController& controller = shell()->web_contents()->GetController(); | 3463 NavigationController& controller = shell()->web_contents()->GetController(); |
| 3454 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3464 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 3455 ->GetFrameTree() | 3465 ->GetFrameTree() |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3500 "/navigation_controller/simple_page_2.html"); | 3510 "/navigation_controller/simple_page_2.html"); |
| 3501 NavigateFrameToURL(frame, frame_url_2); | 3511 NavigateFrameToURL(frame, frame_url_2); |
| 3502 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3512 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3503 | 3513 |
| 3504 EXPECT_EQ(3, controller.GetEntryCount()); | 3514 EXPECT_EQ(3, controller.GetEntryCount()); |
| 3505 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3515 EXPECT_EQ(3, RendererHistoryLength(shell())); |
| 3506 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3516 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 3507 | 3517 |
| 3508 EXPECT_EQ(frame_url_2, frame->current_url()); | 3518 EXPECT_EQ(frame_url_2, frame->current_url()); |
| 3509 | 3519 |
| 3520 // At this point the rest of the test is inapplicable. The bug that it tests |
| 3521 // to be gone had to be reintroduced. |
| 3522 // |
| 3523 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for |
| 3524 // more information. |
| 3525 |
| 3526 #if 0 |
| 3510 // Go back two entries. The original frame URL should be back. | 3527 // Go back two entries. The original frame URL should be back. |
| 3511 | 3528 |
| 3512 TestFrameNavigationObserver observer(frame); | 3529 TestFrameNavigationObserver observer(frame); |
| 3513 ASSERT_TRUE(controller.CanGoToOffset(-2)); | 3530 ASSERT_TRUE(controller.CanGoToOffset(-2)); |
| 3514 controller.GoToOffset(-2); | 3531 controller.GoToOffset(-2); |
| 3515 observer.Wait(); | 3532 observer.Wait(); |
| 3516 | 3533 |
| 3517 EXPECT_EQ(3, controller.GetEntryCount()); | 3534 EXPECT_EQ(3, controller.GetEntryCount()); |
| 3518 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3535 EXPECT_EQ(3, RendererHistoryLength(shell())); |
| 3519 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3536 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 3520 | 3537 |
| 3521 EXPECT_EQ(frame_url_1, frame->current_url()); | 3538 EXPECT_EQ(frame_url_1, frame->current_url()); |
| 3539 #endif |
| 3522 } | 3540 } |
| 3523 | 3541 |
| 3524 // Ensure that we do not corrupt a NavigationEntry's PageState if a subframe | 3542 // Ensure that we do not corrupt a NavigationEntry's PageState if a subframe |
| 3525 // forward navigation commits after we've already started another forward | 3543 // forward navigation commits after we've already started another forward |
| 3526 // navigation in the main frame. See https://crbug.com/597322. | 3544 // navigation in the main frame. See https://crbug.com/597322. |
| 3527 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3545 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 3528 ForwardInSubframeWithPendingForward) { | 3546 ForwardInSubframeWithPendingForward) { |
| 3529 // Navigate to a page with an iframe. | 3547 // Navigate to a page with an iframe. |
| 3530 GURL url_a(embedded_test_server()->GetURL( | 3548 GURL url_a(embedded_test_server()->GetURL( |
| 3531 "/navigation_controller/page_with_data_iframe.html")); | 3549 "/navigation_controller/page_with_data_iframe.html")); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3660 { | 3678 { |
| 3661 TestNavigationObserver observer(new_tab.get()); | 3679 TestNavigationObserver observer(new_tab.get()); |
| 3662 new_controller.GoForward(); | 3680 new_controller.GoForward(); |
| 3663 observer.Wait(); | 3681 observer.Wait(); |
| 3664 } | 3682 } |
| 3665 EXPECT_TRUE(new_root->current_frame_host()->IsRenderFrameLive()); | 3683 EXPECT_TRUE(new_root->current_frame_host()->IsRenderFrameLive()); |
| 3666 EXPECT_EQ(url_3, new_root->current_url()); | 3684 EXPECT_EQ(url_3, new_root->current_url()); |
| 3667 } | 3685 } |
| 3668 | 3686 |
| 3669 } // namespace content | 3687 } // namespace content |
| OLD | NEW |