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

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

Issue 2316003002: Notify the renderer if a history navigation has no subframe items. (Closed)
Patch Set: Alex's review Created 4 years, 2 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 | content/browser/frame_host/navigation_entry_impl.h » ('j') | 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"
(...skipping 3624 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 EXPECT_EQ(main_url_a, new_entry->root_node()->frame_entry->url()); 3635 EXPECT_EQ(main_url_a, new_entry->root_node()->frame_entry->url());
3636 ASSERT_EQ(1U, new_entry->root_node()->children.size()); 3636 ASSERT_EQ(1U, new_entry->root_node()->children.size());
3637 EXPECT_EQ(frame_url_b, 3637 EXPECT_EQ(frame_url_b,
3638 new_entry->root_node()->children[0]->frame_entry->url()); 3638 new_entry->root_node()->children[0]->frame_entry->url());
3639 } else { 3639 } else {
3640 // There are no subframe FrameNavigationEntries by default. 3640 // There are no subframe FrameNavigationEntries by default.
3641 EXPECT_EQ(0U, new_entry->root_node()->children.size()); 3641 EXPECT_EQ(0U, new_entry->root_node()->children.size());
3642 } 3642 }
3643 } 3643 }
3644 3644
3645 // Verify that we can finish loading a page on restore if the PageState is
3646 // missing subframes. See https://crbug.com/638088.
3647 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3648 FrameNavigationEntry_RestoreViaPartialPageState) {
3649 GURL main_url(embedded_test_server()->GetURL(
3650 "a.com", "/navigation_controller/inject_into_blank_iframe.html"));
3651 GURL blank_url(url::kAboutBlankURL);
3652 NavigationControllerImpl& controller =
3653 static_cast<NavigationControllerImpl&>(
3654 shell()->web_contents()->GetController());
3655 FrameTreeNode* root =
3656 static_cast<WebContentsImpl*>(shell()->web_contents())
3657 ->GetFrameTree()
3658 ->root();
3659
3660 // Create a NavigationEntry to restore, as if it had been loaded before. The
3661 // page has an about:blank iframe and injects content into it, but the
3662 // PageState lacks any subframe history items. This may happen during a
3663 // restore of a bad session or if the page has changed since the last visit.
3664 // Chrome should be robust to this and should be able to load the frame from
3665 // its default URL.
3666 std::unique_ptr<NavigationEntryImpl> restored_entry =
3667 NavigationEntryImpl::FromNavigationEntry(
3668 NavigationControllerImpl::CreateNavigationEntry(
3669 main_url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false,
3670 std::string(), controller.GetBrowserContext()));
3671 restored_entry->SetPageID(0);
3672 restored_entry->SetPageState(PageState::CreateFromURL(main_url));
3673 EXPECT_EQ(0U, restored_entry->root_node()->children.size());
3674
3675 // Restore the new entry in a new tab and verify the iframe loads and has
3676 // content injected into it.
3677 std::vector<std::unique_ptr<NavigationEntry>> entries;
3678 entries.push_back(std::move(restored_entry));
3679 controller.Restore(entries.size() - 1,
3680 RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries);
alexmos 2016/09/22 21:09:39 nit: indent
Charlie Reis 2016/09/22 21:14:39 Done.
3681 ASSERT_EQ(0u, entries.size());
3682 {
3683 TestNavigationObserver restore_observer(shell()->web_contents());
3684 controller.LoadIfNecessary();
3685 restore_observer.Wait();
3686 }
3687 ASSERT_EQ(1U, root->child_count());
3688 EXPECT_EQ(main_url, root->current_url());
3689 EXPECT_EQ(blank_url, root->child_at(0)->current_url());
3690
3691 EXPECT_EQ(1, controller.GetEntryCount());
3692 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3693 NavigationEntryImpl* new_entry = controller.GetLastCommittedEntry();
3694
3695 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
3696 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3697 // The entry should have a FrameNavigationEntry for the blank subframe.
3698 EXPECT_EQ(main_url, new_entry->root_node()->frame_entry->url());
3699 ASSERT_EQ(1U, new_entry->root_node()->children.size());
3700 EXPECT_EQ(blank_url,
3701 new_entry->root_node()->children[0]->frame_entry->url());
3702 } else {
3703 EXPECT_EQ(0U, new_entry->root_node()->children.size());
3704 }
3705
3706 // Verify that the parent was able to script the iframe.
3707 std::string expected_text("Injected text");
3708 {
3709 std::string value;
3710 EXPECT_TRUE(ExecuteScriptAndExtractString(
3711 root->child_at(0),
3712 "domAutomationController.send(document.body.innerHTML)", &value));
3713 EXPECT_EQ(expected_text, value);
3714 }
3715 }
3716
3645 // Verifies that the |frame_unique_name| is set to the correct frame, so that we 3717 // Verifies that the |frame_unique_name| is set to the correct frame, so that we
3646 // can match subframe FrameNavigationEntries to newly created frames after 3718 // can match subframe FrameNavigationEntries to newly created frames after
3647 // back/forward and restore. 3719 // back/forward and restore.
3648 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 3720 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3649 FrameNavigationEntry_FrameUniqueName) { 3721 FrameNavigationEntry_FrameUniqueName) {
3650 const NavigationControllerImpl& controller = 3722 const NavigationControllerImpl& controller =
3651 static_cast<const NavigationControllerImpl&>( 3723 static_cast<const NavigationControllerImpl&>(
3652 shell()->web_contents()->GetController()); 3724 shell()->web_contents()->GetController());
3653 3725
3654 // 1. Navigate the main frame. 3726 // 1. Navigate the main frame.
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after
6042 content::FaviconStatus& favicon_status2 = entry->GetFavicon(); 6114 content::FaviconStatus& favicon_status2 = entry->GetFavicon();
6043 EXPECT_TRUE(favicon_status2.valid); 6115 EXPECT_TRUE(favicon_status2.valid);
6044 6116
6045 ASSERT_TRUE(RendererLocationReplace(shell(), GURL("data:text/html,page2"))); 6117 ASSERT_TRUE(RendererLocationReplace(shell(), GURL("data:text/html,page2")));
6046 entry = controller.GetLastCommittedEntry(); 6118 entry = controller.GetLastCommittedEntry();
6047 content::FaviconStatus& favicon_status3 = entry->GetFavicon(); 6119 content::FaviconStatus& favicon_status3 = entry->GetFavicon();
6048 EXPECT_FALSE(favicon_status3.valid); 6120 EXPECT_FALSE(favicon_status3.valid);
6049 } 6121 }
6050 6122
6051 } // namespace content 6123 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698