Index: content/browser/site_per_process_browsertest.cc |
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
index e61c79084d804712fa773b8bb3aefedb3ed21fbb..d8f517e83baff1feb9618154f3e63c20ceb89c09 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -786,6 +786,44 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
DepictFrameTree(root)); |
} |
+// Ensure that title updates affect the correct NavigationEntry after a new |
+// subframe navigation with an out-of-process iframe. https://crbug.com/616609. |
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, TitleAfterCrossSiteIframe) { |
+ // Start at an initial page. |
+ GURL initial_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
+ EXPECT_TRUE(NavigateToURL(shell(), initial_url)); |
+ |
+ // Navigate to a same-site page with a same-site iframe. |
+ GURL main_url(embedded_test_server()->GetURL( |
+ "a.com", "/cross_site_iframe_factory.html?a(a)")); |
+ EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
+ |
+ FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
+ |
+ // Make the main frame update its title after the subframe loads. |
+ EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
+ "document.querySelector('iframe').onload = " |
+ " function() { document.title = 'loaded'; };")); |
+ EXPECT_TRUE( |
+ ExecuteScript(shell()->web_contents(), "document.title = 'not loaded';")); |
+ base::string16 expected_title(base::UTF8ToUTF16("loaded")); |
+ TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
+ |
+ // Navigate the iframe cross-site. |
+ TestNavigationObserver load_observer(shell()->web_contents()); |
+ GURL frame_url = embedded_test_server()->GetURL("b.com", "/title2.html"); |
+ EXPECT_TRUE( |
+ ExecuteScript(root->child_at(0)->current_frame_host(), |
+ "window.location.href = '" + frame_url.spec() + "';")); |
+ load_observer.Wait(); |
+ |
+ // Wait for the title to update and ensure it affects the right NavEntry. |
+ EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
+ NavigationEntry* entry = |
+ shell()->web_contents()->GetController().GetLastCommittedEntry(); |
+ EXPECT_EQ(expected_title, entry->GetTitle()); |
+} |
+ |
// Class to sniff incoming IPCs for FrameHostMsg_FrameRectChanged messages. |
class FrameRectChangedMessageFilter : public content::BrowserMessageFilter { |
public: |