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

Unified Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2550113002: Send a subtree of same-process PageStates for back/forward child frames.
Patch Set: Rebase Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
index 4b98ab1516f2c28dd46662533ba0461b03ac2d82..8bdf7ce2a4c46d6a11b8e57285cc39bf250bd4cf 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -3466,6 +3466,86 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
}
}
+// Verify that we don't clobber any content injected into the initial blank page
+// if we go back to an about:blank/#foo subframe. See https://crbug.com/NNNNNN.
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ FrameNavigationEntry_RecreatedBlankFragmentSubframe) {
+ // 1. Start on a page that injects content into an about:blank/#foo iframe.
+ GURL main_url(embedded_test_server()->GetURL(
+ "/navigation_controller/inject_into_blank_iframe_with_fragment.html"));
+ // TODO(creis): Don't rewrite about:blank/#foo to about:blank.
+ GURL blank_url(url::kAboutBlankURL);
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+ NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+ ASSERT_EQ(1U, root->child_count());
+ ASSERT_EQ(0U, root->child_at(0)->child_count());
+ EXPECT_EQ(main_url, root->current_url());
+ EXPECT_EQ(blank_url, root->child_at(0)->current_url());
+
+ // Verify that the parent was able to script the iframe.
+ std::string expected_text("Injected text");
+ {
+ std::string value;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root->child_at(0),
+ "domAutomationController.send(document.body.innerHTML)", &value));
+ EXPECT_EQ(expected_text, value);
+ }
+
+ EXPECT_EQ(1, controller.GetEntryCount());
+ EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
+ NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
+
+ // The entry should have a FrameNavigationEntry for the blank subframe.
+ if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
+ ASSERT_EQ(1U, entry->root_node()->children.size());
+ EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
+ }
+
+ // 2. Navigate the main frame, destroying the frames.
+ GURL main_url_2(embedded_test_server()->GetURL(
+ "/navigation_controller/simple_page_1.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), main_url_2));
+ ASSERT_EQ(0U, root->child_count());
+ EXPECT_EQ(main_url_2, root->current_url());
+
+ EXPECT_EQ(2, controller.GetEntryCount());
+ EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
+
+ // 3. Go back, recreating the iframe.
+ {
+ TestNavigationObserver back_load_observer(shell()->web_contents());
+ controller.GoBack();
+ back_load_observer.Wait();
+ }
+ ASSERT_EQ(1U, root->child_count());
+ EXPECT_EQ(main_url, root->current_url());
+ EXPECT_EQ(blank_url, root->child_at(0)->current_url());
+
+ // Verify that the parent was able to script the iframe.
+ {
+ std::string value;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root->child_at(0),
+ "domAutomationController.send(document.body.innerHTML)", &value));
+ EXPECT_EQ(expected_text, value);
+ }
+
+ EXPECT_EQ(2, controller.GetEntryCount());
+ EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
+ EXPECT_EQ(entry, controller.GetLastCommittedEntry());
+
+ // The entry should have a FrameNavigationEntry for the blank subframe.
+ if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
+ ASSERT_EQ(1U, entry->root_node()->children.size());
+ EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
+ }
+}
+
// Ensure we don't crash if an onload handler removes an about:blank frame after
// recreating it on a back/forward. See https://crbug.com/638166.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
« 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