Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 1949213002: Don't update subframes on parent frame commits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3485 matching lines...) Expand 10 before | Expand all | Expand 10 after
3496 3496
3497 // Make sure the renderer is still alive. 3497 // Make sure the renderer is still alive.
3498 EXPECT_TRUE( 3498 EXPECT_TRUE(
3499 ExecuteScript(shell()->web_contents(), "console.log('Success');")); 3499 ExecuteScript(shell()->web_contents(), "console.log('Success');"));
3500 } 3500 }
3501 3501
3502 // This tests that 1) the initial "about:blank" URL is elided from the 3502 // This tests that 1) the initial "about:blank" URL is elided from the
3503 // navigation history of a subframe when it is loaded, and 2) that that initial 3503 // navigation history of a subframe when it is loaded, and 2) that that initial
3504 // "about:blank" returns if it is navigated to as part of a history navigation. 3504 // "about:blank" returns if it is navigated to as part of a history navigation.
3505 // See http://crbug.com/542299 and https://github.com/whatwg/html/issues/546 . 3505 // See http://crbug.com/542299 and https://github.com/whatwg/html/issues/546 .
3506 // TODO(avi, creis): This test is partially neutered; fix it.
3506 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 3507 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3507 BackToAboutBlankIframe) { 3508 BackToAboutBlankIframe) {
3508 GURL original_url(embedded_test_server()->GetURL( 3509 GURL original_url(embedded_test_server()->GetURL(
3509 "/navigation_controller/simple_page_1.html")); 3510 "/navigation_controller/simple_page_1.html"));
3510 NavigateToURL(shell(), original_url); 3511 NavigateToURL(shell(), original_url);
3511 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 3512 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3512 3513
3513 NavigationController& controller = shell()->web_contents()->GetController(); 3514 NavigationController& controller = shell()->web_contents()->GetController();
3514 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3515 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
3515 ->GetFrameTree() 3516 ->GetFrameTree()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 "/navigation_controller/simple_page_2.html"); 3556 "/navigation_controller/simple_page_2.html");
3556 NavigateFrameToURL(frame, frame_url); 3557 NavigateFrameToURL(frame, frame_url);
3557 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 3558 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3558 3559
3559 EXPECT_EQ(2, controller.GetEntryCount()); 3560 EXPECT_EQ(2, controller.GetEntryCount());
3560 EXPECT_EQ(2, RendererHistoryLength(shell())); 3561 EXPECT_EQ(2, RendererHistoryLength(shell()));
3561 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 3562 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3562 3563
3563 EXPECT_EQ(frame_url, frame->current_url()); 3564 EXPECT_EQ(frame_url, frame->current_url());
3564 3565
3566 // At this point the rest of the test is inapplicable. The bug that it tests
3567 // to be gone had to be reintroduced.
3568 //
3569 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for
3570 // more information.
3571
3572 #if 0
3565 // Go back. Because the old state had an empty frame, that should be restored 3573 // Go back. Because the old state had an empty frame, that should be restored
3566 // even though it was replaced in the second navigation entry. 3574 // even though it was replaced in the second navigation entry.
3567 3575
3568 TestFrameNavigationObserver observer(frame); 3576 TestFrameNavigationObserver observer(frame);
3569 ASSERT_TRUE(controller.CanGoBack()); 3577 ASSERT_TRUE(controller.CanGoBack());
3570 controller.GoBack(); 3578 controller.GoBack();
3571 observer.Wait(); 3579 observer.Wait();
3572 3580
3573 EXPECT_EQ(2, controller.GetEntryCount()); 3581 EXPECT_EQ(2, controller.GetEntryCount());
3574 EXPECT_EQ(2, RendererHistoryLength(shell())); 3582 EXPECT_EQ(2, RendererHistoryLength(shell()));
3575 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 3583 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3576 3584
3577 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url()); 3585 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url());
3586 #endif
3578 } 3587 }
3579 3588
3580 // This test is similar to "BackToAboutBlankIframe" above, except that a 3589 // This test is similar to "BackToAboutBlankIframe" above, except that a
3581 // fragment navigation is used rather than pushState (both create an in-page 3590 // fragment navigation is used rather than pushState (both create an in-page
3582 // navigation, so we need to test both), and an initial 'src' is given to the 3591 // navigation, so we need to test both), and an initial 'src' is given to the
3583 // iframe to test proper restoration in that case. 3592 // iframe to test proper restoration in that case.
3593 // TODO(avi, creis): This test is partially neutered; fix it.
3584 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 3594 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3585 BackToIframeWithContent) { 3595 BackToIframeWithContent) {
3586 GURL links_url(embedded_test_server()->GetURL( 3596 GURL links_url(embedded_test_server()->GetURL(
3587 "/navigation_controller/page_with_links.html")); 3597 "/navigation_controller/page_with_links.html"));
3588 NavigateToURL(shell(), links_url); 3598 NavigateToURL(shell(), links_url);
3589 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 3599 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3590 3600
3591 NavigationController& controller = shell()->web_contents()->GetController(); 3601 NavigationController& controller = shell()->web_contents()->GetController();
3592 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3602 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
3593 ->GetFrameTree() 3603 ->GetFrameTree()
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 "/navigation_controller/simple_page_2.html"); 3648 "/navigation_controller/simple_page_2.html");
3639 NavigateFrameToURL(frame, frame_url_2); 3649 NavigateFrameToURL(frame, frame_url_2);
3640 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 3650 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3641 3651
3642 EXPECT_EQ(3, controller.GetEntryCount()); 3652 EXPECT_EQ(3, controller.GetEntryCount());
3643 EXPECT_EQ(3, RendererHistoryLength(shell())); 3653 EXPECT_EQ(3, RendererHistoryLength(shell()));
3644 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 3654 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
3645 3655
3646 EXPECT_EQ(frame_url_2, frame->current_url()); 3656 EXPECT_EQ(frame_url_2, frame->current_url());
3647 3657
3658 // At this point the rest of the test is inapplicable. The bug that it tests
3659 // to be gone had to be reintroduced.
3660 //
3661 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for
3662 // more information.
3663
3664 #if 0
3648 // Go back two entries. The original frame URL should be back. 3665 // Go back two entries. The original frame URL should be back.
3649 3666
3650 TestFrameNavigationObserver observer(frame); 3667 TestFrameNavigationObserver observer(frame);
3651 ASSERT_TRUE(controller.CanGoToOffset(-2)); 3668 ASSERT_TRUE(controller.CanGoToOffset(-2));
3652 controller.GoToOffset(-2); 3669 controller.GoToOffset(-2);
3653 observer.Wait(); 3670 observer.Wait();
3654 3671
3655 EXPECT_EQ(3, controller.GetEntryCount()); 3672 EXPECT_EQ(3, controller.GetEntryCount());
3656 EXPECT_EQ(3, RendererHistoryLength(shell())); 3673 EXPECT_EQ(3, RendererHistoryLength(shell()));
3657 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 3674 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3658 3675
3659 EXPECT_EQ(frame_url_1, frame->current_url()); 3676 EXPECT_EQ(frame_url_1, frame->current_url());
3677 #endif
3660 } 3678 }
3661 3679
3662 // Ensure that we do not corrupt a NavigationEntry's PageState if a subframe 3680 // Ensure that we do not corrupt a NavigationEntry's PageState if a subframe
3663 // forward navigation commits after we've already started another forward 3681 // forward navigation commits after we've already started another forward
3664 // navigation in the main frame. See https://crbug.com/597322. 3682 // navigation in the main frame. See https://crbug.com/597322.
3665 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 3683 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3666 ForwardInSubframeWithPendingForward) { 3684 ForwardInSubframeWithPendingForward) {
3667 // Navigate to a page with an iframe. 3685 // Navigate to a page with an iframe.
3668 GURL url_a(embedded_test_server()->GetURL( 3686 GURL url_a(embedded_test_server()->GetURL(
3669 "/navigation_controller/page_with_data_iframe.html")); 3687 "/navigation_controller/page_with_data_iframe.html"));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3857 // TODO(clamy): Check the post id as well when PlzNavigate handles it 3875 // TODO(clamy): Check the post id as well when PlzNavigate handles it
3858 // properly. 3876 // properly.
3859 if (!IsBrowserSideNavigationEnabled()) 3877 if (!IsBrowserSideNavigationEnabled())
3860 EXPECT_NE(-1, frame_entry->post_id()); 3878 EXPECT_NE(-1, frame_entry->post_id());
3861 EXPECT_FALSE(entry->GetHasPostData()); 3879 EXPECT_FALSE(entry->GetHasPostData());
3862 EXPECT_EQ(-1, entry->GetPostID()); 3880 EXPECT_EQ(-1, entry->GetPostID());
3863 } 3881 }
3864 } 3882 }
3865 3883
3866 } // namespace content 3884 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/renderer/history_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698