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

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

Issue 1848813005: Fix HistoryEntry corruption when commit isn't for provisional entry (try #2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/browser/frame_host/frame_navigation_entry.h" 15 #include "content/browser/frame_host/frame_navigation_entry.h"
16 #include "content/browser/frame_host/frame_tree.h" 16 #include "content/browser/frame_host/frame_tree.h"
17 #include "content/browser/frame_host/navigation_entry_impl.h" 17 #include "content/browser/frame_host/navigation_entry_impl.h"
18 #include "content/browser/loader/resource_dispatcher_host_impl.h" 18 #include "content/browser/loader/resource_dispatcher_host_impl.h"
19 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
20 #include "content/common/page_state_serialization.h"
20 #include "content/common/site_isolation_policy.h" 21 #include "content/common/site_isolation_policy.h"
21 #include "content/public/browser/navigation_handle.h" 22 #include "content/public/browser/navigation_handle.h"
22 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/resource_controller.h" 24 #include "content/public/browser/resource_controller.h"
24 #include "content/public/browser/resource_dispatcher_host.h" 25 #include "content/public/browser/resource_dispatcher_host.h"
25 #include "content/public/browser/resource_dispatcher_host_delegate.h" 26 #include "content/public/browser/resource_dispatcher_host_delegate.h"
26 #include "content/public/browser/resource_throttle.h" 27 #include "content/public/browser/resource_throttle.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_contents_observer.h" 29 #include "content/public/browser/web_contents_observer.h"
29 #include "content/public/common/bindings_policy.h" 30 #include "content/public/common/bindings_policy.h"
(...skipping 3484 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 controller.GoToOffset(-2); 3515 controller.GoToOffset(-2);
3515 observer.Wait(); 3516 observer.Wait();
3516 3517
3517 EXPECT_EQ(3, controller.GetEntryCount()); 3518 EXPECT_EQ(3, controller.GetEntryCount());
3518 EXPECT_EQ(3, RendererHistoryLength(shell())); 3519 EXPECT_EQ(3, RendererHistoryLength(shell()));
3519 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 3520 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3520 3521
3521 EXPECT_EQ(frame_url_1, frame->current_url()); 3522 EXPECT_EQ(frame_url_1, frame->current_url());
3522 } 3523 }
3523 3524
3525 // Ensure that we do not corrupt a NavigationEntry's PageState if a subframe
3526 // forward navigation commits after we've already started another forward
3527 // navigation in the main frame. See https://crbug.com/597322.
3528 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3529 ForwardInSubframeWithPendingForward) {
3530 // Navigate to a page with an iframe.
3531 GURL url_a(embedded_test_server()->GetURL(
3532 "/navigation_controller/page_with_data_iframe.html"));
3533 GURL frame_url_a1("data:text/html,Subframe");
3534 NavigateToURL(shell(), url_a);
3535 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3536
3537 NavigationController& controller = shell()->web_contents()->GetController();
3538 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
3539 ->GetFrameTree()
3540 ->root();
3541 ASSERT_EQ(1U, root->child_count());
3542 EXPECT_EQ(url_a, root->current_url());
3543 FrameTreeNode* frame = root->child_at(0);
3544 ASSERT_NE(nullptr, frame);
3545 EXPECT_EQ(frame_url_a1, frame->current_url());
3546
3547 // Navigate the iframe to a second page.
3548 GURL frame_url_a2 = embedded_test_server()->GetURL(
3549 "/navigation_controller/simple_page_1.html");
3550 NavigateFrameToURL(frame, frame_url_a2);
3551 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3552
3553 EXPECT_EQ(2, controller.GetEntryCount());
3554 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3555 EXPECT_EQ(url_a, root->current_url());
3556 EXPECT_EQ(frame_url_a2, frame->current_url());
3557
3558 // Navigate the top-level frame to another page with an iframe.
3559 GURL url_b(embedded_test_server()->GetURL(
3560 "/navigation_controller/page_with_iframe.html"));
3561 GURL frame_url_b1(url::kAboutBlankURL);
3562 NavigateToURL(shell(), url_b);
3563 EXPECT_EQ(3, controller.GetEntryCount());
3564 EXPECT_EQ(url_b, root->current_url());
3565 EXPECT_EQ(frame_url_b1, root->child_at(0)->current_url());
3566
3567 // Go back two entries. The original frame URL should be back.
3568 ASSERT_TRUE(controller.CanGoToOffset(-2));
3569 controller.GoToOffset(-2);
3570 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3571
3572 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3573 EXPECT_EQ(url_a, root->current_url());
3574 EXPECT_EQ(frame_url_a1, root->child_at(0)->current_url());
3575
3576 // Go forward two times in a row, being careful that the subframe commits
3577 // after the second forward navigation begins but before the main frame
3578 // commits.
3579 TestNavigationManager subframe_delayer(shell()->web_contents(), frame_url_a2);
Charlie Reis 2016/04/01 17:28:15 This TestNavigationManager class is being introduc
alexmos 2016/04/02 00:18:54 Acknowledged. Looks like it landed now. It's gre
3580 TestNavigationManager mainframe_delayer(shell()->web_contents(), url_b);
3581 controller.GoForward();
3582 subframe_delayer.WaitForWillStartRequest();
3583 controller.GoForward();
3584 mainframe_delayer.WaitForWillStartRequest();
3585 EXPECT_EQ(2, controller.GetPendingEntryIndex());
3586
3587 // Let the subframe commit.
3588 subframe_delayer.ResumeNavigation();
3589 subframe_delayer.WaitForNavigationFinished();
3590 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3591 EXPECT_EQ(url_a, root->current_url());
3592 EXPECT_EQ(frame_url_a2, root->child_at(0)->current_url());
3593
3594 // Let the main frame commit.
3595 mainframe_delayer.ResumeNavigation();
3596 mainframe_delayer.WaitForNavigationFinished();
3597 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
3598 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
3599 EXPECT_EQ(url_b, root->current_url());
3600 EXPECT_EQ(frame_url_b1, root->child_at(0)->current_url());
3601
3602 // Check the PageState of the previous entry to ensure it isn't corrupted.
3603 NavigationEntry* entry = controller.GetEntryAtIndex(1);
3604 EXPECT_EQ(url_a, entry->GetURL());
3605 ExplodedPageState exploded_state;
3606 EXPECT_TRUE(
3607 DecodePageState(entry->GetPageState().ToEncodedData(), &exploded_state));
3608 EXPECT_EQ(url_a, GURL(exploded_state.top.url_string.string()));
3609 EXPECT_EQ(frame_url_a2,
3610 GURL(exploded_state.top.children.at(0).url_string.string()));
3611 }
3612
3524 } // namespace content 3613 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698