summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravi <avi@chromium.org>2015-05-20 21:42:12 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-21 04:43:09 +0000
commit954dff9e0261be9d1d691b65d070b0ec70caf1b8 (patch)
tree0dc3629d0daa84337560a6a9854a08220a4636cb
parent803ff930a0556a59087e24c2a5461325c01185b9 (diff)
downloadchromium_src-954dff9e0261be9d1d691b65d070b0ec70caf1b8.zip
chromium_src-954dff9e0261be9d1d691b65d070b0ec70caf1b8.tar.gz
chromium_src-954dff9e0261be9d1d691b65d070b0ec70caf1b8.tar.bz2
Ensure that unique ids are unique.
BUG=369661 TEST=NavigationControllerBrowserTest.UniqueIDs Review URL: https://codereview.chromium.org/1139823006 Cr-Commit-Position: refs/heads/master@{#330893}
-rw-r--r--content/browser/frame_host/navigation_controller_impl_browsertest.cc21
-rw-r--r--content/browser/frame_host/navigation_entry_impl.cc4
-rw-r--r--content/test/data/navigation_controller/page_with_link_to_load_iframe.html7
3 files changed, 30 insertions, 2 deletions
diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
index 6cc541e..3f371bf 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -57,6 +57,27 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) {
EXPECT_EQ(controller.GetVisibleEntry()->GetOriginalRequestURL(), history_url);
}
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) {
+ const NavigationControllerImpl& controller =
+ static_cast<const NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+
+ GURL main_url(embedded_test_server()->GetURL(
+ "/navigation_controller/page_with_link_to_load_iframe.html"));
+ NavigateToURL(shell(), main_url);
+ ASSERT_EQ(1, controller.GetEntryCount());
+
+ // Use JavaScript to click the link and load the iframe.
+ std::string script = "document.getElementById('link').click()";
+ EXPECT_TRUE(content::ExecuteScript(shell()->web_contents(), script));
+ EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
+ ASSERT_EQ(2, controller.GetEntryCount());
+
+ // Unique IDs should... um... be unique.
+ ASSERT_NE(controller.GetEntryAtIndex(0)->GetUniqueID(),
+ controller.GetEntryAtIndex(1)->GetUniqueID());
+}
+
// The renderer uses the position in the history list as a clue to whether a
// navigation is stale. In the case where the entry limit is reached and the
// history list is pruned, make sure that there is no mismatch that would cause
diff --git a/content/browser/frame_host/navigation_entry_impl.cc b/content/browser/frame_host/navigation_entry_impl.cc
index f7196a0..2723606 100644
--- a/content/browser/frame_host/navigation_entry_impl.cc
+++ b/content/browser/frame_host/navigation_entry_impl.cc
@@ -346,8 +346,8 @@ NavigationEntryImpl* NavigationEntryImpl::Clone() const {
// the same tab.
copy->frame_tree_.reset(frame_tree_->Clone());
- // Copy all state over, unless cleared in ResetForCommit.
- copy->unique_id_ = unique_id_;
+ // Copy most state over, unless cleared in ResetForCommit.
+ // Don't copy unique_id_, otherwise it won't be unique.
copy->bindings_ = bindings_;
copy->page_type_ = page_type_;
copy->virtual_url_ = virtual_url_;
diff --git a/content/test/data/navigation_controller/page_with_link_to_load_iframe.html b/content/test/data/navigation_controller/page_with_link_to_load_iframe.html
new file mode 100644
index 0000000..4a868e6
--- /dev/null
+++ b/content/test/data/navigation_controller/page_with_link_to_load_iframe.html
@@ -0,0 +1,7 @@
+<html>
+<head></head>
+<body>
+ <p><a href="simple_page_1.html" id="link" target="frame">go</a>
+ <p><iframe src="about:blank" name="frame"></iframe>
+</body>
+</html>